From d2433ec0639191fcdb9e5328c6f00928c5d14564 Mon Sep 17 00:00:00 2001 From: Yujong Lee Date: Wed, 16 Sep 2026 19:35:28 +0000 Subject: [PATCH] fix(ocr): resolve decline types through native_exception_types Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/ocr/main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/litellm/ocr/main.py b/litellm/ocr/main.py index 44dd6210aaf..c6fca6078e5 100644 --- a/litellm/ocr/main.py +++ b/litellm/ocr/main.py @@ -4,7 +4,7 @@ from typing import Final, cast # noqa: TID251 # native binding selects a sync from litellm.llms.base_llm.ocr.transformation import OCRResponse from litellm.ocr import legacy from litellm.ocr.legacy import convert_file_document_to_url_document, get_mime_type -from litellm.rust_bridge.bindings import native_decline_types +from litellm.rust_bridge.bindings import native_exception_types from litellm.rust_bridge.configuration import rust_ocr_enabled from litellm.rust_bridge.ocr import NATIVE_AOCR, NATIVE_OCR @@ -19,7 +19,7 @@ def ocr( if native is not None: try: return native(*args, **kwargs) - except native_decline_types(): + except _decline_types(): pass fallback: Final = cast( # cast-ok: forward the original call shape through the legacy @client decorator Callable[..., OCRResponse | Coroutine[object, object, OCRResponse]], legacy.ocr @@ -32,9 +32,14 @@ async def aocr(*args: object, **kwargs: object) -> OCRResponse: # kwargs-ok: pr if native is not None: try: return await native(*args, **kwargs) - except native_decline_types(): + except _decline_types(): pass fallback: Final = cast( # cast-ok: forward the original call shape through the legacy @client decorator Callable[..., Awaitable[OCRResponse]], legacy.aocr ) return await fallback(*args, **kwargs) + + +def _decline_types() -> tuple[type[BaseException], ...]: + exception_types: Final = native_exception_types() + return (exception_types[0],) if exception_types is not None else ()