mirascope
mirascope copied to clipboard
Add Native Mistral OCR Support, Examples, and Tests
This PR introduces native support for Mistral's newly released OCR feature. The implementation follows the existing pattern used in the Anthropic PDF handling and includes several key components:
-
Documentation:
- Added detailed documentation in
docs/learn/provider_specific_features/mistral.mdexplaining how to use the@mistral.ocrdecorator. This includes prerequisites (installation ofmistralaiand environment variable setup) and usage notes for various document sources (URLs, local files, or byte streams).
- Added detailed documentation in
-
Examples:
- Provided both synchronous and asynchronous examples in
examples/learn/provider_specific_features/mistral/ocr/sync.pyandasync.pyto demonstrate how to handle different types of document input (bytes, URL, and file path).
- Provided both synchronous and asynchronous examples in
-
Core Implementation:
- Implemented the
@mistral.ocrdecorator to automatically call the Mistral OCR API and return a correspondingOCRResponsemodel. - Created the
OCRResponsemodel inmirascope/core/mistral/ocr_response.pyfor convenient access to OCR results, including properties likefull_textand a list of OCR page objects. - Exported the relevant classes and decorator in
mirascope/core/mistral/__init__.py.
- Implemented the
-
Testing:
- Added tests in
tests/core/mistral/test_ocr.pyto verify the functionality and error handling of the Mistral OCR integration. These tests cover synchronous and asynchronous calls, input type validations, client type mismatches, and API errors.
- Added tests in
This enhancement makes it easier for users to integrate document analysis into their workflows by leveraging Mistral's OCR capabilities, with a consistent API design across the Mirascope library.
Please review the changes and verify that all documentation, examples, and tests meet the project standards.
Created with Repobird.ai 📦🐦
👋 Hello from RepoBird.ai!
I'm the founder of RepoBird.ai, an AI Software Engineer Agent that integrates seamlessly as a GitHub App.
This Pull Request was automatically generated by our agent, RepoBirdBot, to address issue #893. This issue was marked as a good first issue and appeared to be unassigned.
Why this PR?
- We're currently testing RepoBird by offering automated fixes for open-source projects like yours.
- Our goal is to help maintainers and provide useful contributions.
- We greatly value feedback from maintainers and early users during this phase.
Your Feedback Matters:
Please review the proposed changes. If this type of automated contribution isn't suitable for your repository, or if this specific PR isn't helpful, just let me know! I'll close it, make any improvements and unlist these PRs – no worries.
Want changes? If you have feedback or requested modifications, please leave comments directly on this PR. Once all review comments are in, comment @RepoBirdBot Update and I will manually run the agent again, taking into account all PR comments and any pipeline failure logs.
Interested in learning more?
- Visit Repobird.ai to explore our Agentic AI-driven code automation.
- Install the RepoBird GitHub App.
Thank you!
I have no desire to use this and am closing this issue.
For reference, the amount of time it would take me to review the code generated here to get it to be of high enough quality to merge would likely take longer than just implementing the issue myself.
The purpose of a "good first issue" is for an external contributor to have an opportunity to contribute to the repo and work with our team.