Repository navigation
refactor(ocr): remove the Python OCR execution path and require the Rust route - #43081
Conversation
…ust route Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Replace passthrough_url/passthrough_transform with passthrough_response, which matches the relayed endpoint against each Azure config's path segments instead of building a fake request to call get_complete_url. The binding drops the unused headers, status and api_base arguments. Catch the ValueError/RuntimeError the binding raises so a relayed body that is not OCR-shaped falls back to the passthrough object instead of failing logging, and cover the relay against the real binding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The public litellm.ocr / aocr / Router interface is unchanged by the Rust migration, so the live provider matrix still applies. Drops the stale VCR skip list for the deleted test_rust_bridge.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@greptile-apps wdyt |
…3266) test_update_config_success_callback_normalization replaced proxy_server.proxy_logging_obj with a MagicMock and never restored it. Since the proxy unit tests joined tests/unit (#42903), 14 JWT mapping, end-user and MCP tests on the same xdist worker awaited that mock and failed. The test now uses monkeypatch. test_prometheus_logging_callbacks set verbose_logger to DEBUG and litellm.set_verbose at import, so every worker in the unit job ran with DEBUG on. That broke caplog equality in the JEV classifier test, the vertex streaming memory ratio, and four event-loop lag checks. The module-level setup is removed; nothing in the file depended on it. #43081 removed the OCR harness modules but left them in the importability parametrize list. test_get_model_info_bedrock_region reassigned litellm.model_cost and set LITELLM_LOCAL_MODEL_COST_MAP without restoring either, and never cleared the get_model_info caches, so it failed whenever an earlier test had looked up the regional model. It now uses monkeypatch and invalidates the caches; the local_testing isolation fixture also invalidates them after restoring model_cost. The Windows job hit CircleCI's 10 minute no-output limit while cargo compiles the Rust crates inside uv sync and uv build. Those two steps now allow 30 minutes of silence.
…3266) test_update_config_success_callback_normalization replaced proxy_server.proxy_logging_obj with a MagicMock and never restored it. Since the proxy unit tests joined tests/unit (#42903), 14 JWT mapping, end-user and MCP tests on the same xdist worker awaited that mock and failed. The test now uses monkeypatch. test_prometheus_logging_callbacks set verbose_logger to DEBUG and litellm.set_verbose at import, so every worker in the unit job ran with DEBUG on. That broke caplog equality in the JEV classifier test, the vertex streaming memory ratio, and four event-loop lag checks. The module-level setup is removed; nothing in the file depended on it. #43081 removed the OCR harness modules but left them in the importability parametrize list. test_get_model_info_bedrock_region reassigned litellm.model_cost and set LITELLM_LOCAL_MODEL_COST_MAP without restoring either, and never cleared the get_model_info caches, so it failed whenever an earlier test had looked up the regional model. It now uses monkeypatch and invalidates the caches; the local_testing isolation fixture also invalidates them after restoring model_cost. The Windows job hit CircleCI's 10 minute no-output limit while cargo compiles the Rust crates inside uv sync and uv build. Those two steps now allow 30 minutes of silence. (cherry picked from commit 7fc2206)
…3266) (#43267) test_update_config_success_callback_normalization replaced proxy_server.proxy_logging_obj with a MagicMock and never restored it. Since the proxy unit tests joined tests/unit (#42903), 14 JWT mapping, end-user and MCP tests on the same xdist worker awaited that mock and failed. The test now uses monkeypatch. test_prometheus_logging_callbacks set verbose_logger to DEBUG and litellm.set_verbose at import, so every worker in the unit job ran with DEBUG on. That broke caplog equality in the JEV classifier test, the vertex streaming memory ratio, and four event-loop lag checks. The module-level setup is removed; nothing in the file depended on it. #43081 removed the OCR harness modules but left them in the importability parametrize list. test_get_model_info_bedrock_region reassigned litellm.model_cost and set LITELLM_LOCAL_MODEL_COST_MAP without restoring either, and never cleared the get_model_info caches, so it failed whenever an earlier test had looked up the regional model. It now uses monkeypatch and invalidates the caches; the local_testing isolation fixture also invalidates them after restoring model_cost. The Windows job hit CircleCI's 10 minute no-output limit while cargo compiles the Rust crates inside uv sync and uv build. Those two steps now allow 30 minutes of silence. (cherry picked from commit 7fc2206)
Stacked on #43057 (
now-read-secrets-from-rust). Merge that one first; this PR only carries the OCR commit on topTLDR
Problem this solves:
How it solves it:
catalog.py:Route.OCRisRUST_REQUIREDfor every provider, no opt-outlitellm.ocrdispatch usesruntime.NO_PYTHON;litellm/ocr/main.pyis goneBaseLLMHTTPHandler.ocr/aocr,BaseOCRConfig,get_provider_ocr_configand every providerocr/transformation package (mistral, azure_ai, vertex_ai, cohere, reducto); shared OCR response types stay inlitellm/llms/base_llm/ocr/transformation.pyocr_health_check_document(model, provider)for health checks andocr_passthrough_response(model, endpoint, body)for Azure AI passthrough OCR costing, which matches the relayed endpoint against the resolved Azure config's route and returnsNonefor anything elseUser Flow
Before: a proxy without the Rust extension still serves OCR through Python, and the two paths can drift
"model": "mistral/mistral-ocr-latest"and a document URLLITELLM_RUST_OCRopted out, the request runs in Python and returns 200 withoutx-litellm-rustx-litellm-rustAfter: every OCR request runs in Rust, and a proxy without the extension says so instead of silently falling back
"model": "mistral/mistral-ocr-latest"x-litellm-rust, for every OCR provider/model/healthfor OCR models and Azure AI passthrough OCR spend keep working as beforePre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Type
🧹 Refactoring
Caveats (if any)
Severe
/v1/ocrLITELLM_RUST_OCRopt-out no longer has any effectMedium
litellm.ocr.convert_file_document_to_url_documentandget_mime_typeare removed; Rust does that conversionBaseOCRConfig,MistralOCRConfigand the provider OCR config classes are no longer importableLow
make lintand the fullmake test-rust-extensionrun had not finished at PR open; CI covers themFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/aa43dbb4468742ea97eff2e1bb0a7824
Open in Devin Desktop: https://app.devin.ai/desktop/session/aa43dbb4468742ea97eff2e1bb0a7824?variant=devin
Requested by: @yujonglee-berri