Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(rust-bridge): narrow OCR input_sources values to the native InputSource variants

Yujong Leec7c71b95ad90
diff --git a/litellm/rust_bridge/_native.pyi b/litellm/rust_bridge/_native.pyi
index 4c1033aee79..e62c85f4599 100644
--- a/litellm/rust_bridge/_native.pyi
+++ b/litellm/rust_bridge/_native.pyi
@@ -1,10 +1,12 @@
from asyncio import Future
from collections.abc import Coroutine, Mapping, Sequence
-from typing import Never, final
+from typing import Literal, Never, TypeAlias, final
from litellm.llms.base_llm.ocr.transformation import OCRResponse
from litellm.rust_bridge.ocr import LiteLLMOcrRequest
+_InputSource: TypeAlias = Literal["request", "deployment", "environment"]
+
class RustBridgeDeclined(Exception): ...
class RustUpstreamError(Exception): ...
@@ -16,7 +18,7 @@ def ocr(
custom_llm_provider: str | None = None,
extra_headers: Mapping[str, object] | None = None,
optional_params: Mapping[str, object] | None = None,
- input_sources: Mapping[str, str] | None = None,
+ input_sources: Mapping[str, _InputSource] | None = None,
timeout_seconds: float | None = None,
) -> dict[str, object]: ...
def aocr(
@@ -27,7 +29,7 @@ def aocr(
custom_llm_provider: str | None = None,
extra_headers: Mapping[str, object] | None = None,
optional_params: Mapping[str, object] | None = None,
- input_sources: Mapping[str, str] | None = None,
+ input_sources: Mapping[str, _InputSource] | None = None,
timeout_seconds: float | None = None,
) -> Future[dict[str, object]]: ...