mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
Litellm dev 12 12 2024 (#7203)
All checks were successful
Read Version from pyproject.toml / read-version (push) Successful in 47s
All checks were successful
Read Version from pyproject.toml / read-version (push) Successful in 47s
* fix(azure/): support passing headers to azure openai endpoints
Fixes https://github.com/BerriAI/litellm/issues/6217
* fix(utils.py): move default tokenizer to just openai
hf tokenizer makes network calls when trying to get the tokenizer - this slows down execution time calls
* fix(router.py): fix pattern matching router - add generic "*" to it as well
Fixes issue where generic "*" model access group wouldn't show up
* fix(pattern_match_deployments.py): match to more specific pattern
match to more specific pattern
allows setting generic wildcard model access group and excluding specific models more easily
* fix(proxy_server.py): fix _delete_deployment to handle base case where db_model list is empty
don't delete all router models b/c of empty list
Fixes https://github.com/BerriAI/litellm/issues/7196
* fix(anthropic/): fix handling response_format for anthropic messages with anthropic api
* fix(fireworks_ai/): support passing response_format + tool call in same message
Addresses https://github.com/BerriAI/litellm/issues/7135
* Revert "fix(fireworks_ai/): support passing response_format + tool call in same message"
This reverts commit 6a30dc6929
.
* test: fix test
* fix(replicate/): fix replicate default retry/polling logic
* test: add unit testing for router pattern matching
* test: update test to use default oai tokenizer
* test: mark flaky test
* test: skip flaky test
This commit is contained in:
parent
15a0572a06
commit
e68bb4e051
19 changed files with 496 additions and 103 deletions
|
@ -133,7 +133,7 @@ def test_route_with_multiple_matching_patterns():
|
|||
router.add_pattern("openai/*", deployment1.to_json(exclude_none=True))
|
||||
router.add_pattern("openai/gpt-*", deployment2.to_json(exclude_none=True))
|
||||
assert router.route("openai/gpt-3.5-turbo") == [
|
||||
deployment1.to_json(exclude_none=True)
|
||||
deployment2.to_json(exclude_none=True)
|
||||
]
|
||||
|
||||
|
||||
|
@ -237,3 +237,79 @@ def test_router_pattern_match_e2e():
|
|||
"model": "gpt-4o",
|
||||
"messages": [{"role": "user", "content": "Hello, how are you?"}],
|
||||
}
|
||||
|
||||
|
||||
def test_pattern_matching_router_with_default_wildcard():
|
||||
"""
|
||||
Tests that the router returns the default wildcard model when the pattern is not found
|
||||
|
||||
Make sure generic '*' allows all models to be passed through.
|
||||
"""
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "*",
|
||||
"litellm_params": {"model": "*"},
|
||||
"model_info": {"access_groups": ["default"]},
|
||||
},
|
||||
{
|
||||
"model_name": "anthropic-claude",
|
||||
"litellm_params": {"model": "anthropic/claude-3-5-sonnet"},
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
assert len(router.pattern_router.patterns) > 0
|
||||
|
||||
router.completion(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[{"role": "user", "content": "Hello, how are you?"}],
|
||||
)
|
||||
|
||||
|
||||
def test_pattern_matching_router_with_default_wildcard_and_model_wildcard():
|
||||
"""
|
||||
Match to more specific pattern first.
|
||||
"""
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "*",
|
||||
"litellm_params": {"model": "*"},
|
||||
"model_info": {"access_groups": ["default"]},
|
||||
},
|
||||
{
|
||||
"model_name": "llmengine/*",
|
||||
"litellm_params": {"model": "openai/*"},
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
assert len(router.pattern_router.patterns) > 0
|
||||
|
||||
pattern_router = router.pattern_router
|
||||
deployments = pattern_router.route("llmengine/gpt-3.5-turbo")
|
||||
assert len(deployments) == 1
|
||||
assert deployments[0]["model_name"] == "llmengine/*"
|
||||
|
||||
|
||||
def test_sorted_patterns():
|
||||
"""
|
||||
Tests that the pattern specificity is calculated correctly
|
||||
"""
|
||||
from litellm.router_utils.pattern_match_deployments import PatternUtils
|
||||
|
||||
sorted_patterns = PatternUtils.sorted_patterns(
|
||||
{
|
||||
"llmengine/*": [{"model_name": "anthropic/claude-3-5-sonnet"}],
|
||||
"*": [{"model_name": "openai/*"}],
|
||||
},
|
||||
)
|
||||
assert sorted_patterns[0][0] == "llmengine/*"
|
||||
|
||||
|
||||
def test_calculate_pattern_specificity():
|
||||
from litellm.router_utils.pattern_match_deployments import PatternUtils
|
||||
|
||||
assert PatternUtils.calculate_pattern_specificity("llmengine/*") == (11, 1)
|
||||
assert PatternUtils.calculate_pattern_specificity("*") == (1, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue