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]

refactor(ocr): drop mutable collection builds flagged by LIT002 gate

Yujong Lee4dcbef0558bf
diff --git a/litellm/ocr/legacy.py b/litellm/ocr/legacy.py
index 1c9e1c2c28f..27e72195b60 100644
--- a/litellm/ocr/legacy.py
+++ b/litellm/ocr/legacy.py
@@ -143,10 +143,9 @@ def _prepare_ocr_request(
)
except ValueError as error:
raise litellm.BadRequestError(message=str(error), model=model, llm_provider=custom_llm_provider) from error
- optional_params: Final = {
- **mapped_params,
- **({OCR_REQUEST_FORMAT_PARAM: requested_format} if requested_format is not None else {}),
- }
+ optional_params: Final = (
+ mapped_params if requested_format is None else {**mapped_params, OCR_REQUEST_FORMAT_PARAM: requested_format}
+ )
verbose_logger.debug("OCR optional_params after mapping: %s", optional_params)
@@ -185,7 +184,7 @@ def _error_provider(model: str, custom_llm_provider: str | None) -> str | None:
if custom_llm_provider is not None:
return custom_llm_provider
prefix: Final = model.partition("/")[0]
- if prefix in {"mistral", "azure_ai", "vertex_ai"}:
+ if prefix in ("mistral", "azure_ai", "vertex_ai"):
return prefix
return "mistral" if model.startswith("mistral-ocr") else None
@@ -224,7 +223,7 @@ async def aocr(
)
model = prepared.model
custom_llm_provider = prepared.custom_llm_provider
- completion_kwargs.update({"model": model, "custom_llm_provider": custom_llm_provider})
+ completion_kwargs.update(model=model, custom_llm_provider=custom_llm_provider)
response = base_llm_http_handler.ocr(
model=prepared.model,
@@ -390,7 +389,7 @@ def ocr(
)
model = prepared.model
custom_llm_provider = prepared.custom_llm_provider
- completion_kwargs.update({"model": model, "custom_llm_provider": custom_llm_provider})
+ completion_kwargs.update(model=model, custom_llm_provider=custom_llm_provider)
response: Final = base_llm_http_handler.ocr(
model=prepared.model,