mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
test(router): cover OCR capability filtering
Signed-off-by: Zhibo Zhang <24061721@hdu.edu.cn>
This commit is contained in:
parent
371f7e3cf8
commit
f035d67cbd
1 changed files with 45 additions and 0 deletions
45
tests/unit/test_router/test_router_ocr_capability.py
Normal file
45
tests/unit/test_router/test_router_ocr_capability.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
from litellm import Router
|
||||
|
||||
|
||||
def test_router_ocr_capability_gate_skips_chat_fallbacks() -> None:
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "document-ocr",
|
||||
"litellm_params": {"model": "openai/gpt-4o"},
|
||||
"model_info": {"id": "ocr", "mode": "ocr"},
|
||||
},
|
||||
{
|
||||
"model_name": "document-ocr",
|
||||
"litellm_params": {"model": "openai/gpt-4o-mini"},
|
||||
"model_info": {"id": "chat", "mode": "chat"},
|
||||
},
|
||||
],
|
||||
enable_pre_call_checks=True,
|
||||
)
|
||||
|
||||
async def aocr(*args, **kwargs):
|
||||
return None
|
||||
|
||||
async def chat(*args, **kwargs):
|
||||
return None
|
||||
|
||||
deployments = router.get_model_list(model_name="document-ocr")
|
||||
chat_deployments = router._pre_call_checks(
|
||||
model="document-ocr",
|
||||
healthy_deployments=deployments,
|
||||
messages=None,
|
||||
input=None,
|
||||
request_kwargs={"original_function": chat},
|
||||
)
|
||||
assert [deployment["model_info"]["id"] for deployment in chat_deployments] == ["ocr", "chat"]
|
||||
|
||||
ocr_deployments = router._pre_call_checks(
|
||||
model="document-ocr",
|
||||
healthy_deployments=deployments,
|
||||
messages=None,
|
||||
input=None,
|
||||
request_kwargs={"original_function": aocr},
|
||||
)
|
||||
assert [deployment["model_info"]["id"] for deployment in ocr_deployments] == ["ocr"]
|
||||
Loading…
Add table
Reference in a new issue