Skip to content

feat: Refactor and Unify the ModelInput Selector Across Components#12025

Merged
erichare merged 177 commits intorelease-1.9.0from
feat-unify-models++
Mar 19, 2026
Merged

feat: Refactor and Unify the ModelInput Selector Across Components#12025
erichare merged 177 commits intorelease-1.9.0from
feat-unify-models++

Conversation

@erichare
Copy link
Collaborator

@erichare erichare commented Mar 4, 2026

Summary

This PR unifies model-selection behavior across Langflow components by moving shared logic into unified_models and updating the affected components to use it.

It introduces shared helpers for:

  • refreshing/caching model options
  • showing and hiding provider-specific fields
  • pre-populating provider fields from stored variables
  • constructing embedding clients from the same model metadata used by the UI

It also migrates knowledge ingestion onto the unified embedding path and preserves backward compatibility for older agent configuration styles.

What Changed

  • Added get_embeddings() to unified_models to centralize embedding client construction.
  • Added handle_model_input_update() to centralize ModelInput update behavior.
  • Updated LanguageModelComponent, EmbeddingModelComponent, AgentComponent, ToolCallingAgentComponent, and other model-aware components to use the shared helper.
  • Updated knowledge ingestion to store full embedding model selection metadata and rebuild embedding clients from that metadata.
  • Restored KB creation support for ad hoc API keys during creation, not just globally configured credentials.
  • Preserved legacy AgentComponent behavior for agent_llm / model_name style inputs.
  • Refreshed related tests and generated assets/starter projects.

Why

Before this change, multiple components reimplemented similar logic for:

  • model option refresh
  • provider field visibility
  • provider-specific credential fields
  • embedding client instantiation

That duplication made behavior drift likely and increased maintenance cost. This PR consolidates that logic so model-aware components behave consistently and future provider changes can be made in one place.

User Impact

  • Model dropdowns behave more consistently across components.
  • Provider-specific fields such as WatsonX/Ollama settings are managed through shared logic.
  • Knowledge ingestion can reconstruct embedding clients from saved metadata instead of relying on older string-only metadata.
  • Creating a knowledge base still works when users provide an API key directly during setup.
  • Existing agent setups using legacy configuration patterns continue to work.

Adam-Aghili and others added 11 commits March 2, 2026 18:20
… (#11975)

* feat: add runtime port validation for Kubernetes service discovery

* test: add unit tests for runtime port validation in Settings

* fix: improve runtime port validation to handle exceptions and edge cases

Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
* feat: add documentation link to Guardrails component

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* feat: traces v0

v0 for traces includes:
- filters: status, token usage range and datatime
- accordian rows per trace

Could add:
- more filter options. Ecamples: session_id, trace_id and latency range

* fix: token range

* feat: create sidebar buttons for logs and trace

add sidebar buttons for logs and trace
remove lods canvas control

* fix: fix duplicate trace ID insertion

hopefully fix duplicate trace ID insertion on windows

* fix: update tests and alembic tables for uts

update tests and alembic tables for uts

* chore: add session_id

* chore: allo grouping by session_id and flow_id

* chore: update race input output

* chore: change run name to flow_name - flow_id
was flow_name - trace_id
now flow_name - flow_id

* facelift

* clean up and add testcases

* clean up and add testcases

* merge Alembic detected multiple heads

* [autofix.ci] apply automated fixes

* improve testcases

* remodel files

* chore: address gabriel simple changes

address gabriel simple changes in traces.py and native.py

* clean up and testcases

* chore: address OTel and PG status comments

#11689 (comment)
#11689 (comment)

* chore: OTel span naming convention

model name is now set using name = f"{operation} {model_name}" if model_name else operation

* add traces

* feat: use uv sources for CPU-only PyTorch (#11884)

* feat: use uv sources for CPU-only PyTorch

Configure [tool.uv.sources] with pytorch-cpu index to avoid ~6GB CUDA
dependencies in Docker images. This replaces hardcoded wheel URLs with
a cleaner index-based approach.

- Add pytorch-cpu index with explicit = true
- Add torch/torchvision to [tool.uv.sources]
- Add explicit torch/torchvision deps to trigger source override
- Regenerate lockfile without nvidia/cuda/triton packages
- Add required-environments for multi-platform support



* fix: update regex to only replace name in [project] section

The previous regex matched all lines starting with `name = "..."`,
which incorrectly renamed the UV index `pytorch-cpu` to `langflow-nightly`
during nightly builds. This caused `uv lock` to fail with:
"Package torch references an undeclared index: pytorch-cpu"

The new regex specifically targets the name field within the [project]
section only, avoiding unintended replacements in other sections like
[[tool.uv.index]].

* style: fix ruff quote style

* fix: remove required-environments to fix Python 3.13 macOS x86_64 CI

The required-environments setting was causing hard failures when packages
like torch didn't have wheels for specific platform/Python combinations.
Without this setting, uv resolves optimistically and handles missing wheels
gracefully at runtime instead of failing during resolution.



---------



* LE-270: Hydration and Console Log error (#11628)

* LE-270: add fix hydration issues

* LE-270: fix disable field on max token on language model

---------



* test: add wait for selector in mcp server tests (#11883)

* Add wait for selector in mcp server tests

* [autofix.ci] apply automated fixes

* Add more awit for selectors

* [autofix.ci] apply automated fixes

---------



* fix: reduce visual lag in frontend  (#11686)

* Reduce lag in frontend by batching react events and reducing minimval visual build time

* Cleanup

* [autofix.ci] apply automated fixes

* add tests and improve code read

* [autofix.ci] apply automated fixes

* Remove debug log

---------




* feat: lazy load imports for language model component (#11737)

* Lazy load imports for language model component

Ensures that only the necessary dependencies are required.
For example, if OpenAI provider is used, it will now only
import langchain_openai, rather than requiring langchain_anthropic,
langchain_ibm, etc.

* Add backwards-compat functions

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Add exception handling

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* comp index

* docs: azure default temperature (#11829)

* change-azure-openai-default-temperature-to-1.0

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* [autofix.ci] apply automated fixes

---------



* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* fix unit test?

* add no-group dev to docker builds

* [autofix.ci] apply automated fixes

---------





* feat: generate requirements.txt from dependencies  (#11810)

* Base script to generate requirements

Dymanically picks dependency for LanguageM Comp.
Requires separate change to remove eager loading.

* Lazy load imports for language model component

Ensures that only the necessary dependencies are required.
For example, if OpenAI provider is used, it will now only
import langchain_openai, rather than requiring langchain_anthropic,
langchain_ibm, etc.

* Add backwards-compat functions

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Add exception handling

* Add CLI command to create reqs

* correctly exclude langchain imports

* Add versions to reqs

* dynamically resolve provider imports for language model comp

* Lazy load imports for reqs, some ruff fixes

* Add dynamic resolves for embedding model comp

* Add install hints

* Add missing provider tests; add warnings in reqs script

* Add a few warnings and fix install hint

* update comments add logging

* Package hints, warnings, comments, tests

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* Add alias for watsonx

* Fix anthropic for basic prompt, azure mapping

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* ruff

* [autofix.ci] apply automated fixes

* test formatting

* ruff

* [autofix.ci] apply automated fixes

---------



* fix: add handle to file input to be able to receive text (#11825)

* changed base file and file components to support muitiple files and files from messages

* update component index

* update input file component to clear value and show placeholder

* updated starter projects

* [autofix.ci] apply automated fixes

* updated base file, file and video file to share robust file verification method

* updated component index

* updated templates

* fix whitespaces

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* add file upload test for files fed through the handle

* [autofix.ci] apply automated fixes

* added tests and fixed things pointed out by revies

* update component index

* fixed test

* ruff fixes

* Update component_index.json

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* updated component index

* updated component index

* removed handle from file input

* Added functionality to use multiple files on the File Path, and to allow files on the langflow file system.

* [autofix.ci] apply automated fixes

* fixed lfx test

* build component index

---------





* docs: Add AGENTS.md development guide (#11922)

* add AGENTS.md rule to project

* change to agents-example

* remove agents.md

* add example description

* chore: address cris I1 comment

address cris I1 comment

* chore: address cris I5

address cris I5

* chore: address cris I6

address cris I6

* chore: address cris R7

address cris R7

* fix testcase

* chore: address cris R2

address cris R2

* restructure insight page into sidenav

* added header and total run node

* restructing branch

* chore: address gab otel model changes

address gab otel model changes will need no migration tables

* chore: update alembic migration tables

update alembic migration tables after model changes

* add empty state for gropu sessions

* remove invalid mock

* test: update and add backend tests

update and add backend tests

* chore: address backend code rabbit comments

address backend code rabbit comments

* chore: address code rabbit frontend comments

address code rabbit frontend comments

* chore: test_native_tracer minor fix address c1

test_native_tracer minor fix address c1

* chore: address C2 + C3

address C2 + C3

* chore: address H1-H5

address H1-H5

* test: update test_native_tracer

update test_native_tracer

* fixes

* chore: address M2

address m2

* chore: address M1

address M1

* dry changes, factorization

* chore: fix 422 spam and clean comments

fix 422 spam and clean comments

* chore: address M12

address M12

* chore: address M3
 address M3

* chore: address M4

address M4

* chore: address M5

address M5

* chore: clean up for M7, M9, M11

clean up for M7, M9, M11

* chore: address L2,L4,L5,L6 + any test

address L2,L4,L5 and L6 + any test

* chore: alembic + comment clean up

alembic + comment clean up

* chore: remove depricated test_traces file

remove depricated test_traces file. test have all been moved to test_traces_api.py

* fix datetime

* chore: fix test_trace_api ge=0 is allowed now

fix test_trace_api ge=0 is allowed now

* chore: remove unused traces cost flow

remove unused traces cost flow

* fix traces test

* fix traces test

* fix traces test

* fix traces test

* fix traces test

* chore: address gabriels otel coment

address gabriels otel coment latest

---------

Co-authored-by: Olayinka Adelakun <[email protected]>
Co-authored-by: Olayinka Adelakun <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Ram Gopal Srikar Katakam <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: olayinkaadelakun <[email protected]>
Co-authored-by: Jordan Frazier <[email protected]>
Co-authored-by: cristhianzl <[email protected]>
Co-authored-by: Hamza Rashid <[email protected]>
Co-authored-by: Mendon Kissling <[email protected]>
Co-authored-by: Lucas Oliveira <[email protected]>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: Himavarsha <[email protected]>
#11982)

fix(test): Fix superuser timeout test errors by replacing heavy client fixture                                                    (#11972)

* fix super user timeout test error

* fix fixture db test

* remove canary test

* [autofix.ci] apply automated fixes

* flaky test

---------

Co-authored-by: Cristhian Zanforlin Lousa <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…ics module (#11974)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…2002)

* fix: add ondelete=CASCADE to TraceBase.flow_id to match migration

The migration file creates the trace table's flow_id foreign key with
ondelete="CASCADE", but the model was missing this parameter. This
mismatch caused the migration validator to block startup.

Co-Authored-By: Claude Opus 4.5 <[email protected]>

* fix: add defensive migration to ensure trace.flow_id has CASCADE

Adds a migration that ensures the trace.flow_id foreign key has
ondelete=CASCADE. While the original migration already creates it
with CASCADE, this provides a safety net for any databases that may
have gotten into an inconsistent state.

* fix: dynamically find FK constraint name in migration

The original migration did not name the FK constraint, so it gets an
auto-generated name that varies by database. This fix queries the
database to find the actual constraint name before dropping it.

---------

Co-authored-by: Claude Opus 4.5 <[email protected]>
…mprove button functionality (#12000)

* fix: Update ButtonSendWrapper to handle building state and improve button functionality

* fix(frontend): rename stop button title to avoid Playwright selector conflict

The "Stop building" title caused getByRole('button', { name: 'Stop' })
to match two elements, breaking Playwright tests in shards 19, 20, 22, 25.

Renamed to "Cancel" to avoid the collision with the no-input stop button.
pydantic fail because output is list, instead of a dict

Co-authored-by: Olayinka Adelakun <[email protected]>
* Update guardrails.py

Changing the heuristic threshold icons.

The field was using the default icons. I added icons related to the security theme.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Viktor Avelino <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 47c8cda3-d4ac-43aa-9a63-6604afa9f219

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The PR refactors LanguageModelComponent, StructuredOutputComponent, and AgentComponent across 24 starter project JSON files, replacing in-method update_build_config logic with centralized delegation to handle_model_input_update. This consolidates configuration updates by removing bespoke provider-field handling and unifying option processing.

Changes

Cohort / File(s) Summary
LanguageModelComponent Update Refactoring
src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json, Basic Prompting.json, Blog Writer.json, Custom Component Generator.json, Document Q&A.json, Meeting Summary.json, Memory Chatbot.json, Research Agent.json, Research Translation Loop.json, SEO Keyword Generator.json, Text Sentiment Analysis.json, Twitter Thread Generator.json, Vector Store RAG.json
Removed in-method provider-field visibility logic and imports (apply_provider_variable_config_to_build_config, get_language_model_options, update_model_options_in_build_config). Replaced update_build_config implementation to delegate to handle_model_input_update(self, build_config, field_value, field_name). Method signature unchanged; control flow simplified and centralized.
StructuredOutputComponent Update Refactoring
src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json, Hybrid Search RAG.json, Image Sentiment Analysis.json
Updated imports to use handle_model_input_update instead of update_model_options_in_build_config and get_language_model_options. Replaced update_build_config implementation with single delegation call to handle_model_input_update, removing inline option caching and provider-specific field toggling.
AgentComponent Update Refactoring
src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json, Invoice Summarizer.json, Market Research.json, News Aggregator.json, Nvidia Remix.json, Pokédex Agent.json, Portfolio Website Code Generator.json, Price Deal Finder.json, SaaS Pricing.json, Search agent.json, Simple Agent.json, Social Media Agent.json
Replaced update_model_options_in_build_config with handle_model_input_update in update_build_config method. Several files also removed memory_inputs from AgentComponent public inputs. Updated code_hash metadata to reflect new implementation. Internal model option caching and field visibility now handled by centralized updater.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

refactor

Suggested reviewers

  • edwinjosechittilappilly

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error PR modifies 20+ starter projects and multiple core components (base_component.py, csv_agent.py, openai_tools.py) with new centralized model handling functions, but no corresponding unit or integration test files were found. Add test files for new functions (handle_model_input_update, get_embeddings) and integration tests verifying refactored components correctly delegate to centralized handlers.
Test Quality And Coverage ⚠️ Warning No unit tests found for new handle_model_input_update and get_embeddings functions despite significant refactoring of model configuration logic across multiple components. Add comprehensive pytest-based unit tests for both functions covering normal cases, error handling, provider-specific field visibility, option caching, and component integration.
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Test File Naming And Structure ✅ Passed PR contains only JSON starter project file changes; no test files were modified or added.
Excessive Mock Usage Warning ✅ Passed The PR demonstrates appropriate and well-designed mock usage rather than excessive mocking. Tests include real behavior verification and strategic mocking of external dependencies only.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: refactoring and unifying model input handling across components through centralized logic.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-unify-models++
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@github-actions github-actions bot added the enhancement New feature or request label Mar 4, 2026
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 24%
24.38% (8698/35673) 17.21% (4831/28055) 17.06% (1275/7472)

Unit Test Results

Tests Skipped Failures Errors Time
2783 0 💤 0 ❌ 0 🔥 45.596s ⏱️

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.26%. Comparing base (7d4ffbc) to head (4071134).
⚠️ Report is 2 commits behind head on release-1.9.0.

Files with missing lines Patch % Lines
...base/langflow/agentic/services/flow_preparation.py 50.00% 4 Missing ⚠️
src/backend/base/langflow/api/utils/kb_helpers.py 0.00% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (44.66%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           release-1.9.0   #12025      +/-   ##
=================================================
+ Coverage          38.23%   38.26%   +0.02%     
=================================================
  Files               1647     1652       +5     
  Lines              82369    82457      +88     
  Branches           12223    12239      +16     
=================================================
+ Hits               31494    31551      +57     
- Misses             49092    49111      +19     
- Partials            1783     1795      +12     
Flag Coverage Δ
backend 54.72% <44.44%> (-0.03%) ⬇️
frontend 21.76% <ø> (+<0.01%) ⬆️
lfx 44.66% <ø> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nd/src/components/core/dropdownComponent/index.tsx 0.00% <ø> (ø)
...Component/components/modelInputComponent/index.tsx 67.88% <ø> (-0.24%) ⬇️
src/lfx/src/lfx/base/datastax/astradb_base.py 1.61% <ø> (ø)
.../lfx/base/models/google_generative_ai_constants.py 100.00% <ø> (ø)
...src/lfx/base/models/unified_models/build_config.py 27.27% <ø> (ø)
...c/lfx/base/models/unified_models/class_registry.py 31.25% <ø> (ø)
.../src/lfx/base/models/unified_models/credentials.py 9.25% <ø> (ø)
...rc/lfx/base/models/unified_models/instantiation.py 25.71% <ø> (ø)
...rc/lfx/base/models/unified_models/model_catalog.py 63.95% <ø> (ø)
...lfx/base/models/unified_models/provider_queries.py 68.00% <ø> (ø)
... and 3 more

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
@erichare erichare requested a review from dkaushik94 March 4, 2026 15:53
@erichare erichare changed the base branch from release-1.8.0 to main March 4, 2026 15:54
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
@github-actions github-actions bot removed the enhancement New feature or request label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.