mirascope icon indicating copy to clipboard operation
mirascope copied to clipboard

Add Native Mistral OCR Support, Examples, and Tests

Open RepoBirdBot opened this issue 7 months ago • 1 comments

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.md explaining how to use the @mistral.ocr decorator. This includes prerequisites (installation of mistralai and environment variable setup) and usage notes for various document sources (URLs, local files, or byte streams).
  • Examples:

    • Provided both synchronous and asynchronous examples in examples/learn/provider_specific_features/mistral/ocr/sync.py and async.py to demonstrate how to handle different types of document input (bytes, URL, and file path).
  • Core Implementation:

    • Implemented the @mistral.ocr decorator to automatically call the Mistral OCR API and return a corresponding OCRResponse model.
    • Created the OCRResponse model in mirascope/core/mistral/ocr_response.py for convenient access to OCR results, including properties like full_text and a list of OCR page objects.
    • Exported the relevant classes and decorator in mirascope/core/mistral/__init__.py.
  • Testing:

    • Added tests in tests/core/mistral/test_ocr.py to 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.

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 📦🐦

RepoBirdBot avatar May 04 '25 08:05 RepoBirdBot

👋 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?

Thank you!

ariel-frischer avatar May 04 '25 08:05 ariel-frischer

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.

willbakst avatar Jun 19 '25 17:06 willbakst