fix(proxy): use completion_model as fallback instead of override

completion_model in general_settings always overrode the client-specified
model because it was evaluated first in the Python `or` chain. Reorder
the resolution so the client request model takes priority, matching the
documented behavior: "The default model to use for completions when
model is not specified in the request."

Fixes #21554
This commit is contained in:
hzt 2026-02-20 13:22:58 +08:00
parent 37c98f8325
commit bd89d03d2d
2 changed files with 4 additions and 4 deletions

View file

@ -597,10 +597,10 @@ class ProxyBaseLLMRequestProcessing:
] = queue_time_seconds
self.data["model"] = (
general_settings.get("completion_model", None) # server default
self.data.get("model", None) # model passed in http request
or user_model # model name passed via cli args
or model # for azure deployments
or self.data.get("model", None) # default passed in http request
or general_settings.get("completion_model", None) # server default (fallback)
)
# override with user settings, these are params passed via cli

View file

@ -168,9 +168,9 @@ async def chat_completion_pass_through_endpoint( # noqa: PLR0915
"Request received by LiteLLM:\n{}".format(json.dumps(data, indent=4)),
)
data["model"] = (
general_settings.get("completion_model", None) # server default
data.get("model", None) # model passed in http request
or user_model # model name passed via cli args
or data.get("model", None) # default passed in http request
or general_settings.get("completion_model", None) # server default (fallback)
)
if user_model:
data["model"] = user_model