refactor: Update AgentComponent to utilize MODEL_OPTIONS_METADATA from constants#9969
Conversation
- Introduced `MODEL_PROVIDERS_LIST` containing key model providers: "Anthropic", "Google Generative AI", and "OpenAI". - Added `MODEL_OPTIONS_METADATA` to filter and compile metadata for the specified model providers, improving the robustness of model selection in the application. These changes enhance the flexibility and clarity of model provider options available to users.
…m constants - Removed the hardcoded `MODEL_PROVIDERS_LIST` and replaced it with `MODEL_OPTIONS_METADATA` for improved flexibility in options metadata handling. - Enhanced the `options_metadata` in the AgentComponent to streamline the integration of model provider options, ensuring better alignment with the existing metadata structure. These changes contribute to a more robust and maintainable codebase, enhancing the user experience when selecting model providers.
WalkthroughRefactors multiple starter project AgentComponent templates to use new provider metadata constants (MODEL_PROVIDERS_LIST, MODEL_OPTIONS_METADATA, MODEL_PROVIDERS_DICT), updates inputs/options metadata, and adjusts memory input exposure in some templates. Adds MODEL_PROVIDERS_LIST and MODEL_OPTIONS_METADATA to model_input_constants and updates the core Agent to consume them, removing a local constant. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as Starter Project UI
participant Agent as AgentComponent
participant C as model_input_constants
participant LLM as Provider Adapter
User->>UI: Select Model Provider
UI->>Agent: Build/Update config (provider, options)
Agent->>C: Fetch MODEL_PROVIDERS_LIST / MODEL_OPTIONS_METADATA
C-->>Agent: Provider list + options metadata
Agent->>Agent: Filter/add provider-specific fields
Agent->>LLM: Initialize provider with config
LLM-->>Agent: Ready
Agent-->>UI: Inputs/metadata updated
Note right of Agent: Some templates omit memory inputs in public config
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate 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. Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (45.99%) is below the target coverage (55.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #9969 +/- ##
==========================================
- Coverage 23.45% 23.42% -0.04%
==========================================
Files 1090 1090
Lines 39837 39837
Branches 5530 5530
==========================================
- Hits 9345 9330 -15
- Misses 30321 30336 +15
Partials 171 171
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (6)
src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (1)
2715-2730: Fix connect_other_models to remove inactive-provider fields (e.g. Groq)MODEL_PROVIDERS_DICT contains inactive providers (Groq has is_active=False) but ALL_PROVIDER_FIELDS is built from ACTIVE_MODEL_PROVIDERS_DICT; the connect_other_models branch deletes ONLY ALL_PROVIDER_FIELDS, so fields from inactive providers can remain in build_config.
Location: src/lfx/src/lfx/components/agents/agent.py -> update_build_config; reference: src/lfx/src/lfx/base/models/model_input_constants.py (MODEL_PROVIDERS_DICT / ACTIVE_MODEL_PROVIDERS_DICT / ALL_PROVIDER_FIELDS).
Fix: have connect_other_models delete fields aggregated from MODEL_PROVIDERS_DICT (all providers) or ensure ALL_PROVIDER_FIELDS includes inactive providers before deletion.
src/backend/base/langflow/initial_setup/starter_projects/Search agent.json (1)
1002-1016: Fix the provider icon mismatch inoptions_metadata.
agent_llm.optionsnow lists onlyAnthropic,Google Generative AI, andOpenAI, butoptions_metadatastill contains entries for five icons—includingGroq. Because the frontend aligns icons by index, OpenAI currently renders with Groq’s icon, which is a user‑facing regression. Trim the metadata list so it contains the three active providers (plus the trailing brain icon if you still need it for “connect other models”).- "options_metadata": [ - { - "icon": "Anthropic" - }, - { - "icon": "GoogleGenerativeAI" - }, - { - "icon": "Groq" - }, - { - "icon": "OpenAI" - }, - { - "icon": "brain" - } - ], + "options_metadata": [ + { + "icon": "Anthropic" + }, + { + "icon": "GoogleGenerativeAI" + }, + { + "icon": "OpenAI" + }, + { + "icon": "brain" + } + ],src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (1)
2039-2054: Alignoptions_metadatawith the updated provider list.Same issue here:
agent_llm.optionshas three providers, butoptions_metadatastill includes Groq, so icons slide out of sync and OpenAI renders with the wrong logo. Update the metadata array to mirror the provider list (keeping the extra brain icon only if needed for external options).- "options_metadata": [ - { - "icon": "Anthropic" - }, - { - "icon": "GoogleGenerativeAI" - }, - { - "icon": "Groq" - }, - { - "icon": "OpenAI" - }, - { - "icon": "brain" - } - ], + "options_metadata": [ + { + "icon": "Anthropic" + }, + { + "icon": "GoogleGenerativeAI" + }, + { + "icon": "OpenAI" + }, + { + "icon": "brain" + } + ],src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json (1)
854-878: Correct the provider icon metadata
MODEL_PROVIDERS_LISTnow surfaces only Anthropic / Google Generative AI / OpenAI, but the serializedoptions_metadatastill carries five entries (including Groq). The frontend pairsoptionsandoptions_metadataby index, so OpenAI currently renders with the Groq icon. Please trim the array to the three active providers (or rebuild it fromMODEL_OPTIONS_METADATA) so the icons line up again.- "options_metadata": [ - { - "icon": "Anthropic" - }, - { - "icon": "GoogleGenerativeAI" - }, - { - "icon": "Groq" - }, - { - "icon": "OpenAI" - }, - { - "icon": "brain" - } - ], + "options_metadata": [ + { + "icon": "Anthropic" + }, + { + "icon": "GoogleGenerativeAI" + }, + { + "icon": "OpenAI" + } + ],src/backend/base/langflow/initial_setup/starter_projects/Invoice Summarizer.json (1)
1196-1225: Trim stale provider icons fromoptions_metadataSame issue here: the dropdown now offers three providers, but the serialized
options_metadatastill ships five entries (including Groq). That indexing mismatch makes OpenAI render with the Groq icon in the starter flow. Please align the metadata with the active provider list (or regenerate it fromMODEL_OPTIONS_METADATA).- "options_metadata": [ - { - "icon": "Anthropic" - }, - { - "icon": "GoogleGenerativeAI" - }, - { - "icon": "Groq" - }, - { - "icon": "OpenAI" - }, - { - "icon": "brain" - } - ], + "options_metadata": [ + { + "icon": "Anthropic" + }, + { + "icon": "GoogleGenerativeAI" + }, + { + "icon": "OpenAI" + } + ],src/backend/base/langflow/initial_setup/starter_projects/Nvidia Remix.json (1)
861-894: Fix the dropdown options/icons to match the centralized metadata.
optionsstill hardcodes["Anthropic", "Google Generative AI", "OpenAI"], whileoptions_metadatanow expands the globalMODEL_OPTIONS_METADATA(Amazon, Anthropic, Azure, …, SambaNova) plus the brain extra. That mismatch means the starter project still surfaces only three providers and the icon order no longer lines up with the rendered entries—the very regression this refactor was meant to prevent. Please replace the hardcodedoptionsarray with the centralized list (or regenerate this node from the updated component) so both arrays remain in lockstep withMODEL_PROVIDERS_LIST/MODEL_OPTIONS_METADATA.
🧹 Nitpick comments (1)
src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json (1)
1048-1068: Consolidate the fallback icon into the constants.Now that the dropdown metadata is sourced from
MODEL_OPTIONS_METADATA, the only inline special-case left is the{"icon": "brain"}entry. Keeping it coupled to the component means any future reordering or length change in the constant can misalign icons vs. providers. Please either fold this fallback icon into the constant (or a helper) or derive the list dynamically so the component doesn’t have to maintain an extra element by hand.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Invoice Summarizer.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Market Research.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Nvidia Remix.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Pokédex Agent.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Search agent.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json(2 hunks)src/lfx/src/lfx/base/models/model_input_constants.py(1 hunks)src/lfx/src/lfx/components/agents/agent.py(2 hunks)
👮 Files not reviewed due to content moderation or server errors (6)
- src/lfx/src/lfx/base/models/model_input_constants.py
- src/backend/base/langflow/initial_setup/starter_projects/Pokédex Agent.json
- src/lfx/src/lfx/components/agents/agent.py
- src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json
- src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json
- src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (49)
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 40/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 38/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 35/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 36/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 31/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 39/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 30/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 33/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 37/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 34/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 25/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 29/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 32/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 24/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 28/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 27/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 26/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 13/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 21/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 15/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 19/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 23/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 17/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 18/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 22/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 20/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 16/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 14/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 11/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 12/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/40
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: test-starter-projects
🔇 Additional comments (7)
src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (3)
2026-2026: Confirm the code hash update reflects actual changes.The code hash on line 2026 is updated to "8671861b6aef", which should correspond to the changes made to import and use the new constants. This looks correct for tracking component modifications.
2250-2262: Enhanced provider options configuration looks robust.The code shows proper integration of the constants:
- Uses MODEL_PROVIDERS_LIST for dropdown options
- Includes MODEL_OPTIONS_METADATA for enhanced provider metadata with icons
- Maintains backward compatibility with "brain" icon fallback
- Implements external options for "Connect other models" functionality
This addresses the PR goal of improving flexibility in model provider selection.
2190-2190: Approve model_input_constants imports
All imported constants (MODEL_PROVIDERS_LIST, MODEL_OPTIONS_METADATA, MODEL_PROVIDERS_DICT, MODEL_DYNAMIC_UPDATE_FIELDS, ALL_PROVIDER_FIELDS, MODELS_METADATA) are defined and structured as expected inlfx/base/models/model_input_constants.py.src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json (2)
1245-1245: Code hash updated to reflect AgentComponent refactoring.The code hash has been updated from
d61b1f3d692ato8671861b6aef, indicating that the underlying AgentComponent code has been modified to use the new centralized provider constants.
1406-1426: Improved provider metadata structure with centralized constants.The options metadata now uses the centralized
MODEL_OPTIONS_METADATAand includes additional metadata entries (lines 1344-1360) beyond just the basic options. This provides better icon support and metadata consistency across components.src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (2)
1308-1308: Consistent code hash update across starter projects.The AgentComponent code hash has been updated to
8671861b6aef, maintaining consistency with the other starter projects in this PR that use the same refactored AgentComponent.
1472-1472: Constants are correctly defined and imported. MODEL_PROVIDERS_LIST, MODEL_OPTIONS_METADATA, and MODEL_PROVIDERS_DICT are declared insrc/lfx/base/models/model_input_constants.pyand imported insrc/lfx/components/agents/agent.py; unit tests reference them, confirming functionality.



Having the list in the AgentComponent caused outdated components to check for models that could have been made inactive. Since
Groqwas made inactive in1.6.0flows built in 1.5.0 broke.MODEL_PROVIDERS_LISTand replaced it withMODEL_OPTIONS_METADATAfor improved flexibility in options metadata handling.options_metadatain the AgentComponent to streamline the integration of model provider options, ensuring better alignment with the existing metadata structure.Summary by CodeRabbit
New Features
Improvements