mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
test(test_router.py): add unit test confirming fallbacks with tag based routing works as expected
This commit is contained in:
parent
174a1aa007
commit
2b81a76440
1 changed files with 40 additions and 0 deletions
|
@ -78,3 +78,43 @@ def test_router_with_model_info_and_model_group():
|
|||
model_group="gpt-3.5-turbo",
|
||||
user_facing_model_group_name="gpt-3.5-turbo",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_router_with_tags_and_fallbacks():
|
||||
"""
|
||||
If fallback model missing tag, raise error
|
||||
"""
|
||||
from litellm import Router
|
||||
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "gpt-3.5-turbo",
|
||||
"litellm_params": {
|
||||
"model": "gpt-3.5-turbo",
|
||||
"mock_response": "Hello, world!",
|
||||
"tags": ["test"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"model_name": "anthropic-claude-3-5-sonnet",
|
||||
"litellm_params": {
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"mock_response": "Hello, world 2!",
|
||||
},
|
||||
},
|
||||
],
|
||||
fallbacks=[
|
||||
{"gpt-3.5-turbo": ["anthropic-claude-3-5-sonnet"]},
|
||||
],
|
||||
enable_tag_filtering=True,
|
||||
)
|
||||
|
||||
with pytest.raises(Exception):
|
||||
response = await router.acompletion(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[{"role": "user", "content": "Hello, world!"}],
|
||||
mock_testing_fallbacks=True,
|
||||
metadata={"tags": ["test"]},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue