Skip to content

refactor: Update AgentComponent to utilize MODEL_OPTIONS_METADATA from constants#9969

Merged
ogabrielluiz merged 3 commits into
mainfrom
move-providers-list-off-agent
Sep 25, 2025
Merged

refactor: Update AgentComponent to utilize MODEL_OPTIONS_METADATA from constants#9969
ogabrielluiz merged 3 commits into
mainfrom
move-providers-list-off-agent

Conversation

@ogabrielluiz
Copy link
Copy Markdown
Contributor

@ogabrielluiz ogabrielluiz commented Sep 24, 2025

Having the list in the AgentComponent caused outdated components to check for models that could have been made inactive. Since Groq was made inactive in 1.6.0 flows built in 1.5.0 broke.

  • 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.

Summary by CodeRabbit

  • New Features

    • Unified Model Provider selection across starter projects with a standardized provider list (e.g., Anthropic, Google Generative AI, OpenAI) and richer icons/metadata.
    • Streamlined option to connect other models directly from Agent setup.
  • Improvements

    • More consistent Agent configuration with simplified dropdowns and defaults.
    • Enhanced provider-specific input handling and validation for smoother setup.
    • Memory-related inputs are hidden in certain templates to reduce clutter and confusion.

- 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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 24, 2025

Walkthrough

Refactors 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

Cohort / File(s) Summary
Core model constants
src/lfx/src/lfx/base/models/model_input_constants.py
Adds MODEL_PROVIDERS_LIST and MODEL_OPTIONS_METADATA derived from MODELS_METADATA; no changes to existing logic.
Core Agent component
src/lfx/src/lfx/components/agents/agent.py
Switches provider options construction to use MODEL_OPTIONS_METADATA; imports MODEL_PROVIDERS_DICT/…_LIST/…_METADATA; removes local MODEL_PROVIDERS_LIST constant.
Starter projects — provider metadata refactor
src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json, .../Invoice Summarizer.json, .../Market Research.json, .../Nvidia Remix.json, .../Pokédex Agent.json, .../Price Deal Finder.json, .../Research Agent.json, .../SaaS Pricing.json, .../Search agent.json, .../Simple Agent.json, .../Social Media Agent.json, .../Youtube Analysis.json
Updates AgentComponent imports and inputs to use MODEL_PROVIDERS_LIST and MODEL_OPTIONS_METADATA (replacing prior MODELS_METADATA-only patterns); code_hash updated where present; some add/remove ALL_PROVIDER_FIELDS/MODEL_DYNAMIC_UPDATE_FIELDS per file.
Starter projects — memory inputs exposure
.../News Aggregator.json, .../Instagram Copywriter.json, .../Youtube Analysis.json
Adjusts inputs lists to omit or alter memory_inputs exposure; introduces filtered provider-specific inputs (e.g., openai_inputs_filtered) and external_options wiring.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

lgtm, size:M

Suggested reviewers

  • edwinjosechittilappilly
  • lucaseduoli
  • mfortman11

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly indicates that the AgentComponent is being refactored to use MODEL_OPTIONS_METADATA from constants, directly reflecting the main change in the PR. It is concise and specific, avoiding unnecessary detail or ambiguity.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch move-providers-list-off-agent

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 refactor Maintenance tasks and housekeeping label Sep 24, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Sep 24, 2025
@sonarqubecloud
Copy link
Copy Markdown

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Sep 24, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 23.42%. Comparing base (dd4cace) to head (edca9c1).
⚠️ Report is 4 commits behind head on main.

❌ 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

Impacted file tree graph

@@            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              
Flag Coverage Δ
backend 45.99% <ø> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 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 refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Sep 24, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in options_metadata.

agent_llm.options now lists only Anthropic, Google Generative AI, and OpenAI, but options_metadata still contains entries for five icons—including Groq. 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: Align options_metadata with the updated provider list.

Same issue here: agent_llm.options has three providers, but options_metadata still 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_LIST now surfaces only Anthropic / Google Generative AI / OpenAI, but the serialized options_metadata still carries five entries (including Groq). The frontend pairs options and options_metadata by index, so OpenAI currently renders with the Groq icon. Please trim the array to the three active providers (or rebuild it from MODEL_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 from options_metadata

Same issue here: the dropdown now offers three providers, but the serialized options_metadata still 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 from MODEL_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.

options still hardcodes ["Anthropic", "Google Generative AI", "OpenAI"], while options_metadata now expands the global MODEL_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 hardcoded options array with the centralized list (or regenerate this node from the updated component) so both arrays remain in lockstep with MODEL_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

📥 Commits

Reviewing files that changed from the base of the PR and between dd4cace and edca9c1.

📒 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 in lfx/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 d61b1f3d692a to 8671861b6aef, 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_METADATA and 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 in src/lfx/base/models/model_input_constants.py and imported in src/lfx/components/agents/agent.py; unit tests reference them, confirming functionality.

@ogabrielluiz ogabrielluiz added this pull request to the merge queue Sep 24, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 24, 2025
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Sep 25, 2025
Merged via the queue into main with commit 386d24d Sep 25, 2025
78 of 79 checks passed
@ogabrielluiz ogabrielluiz deleted the move-providers-list-off-agent branch September 25, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor Maintenance tasks and housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants