From 6d831ffff4e279e859c733ed823ed7214da0ecea Mon Sep 17 00:00:00 2001 From: Cesar Garcia <128240629+Chesars@users.noreply.github.com> Date: Thu, 4 Dec 2025 02:28:13 -0300 Subject: [PATCH] fix(ocr): add missing ocr and aocr to CallTypes enum (#17435) Add `ocr` and `aocr` entries to the CallTypes enum to fix the ValueError that occurs when using the /v1/ocr endpoint with guardrails enabled. The OCR endpoint uses route_type="aocr", but the CallTypes enum was missing these values, causing guardrail hooks to fail when trying to instantiate CallTypes("aocr"). Fixes #17381 --- litellm/types/utils.py | 6 +++++ tests/test_litellm/test_main.py | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 65457fd3039..4861510da24 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -340,6 +340,12 @@ class CallTypes(str, Enum): generate_content_stream = "generate_content_stream" agenerate_content_stream = "agenerate_content_stream" + ######################################################### + # OCR Call Types + ######################################################### + ocr = "ocr" + aocr = "aocr" + ######################################################### # MCP Call Types ######################################################### diff --git a/tests/test_litellm/test_main.py b/tests/test_litellm/test_main.py index 71ede0958f5..d2416f8db8c 100644 --- a/tests/test_litellm/test_main.py +++ b/tests/test_litellm/test_main.py @@ -1461,3 +1461,43 @@ async def test_async_mock_completion_stream_with_model_response(): accumulated_content += chunk.choices[0].delta.content assert "This is an async test response" in accumulated_content or len(chunks) > 0 + + +class TestCallTypesOCR: + """Test that OCR call types are properly defined in CallTypes enum. + + Fixes https://github.com/BerriAI/litellm/issues/17381 + """ + + def test_ocr_call_type_exists(self): + """Test that CallTypes.ocr exists and has correct value.""" + from litellm.types.utils import CallTypes + + assert hasattr(CallTypes, "ocr") + assert CallTypes.ocr.value == "ocr" + + def test_aocr_call_type_exists(self): + """Test that CallTypes.aocr exists and has correct value.""" + from litellm.types.utils import CallTypes + + assert hasattr(CallTypes, "aocr") + assert CallTypes.aocr.value == "aocr" + + def test_ocr_call_type_from_string(self): + """Test that CallTypes can be constructed from 'ocr' string.""" + from litellm.types.utils import CallTypes + + call_type = CallTypes("ocr") + assert call_type == CallTypes.ocr + + def test_aocr_call_type_from_string(self): + """Test that CallTypes can be constructed from 'aocr' string. + + This is the actual use case that was failing - the OCR endpoint + uses route_type='aocr' and guardrails try to instantiate + CallTypes('aocr'). + """ + from litellm.types.utils import CallTypes + + call_type = CallTypes("aocr") + assert call_type == CallTypes.aocr