Skip to content

Added Celebras LLM Provider into Agent and LanguageTool Tab#9106

Open
MeetSolanki530 wants to merge 2 commits into
langflow-ai:mainfrom
MeetSolanki530:main
Open

Added Celebras LLM Provider into Agent and LanguageTool Tab#9106
MeetSolanki530 wants to merge 2 commits into
langflow-ai:mainfrom
MeetSolanki530:main

Conversation

@MeetSolanki530
Copy link
Copy Markdown

@MeetSolanki530 MeetSolanki530 commented Jul 18, 2025

Added Celebras Cloud LLM Provider in langflow

https://www.cerebras.ai/

Screenshot 2025-07-18 174038 Screenshot 2025-07-18 174046 Screenshot 2025-07-18 174054

Summary by CodeRabbit

  • New Features

    • Added support for the Cerebras language model provider across the application, including model selection, configuration, and agent components.
    • Enhanced starter project templates to include Cerebras as a selectable model provider.
    • Introduced detailed Cerebras model metadata and configuration options.
    • Added version information utilities to display package version and pre-release status.
  • Improvements

    • Improved error handling and progress notification support for project and resource management endpoints.
    • Refined configuration endpoints to include feature flags and streamlined settings serialization.
  • Refactor

    • Simplified internal session and settings management for database operations.
    • Updated and clarified custom component update and configuration logic.
  • Chores

    • Added and updated documentation files and package initializers.
    • Improved code consistency and removed unused or redundant code.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 18, 2025

Walkthrough

This set of changes introduces support for the "🧠 Cerebras" language model provider throughout the backend, including new constants, components, and integration in both the LanguageModelComponent and AgentComponent. It also refactors MCP server logic, modifies configuration and schema handling, updates flow execution utilities, and removes obsolete code and settings.

Changes

File(s) Change Summary
src/backend/base/langflow/components/cerebras/* Introduced new Cerebras model component, initialization, and metadata constants for Cerebras models.
src/backend/base/langflow/base/models/cerebras_constants.py Added Cerebras model metadata, chat/reasoning model lists, and backward compatibility alias.
src/backend/base/langflow/base/models/model_input_constants.py Added Cerebras provider support, including lazy import and input field extraction.
src/backend/base/langflow/components/agents/agent.py
src/backend/base/langflow/initial_setup/starter_projects/*
Added "🧠 Cerebras" to model provider lists and dropdowns in AgentComponent and starter project configurations.
src/backend/base/langflow/components/models/language_model.py Integrated Cerebras provider into LanguageModelComponent, including build logic and config updates.
src/backend/base/langflow/api/v1/endpoints.py
src/backend/base/langflow/api/v1/schemas.py
src/backend/base/langflow/custom/utils.py
Removed code field augmentation logic, refactored config endpoint to return combined feature flags and settings, and removed obsolete build config helper.
src/backend/base/langflow/api/v1/mcp.py
src/backend/base/langflow/api/v1/mcp_projects.py
Refactored MCP server and project-scoped handlers for resource/tool listing, tool calling, and error handling; added progress notification support and direct DB/storage integration.
src/backend/base/langflow/load/load.py Added stream parameter to arun_flow_from_json for dynamic streaming control.
src/backend/base/langflow/services/database/service.py
src/backend/base/langflow/services/settings/base.py
Removed noop database setting and logic; simplified session management.
src/backend/base/langflow/services/utils.py Condensed database user retrieval logic in utility functions.
src/backend/base/langflow/version/* Added version package and utility functions for retrieving and checking package version.
src/backend/base/langflow/.gitignore Added .gitignore to ignore langflow.db in this directory.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AgentComponent
    participant LanguageModelComponent
    participant CerebrasModelComponent
    participant ChatCerebras

    User->>AgentComponent: Selects "🧠 Cerebras" as provider
    AgentComponent->>LanguageModelComponent: Passes provider selection
    LanguageModelComponent->>CerebrasModelComponent: Delegates model building
    CerebrasModelComponent->>ChatCerebras: Instantiates with config
    ChatCerebras-->>CerebrasModelComponent: Returns model instance
    CerebrasModelComponent-->>LanguageModelComponent: Returns model
    LanguageModelComponent-->>AgentComponent: Returns model
    AgentComponent-->>User: Provides Cerebras-powered agent
Loading

Possibly related PRs

Suggested labels

enhancement, size:L, lgtm

Suggested reviewers

  • mendonk
  • ogabrielluiz
  • jordanrfrazier
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@MeetSolanki530
Copy link
Copy Markdown
Author

Added Celebras Cloud LLM Provider in langflow

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: 15

🔭 Outside diff range comments (39)
src/backend/base/langflow/initial_setup/starter_projects/Pokédex Agent.json (1)

1347-1359: agent_llm dropdown is out-of-sync with the runtime provider list

The runtime code adds "🧠 Cerebras" to MODEL_PROVIDERS_LIST, yet the static dropdown options/metadata here were not updated.
Result: the UI never shows the new provider, and self.agent_llm can never become "🧠 Cerebras" — making the whole integration unreachable.

-                "options": [
-                  "Anthropic",
-                  "Google Generative AI",
-                  "Groq",
-                  "OpenAI",
-                  "Custom"
-                ],
+                "options": [
+                  "Anthropic",
+                  "Google Generative AI",
+                  "Groq",
+                  "OpenAI",
+                  "🧠 Cerebras",
+                  "Custom"
+                ],
...
-                  {
-                    "icon": "OpenAI"
-                  },
-                  {
-                    "icon": "brain"
-                  }
+                  { "icon": "OpenAI" },
+                  { "icon": "Cerebras" },   // or your chosen icon key
+                  { "icon": "brain" }       // Custom

Please update both options and options_metadata to include the new provider.
Without this, the Cerebras work you wired in the backend remains inaccessible.

src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (2)

1510-1513: Provider key contains emoji – will break look-ups in MODEL_PROVIDERS_DICT.

MODEL_PROVIDERS_LIST is now

["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"]

MODEL_PROVIDERS_DICT.get(self.agent_llm) later expects an exact-match key.
Unless you have added a key containing the emoji to MODEL_PROVIDERS_DICT, any selection of “🧠 Cerebras” will return None, raising Invalid model provider.

Fix by using a plain provider identifier (keep the emoji, if desired, only for the UI):

-MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"]
+MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "Cerebras"]

and, if you want the emoji in the dropdown:

options_metadata=[*MODELS_METADATA[key] for key in MODEL_PROVIDERS_LIST] + [{"icon": "brain", "label": "🧠 Cerebras"}]

Make sure the key in MODEL_PROVIDERS_DICT is exactly "Cerebras".


1446-1455: agent_llm dropdown rendered list is now out-of-sync with MODEL_PROVIDERS_LIST.

The JSON still hard-codes:

"options": [
  "Anthropic",
  "Google Generative AI",
  "Groq",
  "OpenAI",
  "Custom"
],

so the new provider never shows up in the UI.

Synchronise the serialized template with the python constant, e.g.:

-  "Groq",
-  "OpenAI",
-  "Custom"
+  "Groq",
+  "OpenAI",
+  "Cerebras",
+  "Custom"

and add a corresponding entry in options_metadata for the Cerebras icon.

src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json (1)

1025-1031: Remove emoji from “Cerebras” provider key across the codebase
The lookup in MODEL_PROVIDERS_DICT uses exact string keys. Having “🧠 Cerebras” as the key breaks lookups and will throw Invalid model provider at runtime. Change all occurrences of "🧠 Cerebras" to "Cerebras" where it’s used as a provider key or dropdown option, and keep the brain icon in options_metadata only.

Files/locations to update:

  • src/backend/base/langflow/initial_setup/starter_projects/SaaS Pricing.json (MODEL_PROVIDERS_LIST)
  • src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json (MODEL_PROVIDERS_LIST)
  • src/backend/base/langflow/components/agents/agent.py (MODEL_PROVIDERS_LIST)
  • src/backend/base/langflow/components/models/language_model.py
    • options list
    if provider == … and elif field_value == … checks
  • src/backend/base/langflow/base/models/model_input_constants.py (MODEL_PROVIDERS_DICT key)
  • src/backend/base/langflow/base/models/cerebras_constants.py (create_model_metadata calls)

Example diff (SaaS Pricing starter):

-MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI","🧠 Cerebras"]
+MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "Cerebras"]

Also update:

  • MODEL_PROVIDERS_DICT keys:
    "🧠 Cerebras""Cerebras"
  • All comparisons:
    if provider == "🧠 Cerebras"if provider == "Cerebras"
  • Dropdown options:
    "🧠 Cerebras""Cerebras"

Keep the brain emoji only in the corresponding icon fields under options_metadata.

src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json (1)

1775-1785: Include “🧠 Cerebras” in the static dropdown and fix spacing

The backend’s MODEL_PROVIDERS_LIST now includes "🧠 Cerebras", but the static JSON dropdown in the starter project is missing it. Please update the following:

• File:
src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json
• Python style fix: add a space after the comma in the provider list.

Suggested diffs:

# 1. In src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json
  "options": [
      "Anthropic",
      "Google Generative AI",
      "Groq",
      "OpenAI",
+     "🧠 Cerebras",
      "Custom"
  ],
  "options_metadata": [
      { "icon": "anthropic" },
      { "icon": "google-generative-ai" },
      { "icon": "groq" },
      { "icon": "openai" },
+     { "icon": "<cerebras-icon-name>" },  // replace with dedicated icon if available
      { "icon": "brain" }
  ],

# 2. In the Python component (ensure consistent spacing)
- MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI","🧠 Cerebras"]
+ MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"]
src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json (1)

1363-1395: Agent dropdown is out-of-sync with backend – add “🧠 Cerebras” (and icon metadata).

MODEL_PROVIDERS_LIST in the embedded AgentComponent code now contains "🧠 Cerebras", yet the template’s agent_llm DropdownInput.options still exposes only the original four providers plus "Custom".
Developers won’t be able to pick the new provider from the UI, and attempts to load a flow that already references "🧠 Cerebras" will break validation.

-            "options": [
-              "Anthropic",
-              "Google Generative AI",
-              "Groq",
-              "OpenAI",
-              "Custom"
-            ],
+            "options": [
+              "Anthropic",
+              "Google Generative AI",
+              "Groq",
+              "OpenAI",
+              "🧠 Cerebras",
+              "Custom"
+            ],
 ...
-            "options_metadata": [
-              { "icon": "Anthropic" },
-              { "icon": "GoogleGenerativeAI" },
-              { "icon": "Groq" },
-              { "icon": "OpenAI" },
-              { "icon": "brain" }
-            ],
+            "options_metadata": [
+              { "icon": "Anthropic" },
+              { "icon": "GoogleGenerativeAI" },
+              { "icon": "Groq" },
+              { "icon": "OpenAI" },
+              { "icon": "Cerebras" },   # keep naming consistent with other providers
+              { "icon": "brain" }
+            ],

Without this, the new capability is effectively hidden and causes runtime issues.

src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json (1)

1058-1066: Dropdown options not in sync – “🧠 Cerebras” missing from the rendered UI

The agent_llm template still lists only Anthropic/Google/Groq/OpenAI (+ Custom).
Because this array is what the builder front-end renders, the newly-supported Cerebras provider will not be selectable even though the Python code accepts it.

Add the new entry (and its icon metadata) to avoid a broken UX.

-                "options": [
-                  "Anthropic",
-                  "Google Generative AI",
-                  "Groq",
-                  "OpenAI",
-                  "Custom"
-                ],
+                "options": [
+                  "Anthropic",
+                  "Google Generative AI",
+                  "Groq",
+                  "OpenAI",
+                  "🧠 Cerebras",
+                  "Custom"
+                ],
@@
-                  {
-                    "icon": "OpenAI"
-                  },
-                  {
-                    "icon": "brain"
-                  }
+                  {
+                    "icon": "OpenAI"
+                  },
+                  {
+                    "icon": "Cerebras"   // <- add matching icon key defined in MODELS_METADATA
+                  },
+                  {
+                    "icon": "brain"
+                  }
src/backend/base/langflow/initial_setup/starter_projects/Travel Planning Agents.json (1)

1766-1772: agent_llm dropdown is not updated to list “🧠 Cerebras”.

The UI still exposes only five providers (Anthropic, Google Generative AI, Groq, OpenAI, Custom).
As soon as a user picks “Cerebras” in the sidebar, self.agent_llm will never equal "🧠 Cerebras" and the new backend branch will stay unreachable.

-          "options": [
-            "Anthropic",
-            "Google Generative AI",
-            "Groq",
-            "OpenAI",
-            "Custom"
-          ],
+          "options": [
+            "Anthropic",
+            "Google Generative AI",
+            "Groq",
+            "OpenAI",
+            "🧠 Cerebras",
+            "Custom"
+          ],

Don’t forget to extend options_metadata with the Cerebras icon as well.

Also applies to: 2309-2316, 2853-2860

src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json (1)

500-512: Include “🧠 Cerebras” in the JSON dropdown options and metadata

I’ve confirmed that MODELS_METADATA already defines a "🧠 Cerebras" entry, so you can safely expose it in the starter‐project JSON. In
src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json, update the agent_llm block:

• Add "🧠 Cerebras" to options before "Custom"
• Add { "icon": "🧠" } to options_metadata before the brain icon

--- a/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json
+++ b/src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json
@@ "agent_llm": {
   "options": [
     "Anthropic",
     "Google Generative AI",
     "Groq",
     "OpenAI",
+    "🧠 Cerebras",
     "Custom"
   ],
   "options_metadata": [
     { "icon": "Anthropic" },
     { "icon": "GoogleGenerativeAI" },
     { "icon": "Groq" },
     { "icon": "OpenAI" },
+    { "icon": "🧠" },
     { "icon": "brain" }
   ],
src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (1)

1422-1446: Template metadata out of sync with code – “🧠 Cerebras” missing

The provider template shown to the front-end still exposes only OpenAI, Anthropic, Google.
Because the options array is the single source of truth for the UI, users won’t be able to pick Cerebras even though the backend supports it.

-                "options": [
-                  "OpenAI",
-                  "Anthropic",
-                  "Google"
-                ],
+                "options": [
+                  "OpenAI",
+                  "Anthropic",
+                  "Google",
+                  "🧠 Cerebras"
+                ],
 ...
-                "options_metadata": [
-                  { "icon": "OpenAI" },
-                  { "icon": "Anthropic" },
-                  { "icon": "GoogleGenerativeAI" }
-                ],
+                "options_metadata": [
+                  { "icon": "OpenAI" },
+                  { "icon": "Anthropic" },
+                  { "icon": "GoogleGenerativeAI" },
+                  { "icon": "Cerebras" }
+                ],

Also ensure the frontend icon map contains a “Cerebras” entry – emoji placeholders rarely survive icon pipelines.

src/backend/base/langflow/initial_setup/starter_projects/Custom Component Generator.json (2)

2638-2649: Avoid using an emoji in the provider identifier

The dropdown option is the single source of truth used later for equality checks (provider == "🧠 Cerebras").
Relying on an emoji:

  • complicates programmatic comparisons and logging,
  • is prone to invisible copy-paste errors,
  • is inconsistent with the plain-text identifiers already in use ("OpenAI", "Anthropic", "Google").

Recommendation:

- options=["OpenAI", "Anthropic", "Google", "🧠 Cerebras"],
+ options=["OpenAI", "Anthropic", "Google", "Cerebras"],
...
- elif field_value == "🧠 Cerebras":
+ elif field_value == "Cerebras":
...
- if provider == "🧠 Cerebras":
+ if provider == "Cerebras":

Keep the 🧠 in options_metadata if you want it purely for UI display ({"icon": "brain-circuit"}), but make the logical identifier text-only.


2626-2635: Guard ChatCerebras import and surface clear error when missing

The unguarded from langchain_cerebras import ChatCerebras breaks installs without that package. Please:

• Wrap the import in both

  • src/backend/base/langflow/components/models/language_model.py
  • src/backend/base/langflow/components/cerebras/cerebras_chat_models.py
    in a try/except ModuleNotFoundError and set ChatCerebras = None.
    • In build_model, before using ChatCerebras, check if it’s None and raise a ValueError instructing users to install the extra.
    • Add an extras_require entry (or Poetry/Flit equivalent) for Cerebras, e.g.
    [tool.poetry.extras] cerebras = ["langchain-cerebras"]

Example diff for language_model.py:

- from langchain_cerebras import ChatCerebras
+ try:
+     from langchain_cerebras import ChatCerebras  # optional
+ except ModuleNotFoundError:  # pragma: no cover
+     ChatCerebras = None
@@ def build_model(self) -> LanguageModel:
     if provider == "🧠 Cerebras":
-        if not self.api_key:
-            raise ValueError("CEREBRAS API key is required…")
-        return ChatCerebras(...)
+        if ChatCerebras is None:
+            raise ValueError(
+                "Cerebras support requires installing the optional langchain-cerebras package."
+            )
+        if not self.api_key:
+            raise ValueError("CEREBRAS API key is required…")
+        return ChatCerebras(...)
src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json (2)

1545-1551: Add langchain-cerebras to runtime dependencies

The component now imports ChatCerebras, but the project’s dependency lists (e.g. requirements.txt, pyproject.toml) were not touched in this PR. Any flow that instantiates this starter project will raise ModuleNotFoundError at runtime unless the package is pre-installed.

  • Verify whether langflow already vendors this extra; otherwise add:
langchain-cerebras>=0.1.0  # exact version as needed

1564-1570: Template JSON still lists only three providers

Further down in the same node’s JSON (provider.options array) the new provider is not present.
This starter project will therefore load with an invalid default value ("🧠 Cerebras" not in list) or hide the option entirely, depending on the frontend’s validation logic.

After regenerating the starter via langflow run --save, ensure the provider.options array contains the exact four values defined in code.

src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json (1)

1053-1076: Provider dropdown is out-of-sync with the new Cerebras support.

The provider.options array still lists only "OpenAI", "Anthropic", "Google", and options_metadata has only three entries.
Because "🧠 Cerebras" is missing here, the UI cannot surface the new provider that the component code now understands, leading to an unreachable code path and a runtime “Unknown provider” error when users select Cerebras in another context (e.g., importing this flow).

           "options": [
             "OpenAI",
             "Anthropic",
-            "Google"
+            "Google",
+            "🧠 Cerebras"
           ],
           "options_metadata": [
             {
               "icon": "OpenAI"
             },
             {
               "icon": "Anthropic"
             },
             {
-              "icon": "GoogleGenerativeAI"
+              "icon": "GoogleGenerativeAI"
+            },
+            {
+              "icon": "Cerebras"
             }
           ],

Please update both arrays (and keep them alphabetically sorted per project conventions) so the frontend and backend stay consistent.

src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json (1)

1409-1420: Provider dropdown in template not in sync with new Cerebras support

LanguageModelComponent code now exposes "🧠 Cerebras" in the provider DropdownInput, but the node template further down (lines 1467-1490) still lists only OpenAI, Anthropic, Google.
End-users won’t be able to pick the new provider from the UI, which breaks the feature you’re shipping.

@@
-          "options": [
-            "OpenAI",
-            "Anthropic",
-            "Google"
-          ],
+          "options": [
+            "OpenAI",
+            "Anthropic",
+            "Google",
+            "🧠 Cerebras"
+          ],
@@
-          "options_metadata": [
-            {"icon": "OpenAI"},
-            {"icon": "Anthropic"},
-            {"icon": "GoogleGenerativeAI"}
-          ],
+          "options_metadata": [
+            {"icon": "OpenAI"},
+            {"icon": "Anthropic"},
+            {"icon": "GoogleGenerativeAI"},
+            {"icon": "Cerebras"}
+          ],

Update the JSON so the template matches the Python component.

src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json (1)

1148-1153: Starter-template mismatch – new provider missing from persisted config

The rendered template still lists only three providers:

"options": ["OpenAI", "Anthropic", "Google"]

Consequently the UI will not show “🧠 Cerebras” until the field is touched at runtime.
Add the provider here to keep the template self-consistent:

-"options": [
-  "OpenAI",
-  "Anthropic",
-  "Google"
-],
+"options": [
+  "OpenAI",
+  "Anthropic",
+  "Google",
+  "🧠 Cerebras"
+],
src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (2)

4598-4608: Provider label contains emoji – expect downstream breakage

DropdownInput.options defines the provider as "🧠 Cerebras".
The backend normally treats provider IDs as ASCII labels (e.g. "OpenAI", "Anthropic"). Introducing the emoji inside the value:

  1. ​Makes equality checks fragile (self.provider == "🧠 Cerebras" must be used everywhere).
  2. ​Breaks existing analytics / telemetry that assume plain-text provider names.
  3. ​Leaks a UI concern (iconography) into data / logic layers.

Recommend keeping the data value text-only ("Cerebras") and convey the emoji purely through options_metadata:

-            options=["OpenAI", "Anthropic", "Google","🧠 Cerebras"],
+            options=["OpenAI", "Anthropic", "Google", "Cerebras"],
...
-            options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"},{"icon" : "🧠"}],
+            options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"}, {"icon": "brain-circuit"}],

Adjust the two string comparisons further below accordingly.


4629-4639: Use the correct keyword for ChatCerebras instantiation
The ChatCerebras model uses a Pydantic field named cerebras_api_key (and reads from the CEREBRAS_API_KEY env var). Passing api_key=… will be ignored or raise a TypeError. Please update the instantiation in your JSON-embedded Python snippet accordingly:

• File: src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json
(around lines 4629–4639, where ChatCerebras is returned)

- return ChatCerebras(
-     model=model_name,
-     temperature=temperature,
-     streaming=stream,
-     api_key=self.api_key,
- )
+ return ChatCerebras(
+     model=model_name,
+     temperature=temperature,
+     streaming=stream,
+     cerebras_api_key=self.api_key,
+ )

Verified against langchain-cerebras v0.5.0, which defines cerebras_api_key and does not accept api_key.

src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (3)

1553-1576: Provider dropdown not updated – Cerebras can’t be selected from the UI.

The template section that feeds the frontend dropdown still exposes only the three legacy providers.
Without the extra option the user will never be able to pick “🧠 Cerebras”, making the rest of the integration unreachable.

"options": [
-  "OpenAI",
-  "Anthropic",
-  "Google"
+  "OpenAI",
+  "Anthropic",
+  "Google",
+  "🧠 Cerebras"
],
"options_metadata": [
   { "icon": "OpenAI" },
   { "icon": "Anthropic" },
-  { "icon": "Google" }
+  { "icon": "GoogleGenerativeAI" },
+  { "icon": "🧠" }
]

Please apply the same fix to every LanguageModelComponent node in this starter project.


1495-1659: Three identical embedded component definitions – centralise to avoid drift.

The full LanguageModelComponent source code is inlined three times (qFXT1, Wp3pC, gYAmH). Keeping them in sync will be error-prone; bugs fixed in one node will keep resurfacing in the others.

Recommend turning the starter-project’s nodes into references of the backend component instead of pasting the whole class, or at least move the JSON-embedded code to a single custom component and reuse it.


1495-1504: Add langchain_cerebras to runtime dependencies and keep api_key in ChatCerebras constructor

The import of ChatCerebras requires adding langchain_cerebras to your project’s runtime requirements. The suggestion to switch the constructor kw-arg to cerebras_api_key is incorrect—ChatCerebras accepts api_key, not cerebras_api_key.

• Ensure you list langchain_cerebras in your runtime requirements (e.g. requirements.txt or an extras/cerebras entry).
• In src/backend/base/langflow/components/models/language_model.py (around line 133) and similar starter-project snippets, keep using:

return ChatCerebras(
    model=model_name,
    temperature=temperature,
    streaming=stream,
    api_key=self.api_key,  # correct parameter
)
src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json (1)

2126-2140: Provider dropdown not updated – “🧠 Cerebras” can’t be selected

The component’s Python code (see lines 2068-2100) adds the new provider, but this template section still exposes only ["OpenAI", "Anthropic", "Google"].
When this flow is opened the UI will never surface the Cerebras option, so the new path is unreachable.

-            "options": [
-              "OpenAI",
-              "Anthropic",
-              "Google"
-            ],
-            "options_metadata": [
-              { "icon": "OpenAI" },
-              { "icon": "Anthropic" },
-              { "icon": "Google" }
-            ],
+            "options": [
+              "OpenAI",
+              "Anthropic",
+              "Google",
+              "🧠 Cerebras"
+            ],
+            "options_metadata": [
+              { "icon": "OpenAI" },
+              { "icon": "Anthropic" },
+              { "icon": "GoogleGenerativeAI" },
+              { "icon": "Cerebras" }     // pick an existing icon name used in icons.mdc
+            ],

Please mirror the same change in any duplicated LanguageModelComponent nodes to avoid silent inconsistency.

src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json (2)

1371-1390: Icon metadata is inconsistent with project guidelines.

options_metadata expects an icon name (e.g. "Cerebras"), not a raw emoji.
Mixing an emoji ("🧠") with the others ("OpenAI", "Anthropic", …) breaks the “clear, recognizable and consistent” rule and may render a missing-icon placeholder on the frontend.

- options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"},{"icon" : "🧠"}],
+ options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"}, {"icon": "Cerebras"}],

1305-1314: Add langchain-cerebras to project dependencies and confirm correct api_key usage

The ChatCerebras class does indeed accept api_key (not cerebras_api_key), so your constructor call is correct. However, because langchain_cerebras isn’t included in the standard LangChain extras, you should:

  • Add langchain-cerebras to your project’s requirements (e.g. requirements.txt or pyproject.toml) to ensure the wheel is available at deployment.
  • No changes needed to the constructor call—continue using api_key="…".
src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (2)

2085-2105: Inconsistent provider list between backend logic and template – “🧠 Cerebras” missing in UI

MODEL_PROVIDERS_LIST now contains "🧠 Cerebras", but the agent_llm dropdown (template.agent_llm.options) still exposes only Anthropic, Google Generative AI, Groq, and OpenAI.
At run-time the backend will happily accept "🧠 Cerebras", yet the user cannot select it from the UI, breaking the feature.

-                "options": [
-                  "Anthropic",
-                  "Google Generative AI",
-                  "Groq",
-                  "OpenAI",
-                  "Custom"
-                ],
+                "options": [
+                  "Anthropic",
+                  "Google Generative AI",
+                  "Groq",
+                  "OpenAI",
+                  "🧠 Cerebras",
+                  "Custom"
+                ],

Also append a matching icon entry to options_metadata to keep indices aligned.


2550-2580: Provider dropdown of LanguageModelComponent not updated

The backend code supports "🧠 Cerebras" (import + build-logic), but the template for LanguageModelComponent-Ln5SK and LanguageModelComponent-7h76H still lists only OpenAI | Anthropic | Google.
End-users therefore cannot trigger the Cerebras branch and will hit the "Unknown provider" fallback.

Same fix pattern as above – add "🧠 Cerebras" to template.provider.options and extend options_metadata with a proper icon key (do not use the raw emoji; prefer a deterministic icon name, e.g. "Cerebras").

src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json (1)

3080-3120: Fix Cerebras integration import & constructor

The import from langchain_cerebras import ChatCerebras fails with ModuleNotFoundError. The Cerebras chat model is published under LangChain’s community namespace, and its constructor likely expects a vendor-specific API key parameter.

– File: src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json
• Update the import to the correct module path (for example:
python from langchain_community.chat_models.cerebras import ChatCerebras
)
• In build_model, adjust the instantiation to match the actual signature (e.g. rename api_key=self.api_key to cerebras_api_key=self.api_key or whatever the class expects)

Ensure you install the correct package and verify the constructor signature in its source before merging.

src/backend/base/langflow/initial_setup/starter_projects/Youtube Analysis.json (3)

868-875: MODEL_PROVIDERS_LIST updated but front-end dropdown still misses “🧠 Cerebras”.

The class–level MODEL_PROVIDERS_LIST now includes the new provider, yet the agent_llm DropdownInput declared a few lines above ( ≈ 799-822 ) still hard-codes the old list.
At runtime this causes an invalid default selection (“OpenAI”) whenever the UI serialises the component, and users will never be able to choose Cerebras.

-            options=["Anthropic", "Google Generative AI", "Groq", "OpenAI", "Custom"],
+            options=[*MODEL_PROVIDERS_LIST, "Custom"],

Please replicate the same fix in the JSON template (field agent_llm→options/options_metadata) so that the starter-project opens without manual edits.


2330-2356: LanguageModel provider dropdown out of sync with code

The template stanza for provider still lists only OpenAI | Anthropic | Google.
Because update_build_config relies on receiving "🧠 Cerebras" from the UI, the newly-added branch will never be hit.

Add the missing option & icon:

-            "options": [
-              "OpenAI",
-              "Anthropic",
-              "Google"
-            ],
+            "options": [
+              "OpenAI",
+              "Anthropic",
+              "Google",
+              "🧠 Cerebras"
+            ],
...
-                  { "icon": "GoogleGenerativeAI" }
+                  { "icon": "GoogleGenerativeAI" },
+                  { "icon": "brain" }

(Assuming “brain” is the correct icon identifier – emoji won’t render in the current UI set.)


2245-2280: Add langchain-cerebras to project dependencies

The langchain_cerebras import is unconditional, so you must declare it in your dependency files to avoid runtime errors. The existing use of api_key is correct per the current ChatCerebras signature.

• In your dependency manifest (e.g. pyproject.toml, requirements.txt), add:

+# Add Cerebras support
+langchain-cerebras>=0.5.0
src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (2)

1070-1100: Node template still omits the new provider – UI won’t expose Cerebras

The serialized node (template.provider.options) only lists OpenAI, Anthropic, Google.
Because the builder UI relies on this list, users will not be able to pick “🧠 Cerebras”, even though the backend class supports it.

Patch suggestion (keep alphabetical order for consistency):

-                  "Google"
+                  "Google",
+                  "🧠 Cerebras"

Don’t forget to append the corresponding entry in options_metadata.
Until this is fixed, the new feature is effectively unreachable from the playground.


1017-1030: Emoji-prefixed provider label & icon may break downstream equality checks

You chose "🧠 Cerebras" as the provider token and used a raw emoji ("🧠") as icon metadata.
Down-stream comparisons (if provider == "🧠 Cerebras":) work, but:

  1. Emojis can be lost during serialisation in some DBs / JSON viewers.
  2. The icon registry expects a slug, not a Unicode glyph (see icons guideline).

Consider switching to a plain identifier, e.g. "Cerebras" with "Cerebras" (or a dedicated slug) in options_metadata; then map the slug to an emoji or SVG in the frontend layer.

src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (3)

1832-1861: Missing external dependency declaration for langchain-cerebras
ChatCerebras is imported from langchain_cerebras, but that extra-provider is not present in the project’s dependency lists (requirements*.txt / pyproject.toml). Import will fail at runtime on a fresh installation.

# requirements.txt / pyproject-extras
+langchain-cerebras>=0.1.0   # version aligned with the rest of langchain_* family

1889-1903: Starter-project UI not wired for the new provider
The provider dropdown that the Playground actually renders still lists only OpenAI | Anthropic | Google.
Without adding “🧠 Cerebras” here the user can never pick it, despite the backend code supporting it.

                 "options": [
                   "OpenAI",
                   "Anthropic",
                   "Google"
+                  ,"🧠 Cerebras"
                 ],

Replicate the same in options_metadata with a proper icon entry.


2130-2142: Agent component suffers from the same UI / backend mismatch
MODEL_PROVIDERS_LIST (backend) contains “🧠 Cerebras” but the agent_llm dropdown in this JSON block does not.
Failure path: user selects Cerebras in future UI → self.agent_llm == "🧠 Cerebras" but MODEL_PROVIDERS_DICT has no matching key → runtime ValueError.

Add the option (and metadata) or change all backend keys to a plain "Cerebras" string to stay ASCII-safe.

src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json (3)

2043-2058: Provider is supported in code but not selectable in the UI

inputs = [ DropdownInput( … options=["OpenAI", "Anthropic", "Google", "🧠 Cerebras"], … ) ]

Good that Cerebras is added in the backend, but the corresponding template section for this component (↓ lines 2085-2115) still lists only ["OpenAI", "Anthropic", "Google"].
Result: users can’t pick the provider from the dropdown, so the new branch is dead code.

Add the option (and its icon metadata) to the template to keep UI ↔ logic in sync.

-            "options": [
-              "OpenAI",
-              "Anthropic",
-              "Google"
-            ],
+            "options": [
+              "OpenAI",
+              "Anthropic",
+              "Google",
+              "🧠 Cerebras"
+            ],
+            "options_metadata": [
+              {"icon": "OpenAI"},
+              {"icon": "Anthropic"},
+              {"icon": "GoogleGenerativeAI"},
+              {"icon": "Cerebras"}
+            ],

2059-2068: Inconsistent provider key may break cross-component coherence

Every comparison uses the literal "🧠 Cerebras".
Elsewhere in the codebase (model_input_constants, cerebras_constants) the provider might be registered simply as "Cerebras". A mismatch will cause:

  • MODEL_PROVIDERS_DICT look-ups to fail.
  • The Agent component not finding the Cerebras entry.

Prefer a plain key ("Cerebras") and keep the emoji for display purposes via options_metadata.


2695-2705: Same UI desync in Agent component

MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"]

But the agent_llm dropdown (lines 2624-2633) still lacks Cerebras – users can’t select it → get_llm() will raise Invalid model provider.

Bring the dropdown’s options/options_metadata in line with MODEL_PROVIDERS_LIST.

♻️ Duplicate comments (7)
src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json (2)

1045-1060: Same inconsistency duplicated – please apply fix once and deduplicate

The identical block appears again for the Analysis & Editor Agent. Consider extracting this shared agent Python to a single component instead of embedding three almost-identical code blobs inside JSON.


2385-2410: Third occurrence – see first comment

Same missing dropdown update for the Researcher Agent.

src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json (1)

2361-2410: Same issue duplicated in second LanguageModelComponent

This second node repeats the code & template; ensure the provider dropdown patch and icon fix are applied here as well.

src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json (2)

1685-1689: Duplicate of the provider-icon inconsistency noted above – same fix applies here.


1605-1614: Duplicate of the earlier ChatCerebras import / constructor concerns.

src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json (1)

3375-3405: Same concerns apply here – duplicated component code.

The second LanguageModelComponent node repeats the entire class definition with the same potential issues (import path, api_key kwarg, emoji icon). Consider referencing a single, tested component implementation instead of duplicating large code blocks inside starter-project JSON.

src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (1)

1942-1943: Same issue duplicated in second LanguageModelComponent block

The concerns about the wrong keyword name and the emoji-prefixed provider string apply here as well.

🧹 Nitpick comments (25)
src/backend/base/langflow/.gitignore (1)

1-1: Verify .gitignore placement – pattern likely misses the real database file

A .gitignore inside src/backend/base/langflow/ only ignores langflow.db if that file lives in the same directory.
If your SQLite database is actually created at the project root (or anywhere else), it will still be tracked.

Action:

  1. Confirm where langflow.db is produced.
  2. If it is outside this sub-directory, move the rule to the top-level .gitignore (or prepend ../ as needed) and delete this nested file.

Example fix at repo root:

+# Ignore local SQLite database
+langflow.db

Then delete src/backend/base/langflow/.gitignore entirely.

src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (2)

1454-1469: Missing icon metadata for the new provider.

options_metadata currently contains five items; the last one (“brain”) is meant for Custom.
Insert an entry for Cerebras before that, otherwise the dropdown shows a blank icon.

                 {"icon": "OpenAI"},
+                {"icon": "Cerebras"},
                 {"icon": "brain"}

1437-1444: Minor: MODEL_PROVIDERS_LIST now duplicated between code & JSON.

Since the JSON snapshot is generated from the component code, keeping a separate static list invites drift (as seen here).
Consider generating the dropdown options from MODEL_PROVIDERS_LIST at build-time rather than hard-coding them in starter-project templates.

src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json (1)

1441-1455: Avoid duplicating provider lists – derive from MODEL_PROVIDERS_DICT instead.

MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"] hard-codes the same info already present in MODEL_PROVIDERS_DICT. This duplication invites drift (see mismatch above) and forces future edits in two places.

A minimal refactor keeps a single source of truth:

-MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"]
+MODEL_PROVIDERS_LIST = list(MODEL_PROVIDERS_DICT.keys())

If display order matters, consider an ordered mapping or explicit sort rather than a second constant.

src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (1)

1364-1374: PEP-8: missing space after comma in newly-added import and option lists

Two tiny but recurring spacing glitches slipped in with the Cerebras addition:

  1. from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES
  2. options=[\"OpenAI\", \"Anthropic\", \"Google\",\"🧠 Cerebras\"],

Besides hurting readability, these nits will make the linter scream in CI.

-from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES
+from langflow.base.models.cerebras_constants import (
+    CEREBRAS_CHAT_MODEL_NAMES,
+    CEREBRAS_REASONING_MODEL_NAMES,
+)
...
-options=["OpenAI", "Anthropic", "Google","🧠 Cerebras"],
+options=["OpenAI", "Anthropic", "Google", "🧠 Cerebras"],
src/backend/base/langflow/components/cerebras/cerebras_chat_models.py (2)

3-3: Remove commented import.

This commented import appears to be leftover code and should be removed.

-# from langchain_openai import ChatOpenAI

54-61: Set default API base URL value.

The info text mentions a default URL but the field doesn't have a default value set.

         StrInput(
-            name="Cerebras_api_base",
+            name="cerebras_api_base",
             display_name="Cerebras API Base",
             advanced=True,
             info="The base URL of the Cerebras API. "
             "Defaults to https://api.cerebras.ai/v1. "
             "You can change this to use other APIs like JinaChat, LocalAI and Prem.",
+            value="https://api.cerebras.ai/v1",
         ),
src/backend/base/langflow/initial_setup/starter_projects/Image Sentiment Analysis.json (1)

1558-1564: Icon metadata is inconsistent

options_metadata uses { "icon": "🧠" }, while other providers reference a stable icon name ("OpenAI", "Anthropic", …). Unless the frontend explicitly maps the brain emoji, the picker will render nothing or a fallback.

Prefer a descriptive identifier, e.g.:

-            options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"}, {"icon" : "🧠"}],
+            options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"}, {"icon": "Cerebras"}],
src/backend/base/langflow/initial_setup/starter_projects/Blog Writer.json (2)

1409-1409: Tiny style nit – missing space after comma in import

from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES

→ add a space after the comma for consistency.

-from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES
+from langflow.base.models.cerebras_constants import (
+    CEREBRAS_CHAT_MODEL_NAMES,
+    CEREBRAS_REASONING_MODEL_NAMES,
+)

1409-1420: Icon metadata likely invalid

{"icon": "🧠"} is not a registered icon key (others use OpenAI, Anthropic, GoogleGenerativeAI).
Unless the frontend maps this emoji explicitly, the icon will fall back to a default or render incorrectly. Use a named icon (e.g., "Cerebras") and add the asset on the FE side.

src/backend/base/langflow/initial_setup/starter_projects/Financial Report Parser.json (3)

1082-1084: Missing whitespace after comma in import list

Python style guides (PEP-8) recommend a space after commas.

-from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES
+from langflow.base.models.cerebras_constants import (
+    CEREBRAS_CHAT_MODEL_NAMES,
+    CEREBRAS_REASONING_MODEL_NAMES,
+)

1092-1105: Un-mapped icon name may break the provider dropdown

options_metadata uses

{"icon" : "🧠"}

The icon registry expects a symbolic name (e.g. "Cerebras"), not a raw emoji, otherwise the frontend falls back to the generic icon.

- options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"},{ "icon": "🧠"}],
+ options_metadata=[{"icon": "OpenAI"}, {"icon": "Anthropic"}, {"icon": "GoogleGenerativeAI"}, {"icon": "Cerebras"}],

1100-1130: Minor: keep provider literals in a single constant

"🧠 Cerebras" appears four times (options, comparison, update logic, default value).
Introduce a constant PROVIDER_CEREBRAS = "🧠 Cerebras" at the top of the component to avoid typos drifting apart.

src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (3)

4586-4586: PEP-8 / readability – missing space after comma

from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES

Minor, but the missing space after the comma hurts readability and fails most linters.


4649-4662: Duplicated provider logic – consider mapping table

build_model now contains four near-identical if provider == ... blocks.
Adding further providers will keep inflating this method. A concise dispatch table removes duplication:

PROVIDER_MAP = {
    "OpenAI": (ChatOpenAI, OPENAI_REASONING_MODEL_NAMES, "openai_api_key"),
    "Anthropic": (ChatAnthropic, None, "anthropic_api_key"),
    "Google": (ChatGoogleGenerativeAI, None, "google_api_key"),
    "Cerebras": (ChatCerebras, None, "cerebras_api_key"),
}

model_cls, no_temp_names, key_kw = PROVIDER_MAP[provider]
if not self.api_key:
    raise ValueError(f"{provider} API key is required")

kwargs = {key_kw: self.api_key, "model": model_name, "temperature": temperature, "streaming": stream}
if no_temp_names and model_name in no_temp_names:
    kwargs.pop("temperature")
return model_cls(**kwargs)

This removes six dozen lines and centralises provider metadata.


4675-4685: Icon metadata uses literal emoji

{"icon" : "🧠"} is passed as an icon id. The frontend icon registry expects a semantic key (e.g. "Cerebras" or "brain-circuit" per repo convention). Using a raw emoji will likely render nothing. Align with the guideline “ensure the icon name is clear, recognizable, and used consistently across backend & frontend mappings.”

src/backend/base/langflow/initial_setup/starter_projects/Hybrid Search RAG.json (1)

2068-2100: Use a real icon identifier instead of the “🧠” emoji

options_metadata currently sets {"icon": "🧠"}. Front-end icon maps expect symbolic names (e.g. Cerebras, BrainCircuit) defined in icons.mdc; an emoji will fall back to a missing-icon glyph.

Replace with the agreed icon key and add the mapping in the React/TypeScript side according to the icon-naming guideline.

src/backend/base/langflow/initial_setup/starter_projects/Basic Prompt Chaining.json (1)

1305-1306: PEP 8 nit – spacing in import list.

Missing space after the comma:

-from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES
+from langflow.base.models.cerebras_constants import (
+    CEREBRAS_CHAT_MODEL_NAMES,
+    CEREBRAS_REASONING_MODEL_NAMES,
+)
src/backend/base/langflow/initial_setup/starter_projects/Instagram Copywriter.json (1)

2845-2875: Duplicate embedded Python blocks – risk of divergence

Identical LanguageModelComponent code is embedded twice (nodes Ln5SK & 7h76H).
Future changes will require editing both blobs, increasing maintenance cost and risk of inconsistencies. Consider keeping a single source of truth (custom component import) and reference it from both nodes.

src/backend/base/langflow/initial_setup/starter_projects/Meeting Summary.json (1)

3088-3095: Icon metadata uses a raw emoji – may break UI rendering.

options_metadata=[…, {"icon": "🧠"}]
The frontend icon loader expects a registered icon name (e.g., "Cerebras"), not an emoji. Falling back to a missing icon will render a blank square. Replace with a valid icon identifier or add the Cerebras icon asset first.

src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (1)

1017-1019: Minor style nits in import list

...,CEREBRAS_REASONING_MODEL_NAMES is missing a space after the comma – inconsistent with the other grouped imports.
Not critical, but fixing keeps the codebase tidy.

-from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMES
+from langflow.base.models.cerebras_constants import (
+    CEREBRAS_CHAT_MODEL_NAMES,
+    CEREBRAS_REASONING_MODEL_NAMES,
+)
src/backend/base/langflow/initial_setup/starter_projects/Market Research.json (1)

1832-1840: Use of emoji in provider key is fragile
Using the literal brain emoji in the provider identifier risks:

• Encoding issues in terminals / logs
• JSON key mismatches across files where different contributors might type “Cerebras” without the icon
• Difficulty when referencing providers via CLI / env vars.

Strongly consider a plain key "Cerebras" and keep the emoji only for display_name / icon.

src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json (1)

2323-2333: Duplicate block – keep one source of truth

The full LanguageModelComponent source is duplicated in two separate nodes. Any future hot-fix (e.g., API param rename) must be applied twice and risks drifting.

Consider storing the component once and referencing it, or generating these starter‐project nodes from a single canonical template.

src/backend/base/langflow/api/v1/mcp_projects.py (2)

85-89: Use is operator for boolean comparisons to avoid linting warnings.

The direct boolean comparison triggers E712 linting warnings. Use the is operator instead.

-            flows_query = select(Flow).where(Flow.folder_id == project_id, Flow.is_component == False)  # noqa: E712
+            flows_query = select(Flow).where(Flow.folder_id == project_id, Flow.is_component is False)

             # Optionally filter for MCP-enabled flows only
             if mcp_enabled:
-                flows_query = flows_query.where(Flow.mcp_enabled == True)  # noqa: E712
+                flows_query = flows_query.where(Flow.mcp_enabled is True)

661-661: Use is operator for boolean comparison.

-                            select(Flow).where(Flow.mcp_enabled == True, Flow.folder_id == self.project_id)  # noqa: E712
+                            select(Flow).where(Flow.mcp_enabled is True, Flow.folder_id == self.project_id)

Comment on lines +36 to +42
def is_pre_release(v: str) -> bool:
"""Returns a boolean indicating whether the version is a pre-release version.

Returns a boolean indicating whether the version is a pre-release version,
as per the definition of a pre-release segment from PEP 440.
"""
return any(label in v for label in ["a", "b", "rc"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve pre-release detection to avoid false positives.

The current implementation may produce false positives by matching pre-release labels anywhere in the version string. According to PEP 440, pre-release identifiers should be more specifically formatted.

Consider using a more robust regex-based approach:

+import re
+
 def is_pre_release(v: str) -> bool:
     """Returns a boolean indicating whether the version is a pre-release version.

     Returns a boolean indicating whether the version is a pre-release version,
     as per the definition of a pre-release segment from PEP 440.
     """
-    return any(label in v for label in ["a", "b", "rc"])
+    # PEP 440 pre-release pattern: matches .aN, .bN, .rcN where N is a number
+    pre_release_pattern = r'\.(?:a|b|rc)\d+'
+    return bool(re.search(pre_release_pattern, v))

Alternatively, consider using the packaging library for more robust version parsing:

from packaging.version import Version

def is_pre_release(v: str) -> bool:
    """Returns a boolean indicating whether the version is a pre-release version."""
    try:
        parsed_version = Version(v)
        return parsed_version.is_prerelease
    except Exception:
        return False
🤖 Prompt for AI Agents
In src/backend/base/langflow/version/version.py around lines 36 to 42, the
current is_pre_release function checks for pre-release labels anywhere in the
version string, causing false positives. Replace the simple substring check with
a robust approach by importing Version from the packaging library, parsing the
version string with Version(v), and returning parsed_version.is_prerelease. Add
exception handling to return False if parsing fails.

Comment on lines +24 to +33
version = None
for pkg_name in pkg_names:
with contextlib.suppress(ImportError, metadata.PackageNotFoundError):
version = metadata.version(pkg_name)

if version is None:
msg = f"Package not found from options {pkg_names}"
raise ValueError(msg)

return version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the logic bug in version retrieval.

The current implementation has a critical flaw: it continues iterating through package names even after finding a version, potentially overwriting a valid version with None. The function should return immediately upon finding a version.

Apply this diff to fix the logic:

-    version = None
-    for pkg_name in pkg_names:
-        with contextlib.suppress(ImportError, metadata.PackageNotFoundError):
-            version = metadata.version(pkg_name)
-
-    if version is None:
-        msg = f"Package not found from options {pkg_names}"
-        raise ValueError(msg)
-
-    return version
+    for pkg_name in pkg_names:
+        with contextlib.suppress(ImportError, metadata.PackageNotFoundError):
+            version = metadata.version(pkg_name)
+            if version is not None:
+                return version
+
+    msg = f"Package not found from options {pkg_names}"
+    raise ValueError(msg)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
version = None
for pkg_name in pkg_names:
with contextlib.suppress(ImportError, metadata.PackageNotFoundError):
version = metadata.version(pkg_name)
if version is None:
msg = f"Package not found from options {pkg_names}"
raise ValueError(msg)
return version
for pkg_name in pkg_names:
with contextlib.suppress(ImportError, metadata.PackageNotFoundError):
version = metadata.version(pkg_name)
if version is not None:
return version
msg = f"Package not found from options {pkg_names}"
raise ValueError(msg)
🤖 Prompt for AI Agents
In src/backend/base/langflow/version/version.py around lines 24 to 33, the code
continues looping through package names even after successfully retrieving a
version, which can overwrite a valid version with None. To fix this, modify the
loop to return the version immediately once it is found instead of continuing
the iteration. This ensures the first valid version is returned without being
overwritten.

status_code = httpx.get(
f"{protocol}://{health_check_host}:{port}/health",
verify=health_check_host not in ("127.0.0.1", "localhost"),
f"{protocol}://{host}:{port}/health", verify=host not in ("127.0.0.1", "localhost")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify health check functionality for "0.0.0.0" binding.

The removal of special handling for "0.0.0.0" host might break health checks. When a server binds to "0.0.0.0", it accepts connections on all interfaces, but making HTTP requests to "0.0.0.0" may not work reliably on all systems. The previous logic used "localhost" for health checks when binding to "0.0.0.0", which is more reliable.


🏁 Script executed:

#!/bin/bash
# Description: Check if there are any tests or documentation that validate health check behavior for "0.0.0.0" binding
# Expected: Find test cases or documentation that verify health check functionality

echo "Searching for tests related to health check and 0.0.0.0 binding..."
rg -A 5 -B 5 "wait_for_server_ready|health.*check.*0\.0\.0\.0|0\.0\.0\.0.*health"

echo "Searching for any references to 0.0.0.0 in test files..."
fd -e py -x rg -l "0\.0\.0\.0" {} \; | head -10

Length of output: 2378


Add explicit health-check coverage for “0.0.0.0” binding

We didn’t find any existing tests or documentation verifying the new behavior when the server is bound to “0.0.0.0” (the health-check URL now uses “0.0.0.0” directly). To avoid regressions across different environments:

• Add a unit or integration test for wait_for_server_ready(“0.0.0.0”, port, protocol) that confirms it successfully polls the health endpoint.
• Alternatively, document and manually confirm that HTTP requests to 0.0.0.0:{port}/health work reliably on target platforms.

This will ensure we catch any issues caused by removing the previous “0.0.0.0”→“localhost” fallback.

🤖 Prompt for AI Agents
In src/backend/base/langflow/__main__.py at line 154, add a new unit or
integration test that calls wait_for_server_ready with "0.0.0.0" as the host and
verifies it successfully polls the health endpoint. This test should confirm
that the health-check URL using "0.0.0.0" works correctly, preventing
regressions from removing the previous fallback to "localhost". Alternatively,
update documentation to note this behavior and manually verify HTTP requests to
"0.0.0.0:{port}/health" function reliably on target platforms.

Comment on lines +185 to +192
async def with_session(self):
if self.settings_service.settings.use_noop_database:
yield NoopSession()
else:
async with AsyncSession(self.engine, expire_on_commit=False) as session:
# Start of Selection
try:
yield session
except exc.SQLAlchemyError as db_exc:
logger.error(f"Database error during session scope: {db_exc}")
await session.rollback()
raise
async with AsyncSession(self.engine, expire_on_commit=False) as session:
# Start of Selection
try:
yield session
except exc.SQLAlchemyError as db_exc:
logger.error(f"Database error during session scope: {db_exc}")
await session.rollback()
raise
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Database session management simplified - verify no breaking changes.

The removal of the NoopSession conditional logic and always using AsyncSession appears to be a reasonable simplification. However, ensure that all code paths that previously relied on use_noop_database setting have been properly updated.


🏁 Script executed:

#!/bin/bash
# Description: Verify that no code still references use_noop_database or NoopSession
# Expected: No references should remain in the codebase

echo "Searching for references to use_noop_database:"
rg -n "use_noop_database" --type py

echo -e "\nSearching for references to NoopSession:"
rg -n "NoopSession" --type py

echo -e "\nSearching for imports of NoopSession:"
rg -n "from.*NoopSession" --type py

Length of output: 1983


Remove residual NoopSession references and update tests.

The with_session simplification removed the noop branch, but the NoopSession class and its imports still exist in session.py and are referenced in several test files. These need to be cleaned up to avoid dead code and broken tests.

• src/backend/base/langflow/services/database/session.py
– Remove or deprecate the class NoopSession definition if it’s no longer needed.
• src/backend/tests/unit/components/agents/test_agent_component.py
– Replace all from langflow.services.database.session import NoopSession imports and patches (add, commit, etc.) with the appropriate AsyncSession or a test session fixture.
• src/backend/tests/unit/custom/custom_component/test_component.py
– Update the same imports and mocks of NoopSession to use AsyncSession or your test session helper.
• src/backend/tests/conftest.py
– Remove the commented-out monkeypatch.setattr(Settings, "use_noop_database", True) (line 378) and any other noop-related setup.

🤖 Prompt for AI Agents
In src/backend/base/langflow/services/database/session.py around the NoopSession
class definition, remove or deprecate the NoopSession class since it is no
longer used. In src/backend/tests/unit/components/agents/test_agent_component.py
and src/backend/tests/unit/custom/custom_component/test_component.py, replace
all imports and mocks of NoopSession with AsyncSession or the appropriate test
session fixture to align with the updated session handling. In
src/backend/tests/conftest.py, remove the commented-out monkeypatch line related
to use_noop_database and any other noop-related setup to clean up dead code and
prevent broken tests.

Comment on lines +1835 to 1837
"value": "from langchain_core.tools import StructuredTool\n\nfrom langflow.base.agents.agent import LCToolsAgentComponent\nfrom langflow.base.agents.events import ExceptionWithMessageError\nfrom langflow.base.models.model_input_constants import (\n ALL_PROVIDER_FIELDS,\n MODEL_DYNAMIC_UPDATE_FIELDS,\n MODEL_PROVIDERS,\n MODEL_PROVIDERS_DICT,\n MODELS_METADATA,\n)\nfrom langflow.base.models.model_utils import get_model_name\nfrom langflow.components.helpers.current_date import CurrentDateComponent\nfrom langflow.components.helpers.memory import MemoryComponent\nfrom langflow.components.langchain_utilities.tool_calling import ToolCallingAgentComponent\nfrom langflow.custom.custom_component.component import _get_component_toolkit\nfrom langflow.custom.utils import update_component_build_config\nfrom langflow.field_typing import Tool\nfrom langflow.io import BoolInput, DropdownInput, IntInput, MultilineInput, Output\nfrom langflow.logging import logger\nfrom langflow.schema.dotdict import dotdict\nfrom langflow.schema.message import Message\n\n\ndef set_advanced_true(component_input):\n component_input.advanced = True\n return component_input\n\n\nMODEL_PROVIDERS_LIST = [\"Anthropic\", \"Google Generative AI\", \"Groq\", \"OpenAI\",\"🧠 Cerebras\"]\n\n\nclass AgentComponent(ToolCallingAgentComponent):\n display_name: str = \"Agent\"\n description: str = \"Define the agent's instructions, then enter a task to complete using tools.\"\n documentation: str = \"https://docs.langflow.org/agents\"\n icon = \"bot\"\n beta = False\n name = \"Agent\"\n\n memory_inputs = [set_advanced_true(component_input) for component_input in MemoryComponent().inputs]\n\n inputs = [\n DropdownInput(\n name=\"agent_llm\",\n display_name=\"Model Provider\",\n info=\"The provider of the language model that the agent will use to generate responses.\",\n options=[*MODEL_PROVIDERS_LIST, \"Custom\"],\n value=\"OpenAI\",\n real_time_refresh=True,\n input_types=[],\n options_metadata=[MODELS_METADATA[key] for key in MODEL_PROVIDERS_LIST] + [{\"icon\": \"brain\"}],\n ),\n *MODEL_PROVIDERS_DICT[\"OpenAI\"][\"inputs\"],\n MultilineInput(\n name=\"system_prompt\",\n display_name=\"Agent Instructions\",\n info=\"System Prompt: Initial instructions and context provided to guide the agent's behavior.\",\n value=\"You are a helpful assistant that can use tools to answer questions and perform tasks.\",\n advanced=False,\n ),\n IntInput(\n name=\"n_messages\",\n display_name=\"Number of Chat History Messages\",\n value=100,\n info=\"Number of chat history messages to retrieve.\",\n advanced=True,\n show=True,\n ),\n *LCToolsAgentComponent._base_inputs,\n # removed memory inputs from agent component\n # *memory_inputs,\n BoolInput(\n name=\"add_current_date_tool\",\n display_name=\"Current Date\",\n advanced=True,\n info=\"If true, will add a tool to the agent that returns the current date.\",\n value=True,\n ),\n ]\n outputs = [Output(name=\"response\", display_name=\"Response\", method=\"message_response\")]\n\n async def message_response(self) -> Message:\n try:\n # Get LLM model and validate\n llm_model, display_name = self.get_llm()\n if llm_model is None:\n msg = \"No language model selected. Please choose a model to proceed.\"\n raise ValueError(msg)\n self.model_name = get_model_name(llm_model, display_name=display_name)\n\n # Get memory data\n self.chat_history = await self.get_memory_data()\n if isinstance(self.chat_history, Message):\n self.chat_history = [self.chat_history]\n\n # Add current date tool if enabled\n if self.add_current_date_tool:\n if not isinstance(self.tools, list): # type: ignore[has-type]\n self.tools = []\n current_date_tool = (await CurrentDateComponent(**self.get_base_args()).to_toolkit()).pop(0)\n if not isinstance(current_date_tool, StructuredTool):\n msg = \"CurrentDateComponent must be converted to a StructuredTool\"\n raise TypeError(msg)\n self.tools.append(current_date_tool)\n # note the tools are not required to run the agent, hence the validation removed.\n\n # Set up and run agent\n self.set(\n llm=llm_model,\n tools=self.tools or [],\n chat_history=self.chat_history,\n input_value=self.input_value,\n system_prompt=self.system_prompt,\n )\n agent = self.create_agent_runnable()\n return await self.run_agent(agent)\n\n except (ValueError, TypeError, KeyError) as e:\n logger.error(f\"{type(e).__name__}: {e!s}\")\n raise\n except ExceptionWithMessageError as e:\n logger.error(f\"ExceptionWithMessageError occurred: {e}\")\n raise\n except Exception as e:\n logger.error(f\"Unexpected error: {e!s}\")\n raise\n\n async def get_memory_data(self):\n # TODO: This is a temporary fix to avoid message duplication. We should develop a function for this.\n messages = (\n await MemoryComponent(**self.get_base_args())\n .set(session_id=self.graph.session_id, order=\"Ascending\", n_messages=self.n_messages)\n .retrieve_messages()\n )\n return [\n message for message in messages if getattr(message, \"id\", None) != getattr(self.input_value, \"id\", None)\n ]\n\n def get_llm(self):\n if not isinstance(self.agent_llm, str):\n return self.agent_llm, None\n\n try:\n provider_info = MODEL_PROVIDERS_DICT.get(self.agent_llm)\n if not provider_info:\n msg = f\"Invalid model provider: {self.agent_llm}\"\n raise ValueError(msg)\n\n component_class = provider_info.get(\"component_class\")\n display_name = component_class.display_name\n inputs = provider_info.get(\"inputs\")\n prefix = provider_info.get(\"prefix\", \"\")\n\n return self._build_llm_model(component_class, inputs, prefix), display_name\n\n except Exception as e:\n logger.error(f\"Error building {self.agent_llm} language model: {e!s}\")\n msg = f\"Failed to initialize language model: {e!s}\"\n raise ValueError(msg) from e\n\n def _build_llm_model(self, component, inputs, prefix=\"\"):\n model_kwargs = {}\n for input_ in inputs:\n if hasattr(self, f\"{prefix}{input_.name}\"):\n model_kwargs[input_.name] = getattr(self, f\"{prefix}{input_.name}\")\n return component.set(**model_kwargs).build_model()\n\n def set_component_params(self, component):\n provider_info = MODEL_PROVIDERS_DICT.get(self.agent_llm)\n if provider_info:\n inputs = provider_info.get(\"inputs\")\n prefix = provider_info.get(\"prefix\")\n model_kwargs = {input_.name: getattr(self, f\"{prefix}{input_.name}\") for input_ in inputs}\n\n return component.set(**model_kwargs)\n return component\n\n def delete_fields(self, build_config: dotdict, fields: dict | list[str]) -> None:\n \"\"\"Delete specified fields from build_config.\"\"\"\n for field in fields:\n build_config.pop(field, None)\n\n def update_input_types(self, build_config: dotdict) -> dotdict:\n \"\"\"Update input types for all fields in build_config.\"\"\"\n for key, value in build_config.items():\n if isinstance(value, dict):\n if value.get(\"input_types\") is None:\n build_config[key][\"input_types\"] = []\n elif hasattr(value, \"input_types\") and value.input_types is None:\n value.input_types = []\n return build_config\n\n async def update_build_config(\n self, build_config: dotdict, field_value: str, field_name: str | None = None\n ) -> dotdict:\n # Iterate over all providers in the MODEL_PROVIDERS_DICT\n # Existing logic for updating build_config\n if field_name in (\"agent_llm\",):\n build_config[\"agent_llm\"][\"value\"] = field_value\n provider_info = MODEL_PROVIDERS_DICT.get(field_value)\n if provider_info:\n component_class = provider_info.get(\"component_class\")\n if component_class and hasattr(component_class, \"update_build_config\"):\n # Call the component class's update_build_config method\n build_config = await update_component_build_config(\n component_class, build_config, field_value, \"model_name\"\n )\n\n provider_configs: dict[str, tuple[dict, list[dict]]] = {\n provider: (\n MODEL_PROVIDERS_DICT[provider][\"fields\"],\n [\n MODEL_PROVIDERS_DICT[other_provider][\"fields\"]\n for other_provider in MODEL_PROVIDERS_DICT\n if other_provider != provider\n ],\n )\n for provider in MODEL_PROVIDERS_DICT\n }\n if field_value in provider_configs:\n fields_to_add, fields_to_delete = provider_configs[field_value]\n\n # Delete fields from other providers\n for fields in fields_to_delete:\n self.delete_fields(build_config, fields)\n\n # Add provider-specific fields\n if field_value == \"OpenAI\" and not any(field in build_config for field in fields_to_add):\n build_config.update(fields_to_add)\n else:\n build_config.update(fields_to_add)\n # Reset input types for agent_llm\n build_config[\"agent_llm\"][\"input_types\"] = []\n elif field_value == \"Custom\":\n # Delete all provider fields\n self.delete_fields(build_config, ALL_PROVIDER_FIELDS)\n # Update with custom component\n custom_component = DropdownInput(\n name=\"agent_llm\",\n display_name=\"Language Model\",\n options=[*sorted(MODEL_PROVIDERS), \"Custom\"],\n value=\"Custom\",\n real_time_refresh=True,\n input_types=[\"LanguageModel\"],\n options_metadata=[MODELS_METADATA[key] for key in sorted(MODELS_METADATA.keys())]\n + [{\"icon\": \"brain\"}],\n )\n build_config.update({\"agent_llm\": custom_component.to_dict()})\n # Update input types for all fields\n build_config = self.update_input_types(build_config)\n\n # Validate required keys\n default_keys = [\n \"code\",\n \"_type\",\n \"agent_llm\",\n \"tools\",\n \"input_value\",\n \"add_current_date_tool\",\n \"system_prompt\",\n \"agent_description\",\n \"max_iterations\",\n \"handle_parsing_errors\",\n \"verbose\",\n ]\n missing_keys = [key for key in default_keys if key not in build_config]\n if missing_keys:\n msg = f\"Missing required keys in build_config: {missing_keys}\"\n raise ValueError(msg)\n if (\n isinstance(self.agent_llm, str)\n and self.agent_llm in MODEL_PROVIDERS_DICT\n and field_name in MODEL_DYNAMIC_UPDATE_FIELDS\n ):\n provider_info = MODEL_PROVIDERS_DICT.get(self.agent_llm)\n if provider_info:\n component_class = provider_info.get(\"component_class\")\n component_class = self.set_component_params(component_class)\n prefix = provider_info.get(\"prefix\")\n if component_class and hasattr(component_class, \"update_build_config\"):\n # Call each component class's update_build_config method\n # remove the prefix from the field_name\n if isinstance(field_name, str) and isinstance(prefix, str):\n field_name = field_name.replace(prefix, \"\")\n build_config = await update_component_build_config(\n component_class, build_config, field_value, \"model_name\"\n )\n return dotdict({k: v.to_dict() if hasattr(v, \"to_dict\") else v for k, v in build_config.items()})\n\n async def _get_tools(self) -> list[Tool]:\n component_toolkit = _get_component_toolkit()\n tools_names = self._build_tools_names()\n agent_description = self.get_tool_description()\n # TODO: Agent Description Depreciated Feature to be removed\n description = f\"{agent_description}{tools_names}\"\n tools = component_toolkit(component=self).get_tools(\n tool_name=\"Call_Agent\", tool_description=description, callbacks=self.get_langchain_callbacks()\n )\n if hasattr(self, \"tools_metadata\"):\n tools = component_toolkit(component=self, metadata=self.tools_metadata).update_tools_metadata(tools=tools)\n return tools\n"
},
"handle_parsing_errors": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Provider list duplicated across three embedded AgentComponent classes.

MODEL_PROVIDERS_LIST = [...] now appears verbatim in every agent stub.
This violates DRY, risks future divergence, and bloats the starter-project JSON.

Recommend importing the canonical list from langflow.base.models.model_input_constants (or a new central helper) instead of redefining it locally.

Also applies to: 2379-2381, 2923-2925

🤖 Prompt for AI Agents
In src/backend/base/langflow/initial_setup/starter_projects/Travel Planning
Agents.json around lines 1835 to 1837, the MODEL_PROVIDERS_LIST is duplicated
verbatim in multiple AgentComponent classes, violating DRY principles and
risking inconsistencies. To fix this, remove the local definition of
MODEL_PROVIDERS_LIST and instead import it from
langflow.base.models.model_input_constants or a centralized helper module. Apply
the same fix to the other occurrences at lines 2379-2381 and 2923-2925 to ensure
a single source of truth for the provider list.

Comment on lines +100 to +110
def build_model(self) -> LanguageModel: # type: ignore[type-var]
logger.debug(f"Executing request with model: {self.model_name}")
parameters = {
"api_key": SecretStr(self.api_key).get_secret_value() if self.api_key else None,
"model_name": self.model_name,
"max_tokens": self.max_tokens or None,
"model_kwargs": self.model_kwargs or {},
"base_url": "https://api.cerebras.ai/v1",
"max_retries": self.max_retries,
"timeout": self.timeout,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use the API base input field instead of hard-coded URL.

The method hard-codes the base_url but ignores the Cerebras_api_base input field that allows users to customize the API endpoint.

         parameters = {
             "api_key": SecretStr(self.api_key).get_secret_value() if self.api_key else None,
             "model_name": self.model_name,
             "max_tokens": self.max_tokens or None,
             "model_kwargs": self.model_kwargs or {},
-            "base_url": "https://api.cerebras.ai/v1",
+            "base_url": self.cerebras_api_base if hasattr(self, 'cerebras_api_base') and self.cerebras_api_base else "https://api.cerebras.ai/v1",
             "max_retries": self.max_retries,
             "timeout": self.timeout,
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def build_model(self) -> LanguageModel: # type: ignore[type-var]
logger.debug(f"Executing request with model: {self.model_name}")
parameters = {
"api_key": SecretStr(self.api_key).get_secret_value() if self.api_key else None,
"model_name": self.model_name,
"max_tokens": self.max_tokens or None,
"model_kwargs": self.model_kwargs or {},
"base_url": "https://api.cerebras.ai/v1",
"max_retries": self.max_retries,
"timeout": self.timeout,
}
def build_model(self) -> LanguageModel: # type: ignore[type-var]
logger.debug(f"Executing request with model: {self.model_name}")
parameters = {
"api_key": SecretStr(self.api_key).get_secret_value() if self.api_key else None,
"model_name": self.model_name,
"max_tokens": self.max_tokens or None,
"model_kwargs": self.model_kwargs or {},
"base_url": self.cerebras_api_base if hasattr(self, 'cerebras_api_base') and self.cerebras_api_base else "https://api.cerebras.ai/v1",
"max_retries": self.max_retries,
"timeout": self.timeout,
}
🤖 Prompt for AI Agents
In src/backend/base/langflow/components/cerebras/cerebras_chat_models.py around
lines 100 to 110, the build_model method currently hard-codes the base_url to
"https://api.cerebras.ai/v1". To fix this, replace the hard-coded string with
the value from the Cerebras_api_base input field so that users can customize the
API endpoint. Ensure that the base_url parameter uses this input field instead
of a fixed URL.

Comment on lines +710 to +711
flows = (await session.exec(select(Flow))).all()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Filter flows by project_id to prevent cross-project resource leakage.

The current implementation queries all flows in the database without filtering by project. This could expose resources from other projects.

-                    flows = (await session.exec(select(Flow))).all()
+                    flows = (await session.exec(select(Flow).where(Flow.folder_id == self.project_id))).all()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
flows = (await session.exec(select(Flow))).all()
flows = (await session.exec(
- select(Flow)
+ select(Flow).where(Flow.folder_id == self.project_id)
)).all()
🤖 Prompt for AI Agents
In src/backend/base/langflow/api/v1/mcp_projects.py around lines 710 to 711, the
query fetching flows retrieves all flows without filtering by project_id,
risking cross-project data exposure. Modify the select statement to include a
filter condition that restricts flows to those matching the current project_id,
ensuring only flows belonging to the specific project are returned.

Comment on lines +788 to +792
flow = await get_flow_snake_case(name, current_user.id, session, is_action=True)
if not flow:
msg = f"Flow with name '{name}' not found"
raise ValueError(msg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add project validation to ensure the flow belongs to the current project.

The flow is retrieved by name and user ID, but there's no validation that it belongs to the current project context.

                 flow = await get_flow_snake_case(name, current_user.id, session, is_action=True)
                 if not flow:
                     msg = f"Flow with name '{name}' not found"
                     raise ValueError(msg)
+                # Validate flow belongs to current project
+                if flow.folder_id != self.project_id:
+                    msg = f"Flow '{name}' does not belong to the current project"
+                    raise ValueError(msg)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
flow = await get_flow_snake_case(name, current_user.id, session, is_action=True)
if not flow:
msg = f"Flow with name '{name}' not found"
raise ValueError(msg)
flow = await get_flow_snake_case(name, current_user.id, session, is_action=True)
if not flow:
msg = f"Flow with name '{name}' not found"
raise ValueError(msg)
# Validate flow belongs to current project
if flow.folder_id != self.project_id:
msg = f"Flow '{name}' does not belong to the current project"
raise ValueError(msg)
🤖 Prompt for AI Agents
In src/backend/base/langflow/api/v1/mcp_projects.py around lines 788 to 792,
after retrieving the flow by name and user ID, add a validation step to check if
the flow belongs to the current project context. If the flow's project ID does
not match the current project ID, raise an appropriate error to prevent
unauthorized access or operations on flows outside the current project.

try:
db_service = get_db_service()
async with db_service.with_session() as session:
flows = (await session.exec(select(Flow))).all()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security: Filter flows by current user to prevent cross-user tool exposure.

Similar to the resources handler, this queries all flows without user filtering.

-            flows = (await session.exec(select(Flow))).all()
+            current_user = current_user_ctx.get()
+            flows = (await session.exec(select(Flow).where(Flow.user_id == current_user.id))).all()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
flows = (await session.exec(select(Flow))).all()
current_user = current_user_ctx.get()
flows = (
await session.exec(
select(Flow).where(Flow.user_id == current_user.id)
)
).all()
🤖 Prompt for AI Agents
In src/backend/base/langflow/api/v1/mcp.py at line 182, the query fetching flows
does not filter by the current user, risking exposure of flows across users.
Modify the select statement to include a filter condition that restricts flows
to those owned by or associated with the current user, ensuring only their flows
are returned.

base_url = f"http://{host}:{port}".rstrip("/")

async with db_service.with_session() as session:
flows = (await session.exec(select(Flow))).all()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security: Filter flows by current user to prevent cross-user data exposure.

The current implementation queries all flows without user filtering, potentially exposing resources from other users.

-            flows = (await session.exec(select(Flow))).all()
+            current_user = current_user_ctx.get()
+            flows = (await session.exec(select(Flow).where(Flow.user_id == current_user.id))).all()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
flows = (await session.exec(select(Flow))).all()
current_user = current_user_ctx.get()
flows = (await session.exec(select(Flow).where(Flow.user_id == current_user.id))).all()
🤖 Prompt for AI Agents
In src/backend/base/langflow/api/v1/mcp.py at line 111, the query fetching flows
does not filter by the current user, risking exposure of other users' data.
Modify the query to include a filter condition that restricts the results to
flows owned by the current authenticated user, ensuring only their flows are
returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant