mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
perf: skip pattern_router.route() for non-wildcard models (#19664)
Check "*" in model before calling pattern_router.route() to avoid unnecessary pattern matching for non-wildcard model configurations.
This commit is contained in:
parent
54f9ad370f
commit
6e930c9724
1 changed files with 14 additions and 13 deletions
|
|
@ -6355,19 +6355,20 @@ class Router:
|
|||
elif custom_llm_provider != "azure":
|
||||
model = _model
|
||||
|
||||
potential_models = self.pattern_router.route(received_model_name)
|
||||
if "*" in model and potential_models is not None: # if wildcard route
|
||||
for potential_model in potential_models:
|
||||
try:
|
||||
if potential_model.get("model_info", {}).get(
|
||||
"id"
|
||||
) == deployment.get("model_info", {}).get("id"):
|
||||
model = potential_model.get("litellm_params", {}).get(
|
||||
"model"
|
||||
)
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
if "*" in model: # only call pattern_router for wildcard models
|
||||
potential_models = self.pattern_router.route(received_model_name)
|
||||
if potential_models is not None:
|
||||
for potential_model in potential_models:
|
||||
try:
|
||||
if potential_model.get("model_info", {}).get(
|
||||
"id"
|
||||
) == deployment.get("model_info", {}).get("id"):
|
||||
model = potential_model.get("litellm_params", {}).get(
|
||||
"model"
|
||||
)
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
## GET LITELLM MODEL INFO - raises exception, if model is not mapped
|
||||
if model is None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue