diff --git a/litellm/llms/vertex_ai/ocr/deepseek_transformation.py b/litellm/llms/vertex_ai/ocr/deepseek_transformation.py index 1db454ad1f6..2603552152d 100644 --- a/litellm/llms/vertex_ai/ocr/deepseek_transformation.py +++ b/litellm/llms/vertex_ai/ocr/deepseek_transformation.py @@ -38,22 +38,6 @@ class VertexAIDeepSeekOCRConfig(BaseOCRConfig): super().__init__() self.vertex_base = VertexBase() - def get_supported_ocr_params(self, model: str) -> list[str]: # mutable-ok: base contract - return ["stream", "temperature", "max_tokens", "top_p", "n", "stop"] # mutable-ok: base contract - - def map_ocr_params( - self, - non_default_params: dict[str, object], # mutable-ok: base contract - optional_params: dict[str, object], # mutable-ok: base contract - model: str, - ) -> dict[str, object]: # mutable-ok: base contract - return { # mutable-ok: base contract - **optional_params, - **{ # mutable-ok: base contract - key: value for key, value in non_default_params.items() if key in self.get_supported_ocr_params(model) - }, - } - def get_api_key_env_var(self) -> str | None: return VERTEX_AI_DEEPSEEK_OCR_API_KEY_ENV_VAR @@ -193,9 +177,8 @@ class VertexAIDeepSeekOCRConfig(BaseOCRConfig): content_item = {"type": "image_url", "image_url": document_url} # Build DeepSeek OCR request - upstream_model: Final = model if model.startswith("deepseek-ai/") else f"deepseek-ai/{model}" data: Final = { - "model": upstream_model, + "model": "deepseek-ai/" + model, "messages": [{"role": "user", "content": [content_item]}], } diff --git a/tests/test_litellm/ocr/fixtures/models.py b/tests/test_litellm/ocr/fixtures/models.py index 95927c91ec0..95f020f104d 100644 --- a/tests/test_litellm/ocr/fixtures/models.py +++ b/tests/test_litellm/ocr/fixtures/models.py @@ -135,17 +135,11 @@ class AzureDocumentIntelligenceOcrSdkInput(OcrSdkInputBase): class VertexDeepSeekOcrSdkInput(OcrSdkInputBase): boundary: Literal["vertex_deepseek"] = "vertex_deepseek" - model: Literal["vertex_ai/deepseek-ai/deepseek-ocr-maas"] = "vertex_ai/deepseek-ai/deepseek-ocr-maas" + model: Literal["vertex_ai/deepseek-ocr-maas"] = "vertex_ai/deepseek-ocr-maas" document: MistralDocument custom_llm_provider: Literal["vertex_ai"] | None = None vertex_project: str vertex_location: str = "us-central1" - stream: bool | None = None - temperature: float | None = None - max_tokens: int | None = None - top_p: float | None = None - n: int | None = None - stop: str | list[str] | None = None def _validate_reducto_source(source: str) -> str: diff --git a/tests/test_litellm/ocr/fixtures/vertex.py b/tests/test_litellm/ocr/fixtures/vertex.py index 0b71a26a536..1fb36c7c665 100644 --- a/tests/test_litellm/ocr/fixtures/vertex.py +++ b/tests/test_litellm/ocr/fixtures/vertex.py @@ -33,41 +33,22 @@ def _as_vertex_mistral(case_input: MistralOcrSdkInput, project: str, location: s def _required_deepseek_inputs(project: str, location: str) -> tuple[VertexDeepSeekOcrSdkInput, ...]: - document: Final = image_document("invoice 123", 24) - common: Final = {"document": document, "vertex_project": project, "vertex_location": location} - cases: Final[tuple[dict[str, object], ...]] = ( - {}, - {"stream": False}, - {"temperature": 0.5}, - {"max_tokens": 256}, - {"top_p": 0.9}, - {"n": 1}, - {"stop": ["END", "STOP"]}, + return ( + VertexDeepSeekOcrSdkInput( + document=image_document("invoice 123", 24), + vertex_project=project, + vertex_location=location, + ), ) - return tuple(VertexDeepSeekOcrSdkInput.model_validate({**common, **case}) for case in cases) @st.composite def vertex_deepseek_input_strategy(draw: DrawFn, project: str, location: str) -> VertexDeepSeekOcrSdkInput: - optional_params: Final = draw( - st.fixed_dictionaries( - {}, - optional={ - "stream": st.just(False), - "temperature": st.sampled_from((0.0, 0.5, 1.0)), - "max_tokens": st.sampled_from((1, 256, 1024)), - "top_p": st.sampled_from((0.1, 0.9, 1.0)), - "n": st.just(1), - "stop": st.sampled_from(("END", ["END", "STOP"])), - }, - ) - ) return VertexDeepSeekOcrSdkInput.model_validate( { "document": draw(public_document_strategy()), "vertex_project": project, "vertex_location": location, - **optional_params, } ) diff --git a/tests/test_litellm/ocr/test_fixture_models.py b/tests/test_litellm/ocr/test_fixture_models.py index fc563ed657d..26264a97b6d 100644 --- a/tests/test_litellm/ocr/test_fixture_models.py +++ b/tests/test_litellm/ocr/test_fixture_models.py @@ -82,37 +82,10 @@ def test_reducto_fixture_fields_match_provider_configs() -> None: def test_deepseek_fixture_fields_match_provider_config() -> None: assert _provider_fields(VertexDeepSeekOcrSdkInput) == _supported_params( - VertexAIDeepSeekOCRConfig(), "deepseek-ai/deepseek-ocr-maas" + VertexAIDeepSeekOCRConfig(), "deepseek-ocr-maas" ) -def test_deepseek_maps_litellm_params_without_duplicating_model_namespace() -> None: - config: Final = VertexAIDeepSeekOCRConfig() - optional_params: Final = config.map_ocr_params( - non_default_params={"temperature": 0.5, "max_tokens": 256}, - optional_params={}, - model="deepseek-ai/deepseek-ocr-maas", - ) - request: Final = config.transform_ocr_request( - model="deepseek-ai/deepseek-ocr-maas", - document={"type": "image_url", "image_url": "gs://bucket/document.png"}, - optional_params=optional_params, - headers={}, - ) - - assert request.data == { - "model": "deepseek-ai/deepseek-ocr-maas", - "messages": [ - { - "role": "user", - "content": [{"type": "image_url", "image_url": "gs://bucket/document.png"}], - } - ], - "temperature": 0.5, - "max_tokens": 256, - } - - @pytest.mark.parametrize( "sdk_input", (