forked from phoenix/litellm-mirror
test test_default_tagged_deployments
This commit is contained in:
parent
c4052ee7d7
commit
fe7ab3f3d7
1 changed files with 61 additions and 0 deletions
|
@ -91,3 +91,64 @@ async def test_router_free_paid_tier():
|
|||
print("response_extra_info: ", response_extra_info)
|
||||
|
||||
assert response_extra_info["model_id"] == "very-expensive-model"
|
||||
|
||||
|
||||
@pytest.mark.asyncio()
|
||||
async def test_default_tagged_deployments():
|
||||
"""
|
||||
- only use default deployment for untagged requests
|
||||
- if a request has tag "default", use default deployment
|
||||
"""
|
||||
|
||||
router = litellm.Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "gpt-4",
|
||||
"litellm_params": {
|
||||
"model": "gpt-4o",
|
||||
"api_base": "https://exampleopenaiendpoint-production.up.railway.app/",
|
||||
"tags": ["default"],
|
||||
},
|
||||
"model_info": {"id": "default-model"},
|
||||
},
|
||||
{
|
||||
"model_name": "gpt-4",
|
||||
"litellm_params": {
|
||||
"model": "gpt-4o-mini",
|
||||
"api_base": "https://exampleopenaiendpoint-production.up.railway.app/",
|
||||
"tags": ["teamA"],
|
||||
},
|
||||
"model_info": {"id": "very-expensive-model"},
|
||||
},
|
||||
],
|
||||
enable_tag_filtering=True,
|
||||
)
|
||||
|
||||
for _ in range(5):
|
||||
# Untagged request, this should pick model with id == "default-model"
|
||||
response = await router.acompletion(
|
||||
model="gpt-4",
|
||||
messages=[{"role": "user", "content": "Tell me a joke."}],
|
||||
)
|
||||
|
||||
print("Response: ", response)
|
||||
|
||||
response_extra_info = response._hidden_params
|
||||
print("response_extra_info: ", response_extra_info)
|
||||
|
||||
assert response_extra_info["model_id"] == "default-model"
|
||||
|
||||
for _ in range(5):
|
||||
# requests tagged with "default", this should pick model with id == "default-model"
|
||||
response = await router.acompletion(
|
||||
model="gpt-4",
|
||||
messages=[{"role": "user", "content": "Tell me a joke."}],
|
||||
metadata={"tags": ["default"]},
|
||||
)
|
||||
|
||||
print("Response: ", response)
|
||||
|
||||
response_extra_info = response._hidden_params
|
||||
print("response_extra_info: ", response_extra_info)
|
||||
|
||||
assert response_extra_info["model_id"] == "default-model"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue