fix(openai): default Azure LLM model to deployment#6266
Conversation
|
nightcityblade seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
| @@ -238,8 +238,10 @@ def with_azure( | |||
| else httpx.Timeout(connect=15.0, read=5.0, write=5.0, pool=5.0), | |||
| ) # type: ignore | |||
|
|
|||
| resolved_model = model if model is not None else azure_deployment or "gpt-4o" | |||
There was a problem hiding this comment.
We can simply use unknown as the last resort, as the model parameter is only used for metric/label.
|
Addressed the review note in 4c0ede6. Validation:
|
|
I pushed a follow-up commit to align with the review suggestion: Azure now keeps as the fallback model label unless the caller explicitly provides , and I updated the config expectation to match.\n\nI also rechecked the simple constructor path locally against the new behavior. |
|
I pushed a follow-up commit to align with the review suggestion: Azure now keeps "unknown" as the fallback model label unless the caller explicitly provides I also rechecked the simple |
| # For Azure, the model name is only used as a metric label, so keep the | ||
| # fallback neutral unless the caller provided an explicit model name. | ||
| resolved_model = model if model is not None else "unknown" |
There was a problem hiding this comment.
π© Model value "unknown" is sent in the API request body to Azure
When model=None is passed to with_azure and no azure_deployment is provided either (as in test_llm_with_azure_uses_unknown_without_model_or_deployment), the string "unknown" will be sent as the model parameter in chat.completions.create() at livekit-agents/livekit/agents/inference/llm.py:351. With AsyncAzureOpenAI, if azure_deployment is None, the client may attempt to use the model value as the deployment name, which would cause a runtime 404 from the Azure API. This is arguably fine β the user failed to provide any routing info β but it's a change from the old default of "gpt-4o" which at least could match a real deployment name. The comment at llm.py:241-242 says the model is only used as a metric label, which is true when azure_deployment is set but not when it's absent.
Was this helpful? React with π or π to provide feedback.
There was a problem hiding this comment.
Good catch. The intent of the change was to avoid reporting a misleading default metric label when Azure callers provide a deployment but omit model, not to make the no-deployment path any more valid than it already is.
If maintainers want, I can follow up by narrowing the fallback so we only use "unknown" when azure_deployment is set, and otherwise keep the previous behavior for the invalid no-deployment case. That would preserve the neutral label improvement without changing the request-routing fallback.
Fixes #6209
Summary
LLM.with_azure()from exposing the unrelatedgpt-4odefault when Azure callers only setazure_deploymentllm.modelreflect the configured deploymentTesting