Skip to content

fix(bundles): expose model name on the Azure OpenAI chat component - #14574

Open
andifilhohub wants to merge 1 commit into
langflow-ai:mainfrom
andifilhohub:fix/azure-openai-model-name
Open

fix(bundles): expose model name on the Azure OpenAI chat component#14574
andifilhohub wants to merge 1 commit into
langflow-ai:mainfrom
andifilhohub:fix/azure-openai-model-name

Conversation

@andifilhohub

@andifilhohub andifilhohub commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #9855.

AzureChatOpenAIComponent (the "Azure OpenAI" model component) only exposed Deployment Name, with no way to tell langchain_openai.AzureChatOpenAI which 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:

  • Accurate token/cost tracing (AzureChatOpenAI._get_ls_params / _create_chat_result fall back to the deployment name when model_name is None, which usually doesn't match a real model id).
  • langchain_openai's model-name-gated feature checks (e.g. the parallel_tool_calls support check keys off model_name == "gpt-4o", and reasoning-specific params for o-series/gpt-5 models).

Note: for plain Chat Completions routing, azure_deployment alone is already enough to reach the right deployment (the endpoint's base_url is 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

  • Added an optional, advanced model input to AzureChatOpenAIComponent, matching the field name already used by the sibling AzureOpenAIEmbeddingsComponent in the same file.
  • Passed it through as AzureChatOpenAI(model=self.model or None, ...).
  • When left blank, model=None is 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 (matching OpenAIModelComponent), but that collides with lfx/base/models/model_input_constants.py's shared "unified model providers" registry, which special-cases any input literally named model_name and expects a DropdownInput with .combobox support. Since AzureChatOpenAIComponent is already registered there (currently is_active: False), that name broke import of model_input_constants.py itself (and everything that imports it — altk, cuga, the agent component, etc.) with a pydantic ValidationError. Renaming the field to model avoids that collision entirely and still matches the sibling embeddings component's convention.

Test plan

  • Added src/backend/tests/unit/components/bundles/azure/test_azure_openai_component.py covering:
    • Input structure (the new field exists, is optional and advanced).
    • build_model() passes model= through to AzureChatOpenAI.
    • Omitting the field preserves prior behavior (model=None).
    • Exception handling is preserved.
    • The inherited test_latest_version smoke test.
  • Ran the full suite to confirm no regressions:
    • 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 in altk unrelated to this change (verified they fail identically on unmodified main, 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 --check on both changed files — clean.

Summary by CodeRabbit

  • New Features

    • Added an advanced model configuration option for Azure OpenAI connections.
    • The selected model is now applied when creating the chat model.
  • Bug Fixes

    • Improved handling of empty model settings and connection errors with clearer contextual messages.
  • Tests

    • Added coverage for default setup, input definitions, model configuration, argument forwarding, and error handling.

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
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f659a8a-eb66-41f3-a4fb-06b2d00f21ee

📥 Commits

Reviewing files that changed from the base of the PR and between 976ec78 and c6729d3.

📒 Files selected for processing (3)
  • src/backend/tests/unit/components/bundles/azure/__init__.py
  • src/backend/tests/unit/components/bundles/azure/test_azure_openai_component.py
  • src/bundles/lfx-bundles/src/lfx_bundles/azure/azure_openai.py

Walkthrough

The Azure OpenAI component now accepts an advanced model name, forwards it to AzureChatOpenAI, converts empty values to None, and includes unit tests for configuration and connection errors.

Changes

Azure OpenAI model configuration

Layer / File(s) Summary
Add model input and constructor forwarding
src/bundles/lfx-bundles/src/lfx_bundles/azure/azure_openai.py
The component adds an advanced model input and forwards its configured value to AzureChatOpenAI.
Validate model configuration and errors
src/backend/tests/unit/components/bundles/azure/*
Unit tests cover component metadata, input definitions, model forwarding, empty-model handling, and connection-error propagation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c6729

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)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: exposing the Azure OpenAI model name on the chat component.
Linked Issues check ✅ Passed The PR adds an optional model input and forwards it to AzureChatOpenAI, meeting issue #9855.
Out of Scope Changes check ✅ Passed The implementation and tests remain within the scope of issue #9855 and the stated PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Test Coverage For New Implementations ✅ Passed The PR adds a convention-compliant backend test file with schema, model forwarding, blank-model regression, and exception tests for the changed component.
Test Quality And Coverage ✅ Passed Pytest tests verify the new input's presence, optional/advanced flags, model forwarding, blank-value behavior, returned instance, and connection-error handling; inherited async smoke coverage also...
Test File Naming And Structure ✅ Passed The new backend file is named test_azure_openai_component.py, uses pytest fixtures and a test class, and covers setup, inputs, forwarding, empty-model behavior, and errors with descriptive names.
Excessive Mock Usage Warning ✅ Passed The new tests use three patches only for the external AzureChatOpenAI constructor; they exercise the real component and verify arguments, fallback behavior, and error handling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not able to use azure llm

1 participant