mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
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
This commit is contained in:
parent
1879623502
commit
6d831ffff4
2 changed files with 46 additions and 0 deletions
|
|
@ -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
|
||||
#########################################################
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue