fix(bundles): expose model name on the Azure OpenAI chat component - #14574
fix(bundles): expose model name on the Azure OpenAI chat component#14574andifilhohub wants to merge 1 commit into
Conversation
AzureChatOpenAIComponent only exposed the deployment name, with no way to tell langchain-openai's AzureChatOpenAI which underlying OpenAI model is behind that deployment. Some Azure configurations need this to resolve correctly, and it's required for accurate model-based tracing/token accounting and for langchain's model-name-gated feature checks (e.g. parallel_tool_calls, reasoning params). Add an optional, advanced "model" input (matching the sibling AzureOpenAIEmbeddingsComponent's field name) and pass it through to AzureChatOpenAI(model=...). When left blank it resolves to None, identical to current behavior, so existing flows are unaffected. Fixes langflow-ai#9855
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
WalkthroughThe Azure OpenAI component now accepts an advanced model name, forwards it to ChangesAzure OpenAI model configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The PR adds an optional model field for Azure OpenAI while preserving existing behavior when it is blank; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 9✅ Passed checks (9 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes #9855.
AzureChatOpenAIComponent(the "Azure OpenAI" model component) only exposed Deployment Name, with no way to telllangchain_openai.AzureChatOpenAIwhich underlying OpenAI model is behind that deployment. As reported in #9855, some Azure OpenAI configurations need the model name to resolve correctly, and it's also required for:AzureChatOpenAI._get_ls_params/_create_chat_resultfall back to the deployment name whenmodel_nameisNone, which usually doesn't match a real model id).langchain_openai's model-name-gated feature checks (e.g. theparallel_tool_callssupport check keys offmodel_name == "gpt-4o", and reasoning-specific params for o-series/gpt-5 models).Note: for plain Chat Completions routing,
azure_deploymentalone is already enough to reach the right deployment (the endpoint'sbase_urlis built from it at client construction), so the change here doesn't affect routing for the common case — it closes the actual gap in the issue (no way to declare the model at all) and the secondary correctness issues above.Changes
modelinput toAzureChatOpenAIComponent, matching the field name already used by the siblingAzureOpenAIEmbeddingsComponentin the same file.AzureChatOpenAI(model=self.model or None, ...).model=Noneis sent — identical to current behavior, so existing saved flows are unaffected.Kept deliberately minimal: no default value is forced on the new field (unlike the embeddings sibling / OpenAI component), because a forced default could silently mismatch a user's actual deployed model for existing flows that don't set this field.
One naming detail worth calling out for review: I initially named the field
model_name(matchingOpenAIModelComponent), but that collides withlfx/base/models/model_input_constants.py's shared "unified model providers" registry, which special-cases any input literally namedmodel_nameand expects aDropdownInputwith.comboboxsupport. SinceAzureChatOpenAIComponentis already registered there (currentlyis_active: False), that name broke import ofmodel_input_constants.pyitself (and everything that imports it —altk,cuga, the agent component, etc.) with a pydanticValidationError. Renaming the field tomodelavoids that collision entirely and still matches the sibling embeddings component's convention.Test plan
src/backend/tests/unit/components/bundles/azure/test_azure_openai_component.pycovering:build_model()passesmodel=through toAzureChatOpenAI.model=None).test_latest_versionsmoke test.uv run pytest src/backend/tests/unit/components/bundles/azure/— 7 passed, 4 skipped.uv run pytest src/backend/tests/unit/components/bundles/ src/backend/tests/unit/base/models/ src/backend/tests/unit/test_load_components.py— 355 passed, 94 skipped, 3 pre-existing failures inaltkunrelated to this change (verified they fail identically on unmodifiedmain, environment/API-key related).uv run --package lfx pytest src/lfx/tests/unit/base/models/— 329 passed (covers the shared unified-model-providers registry that the field-name collision above would have broken).ruff check/ruff format --checkon both changed files — clean.Summary by CodeRabbit
New Features
Bug Fixes
Tests