Added Celebras LLM Provider into Agent and LanguageTool Tab#9106
Added Celebras LLM Provider into Agent and LanguageTool Tab#9106MeetSolanki530 wants to merge 2 commits into
Conversation
WalkthroughThis 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
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
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
|
Added Celebras Cloud LLM Provider in langflow |
There was a problem hiding this comment.
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_llmdropdown is out-of-sync with the runtime provider listThe runtime code adds
"🧠 Cerebras"toMODEL_PROVIDERS_LIST, yet the static dropdown options/metadata here were not updated.
Result: the UI never shows the new provider, andself.agent_llmcan 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" } // CustomPlease update both
optionsandoptions_metadatato 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 inMODEL_PROVIDERS_DICT.
MODEL_PROVIDERS_LISTis 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 toMODEL_PROVIDERS_DICT, any selection of “🧠 Cerebras” will returnNone, raisingInvalid 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_DICTis exactly"Cerebras".
1446-1455:agent_llmdropdown rendered list is now out-of-sync withMODEL_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_metadatafor 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 throwInvalid model providerat runtime. Change all occurrences of"🧠 Cerebras"to"Cerebras"where it’s used as a provider key or dropdown option, and keep the brain icon inoptions_metadataonly.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 == …andelif 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
iconfields underoptions_metadata.src/backend/base/langflow/initial_setup/starter_projects/Price Deal Finder.json (1)
1775-1785: Include “🧠 Cerebras” in the static dropdown and fix spacingThe backend’s
MODEL_PROVIDERS_LISTnow 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_LISTin the embeddedAgentComponentcode now contains"🧠 Cerebras", yet the template’sagent_llmDropdownInput.optionsstill 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 UIThe
agent_llmtemplate 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_llmdropdown 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_llmwill 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_metadatawith 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 metadataI’ve confirmed that
MODELS_METADATAalready 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 theagent_llmblock:• Add
"🧠 Cerebras"tooptionsbefore"Custom"
• Add{ "icon": "🧠" }tooptions_metadatabefore 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” missingThe
providertemplate shown to the front-end still exposes onlyOpenAI,Anthropic,
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 identifierThe 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_metadataif you want it purely for UI display ({"icon": "brain-circuit"}), but make the logical identifier text-only.
2626-2635: GuardChatCerebrasimport and surface clear error when missingThe unguarded
from langchain_cerebras import ChatCerebrasbreaks installs without that package. Please:• Wrap the import in both
src/backend/base/langflow/components/models/language_model.pysrc/backend/base/langflow/components/cerebras/cerebras_chat_models.py
in atry/except ModuleNotFoundErrorand setChatCerebras = None.
• Inbuild_model, before usingChatCerebras, check if it’sNoneand raise aValueErrorinstructing 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: Addlangchain-cerebrasto runtime dependenciesThe 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 raiseModuleNotFoundErrorat runtime unless the package is pre-installed.
- Verify whether
langflowalready vendors this extra; otherwise add:langchain-cerebras>=0.1.0 # exact version as needed
1564-1570: Template JSON still lists only three providersFurther down in the same node’s JSON (
provider.optionsarray) 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 theprovider.optionsarray 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.optionsarray still lists only"OpenAI", "Anthropic", "Google", andoptions_metadatahas 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
LanguageModelComponentcode now exposes"🧠 Cerebras"in theproviderDropdownInput, 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 configThe 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.optionsdefines the provider as"🧠 Cerebras".
The backend normally treats provider IDs as ASCII labels (e.g."OpenAI","Anthropic"). Introducing the emoji inside the value:
- Makes equality checks fragile (
self.provider == "🧠 Cerebras"must be used everywhere).- Breaks existing analytics / telemetry that assume plain-text provider names.
- Leaks a UI concern (iconography) into data / logic layers.
Recommend keeping the data value text-only (
"Cerebras") and convey the emoji purely throughoptions_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
TheChatCerebrasmodel uses a Pydantic field namedcerebras_api_key(and reads from theCEREBRAS_API_KEYenv var). Passingapi_key=…will be ignored or raise aTypeError. 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, whereChatCerebrasis 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_keyand does not acceptapi_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
LanguageModelComponentnode in this starter project.
1495-1659: Three identical embedded component definitions – centralise to avoid drift.The full
LanguageModelComponentsource 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 keepapi_keyin ChatCerebras constructorThe import of
ChatCerebrasrequires addinglangchain_cerebrasto your project’s runtime requirements. The suggestion to switch the constructor kw-arg tocerebras_api_keyis incorrect—ChatCerebrasacceptsapi_key, notcerebras_api_key.• Ensure you list
langchain_cerebrasin your runtime requirements (e.g.requirements.txtor anextras/cerebrasentry).
• Insrc/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 selectedThe 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
LanguageModelComponentnodes 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_metadataexpects 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 correctapi_keyusageThe
ChatCerebrasclass does indeed acceptapi_key(notcerebras_api_key), so your constructor call is correct. However, becauselangchain_cerebrasisn’t included in the standard LangChain extras, you should:
- Add
langchain-cerebrasto your project’s requirements (e.g.requirements.txtorpyproject.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_LISTnow contains"🧠 Cerebras", but theagent_llmdropdown (template.agent_llm.options) still exposes onlyAnthropic,Google Generative AI,Groq, andOpenAI.
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_metadatato keep indices aligned.
2550-2580: Provider dropdown ofLanguageModelComponentnot updatedThe backend code supports
"🧠 Cerebras"(import + build-logic), but the template forLanguageModelComponent-Ln5SKandLanguageModelComponent-7h76Hstill lists onlyOpenAI | Anthropic | Google.
End-users therefore cannot trigger the Cerebras branch and will hit the"Unknown provider"fallback.Same fix pattern as above – add
"🧠 Cerebras"totemplate.provider.optionsand extendoptions_metadatawith 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 & constructorThe import
from langchain_cerebras import ChatCerebrasfails withModuleNotFoundError. 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
)
• Inbuild_model, adjust the instantiation to match the actual signature (e.g. renameapi_key=self.api_keytocerebras_api_key=self.api_keyor 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_LISTupdated but front-end dropdown still misses “🧠 Cerebras”.The class–level
MODEL_PROVIDERS_LISTnow includes the new provider, yet theagent_llmDropdownInputdeclared 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:LanguageModelprovider dropdown out of sync with codeThe template stanza for
providerstill lists onlyOpenAI | Anthropic | Google.
Becauseupdate_build_configrelies 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 dependenciesThe
langchain_cerebrasimport is unconditional, so you must declare it in your dependency files to avoid runtime errors. The existing use ofapi_keyis correct per the currentChatCerebrassignature.• In your dependency manifest (e.g. pyproject.toml, requirements.txt), add:
+# Add Cerebras support +langchain-cerebras>=0.5.0src/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 CerebrasThe serialized node (
template.provider.options) only listsOpenAI,Anthropic,
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 checksYou chose
"🧠 Cerebras"as the provider token and used a raw emoji ("🧠") as icon metadata.
Down-stream comparisons (if provider == "🧠 Cerebras":) work, but:
- Emojis can be lost during serialisation in some DBs / JSON viewers.
- 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) inoptions_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 forlangchain-cerebras
ChatCerebrasis imported fromlangchain_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
Theproviderdropdown that the Playground actually renders still lists onlyOpenAI | 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_metadatawith a proper icon entry.
2130-2142: Agent component suffers from the same UI / backend mismatch
MODEL_PROVIDERS_LIST(backend) contains “🧠 Cerebras” but theagent_llmdropdown in this JSON block does not.
Failure path: user selects Cerebras in future UI →self.agent_llm == "🧠 Cerebras"butMODEL_PROVIDERS_DICThas no matching key → runtimeValueError.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 coherenceEvery 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_DICTlook-ups to fail.- The Agent component not finding the Cerebras entry.
Prefer a plain key (
"Cerebras") and keep the emoji for display purposes viaoptions_metadata.
2695-2705: Same UI desync in Agent component
MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"]But the
agent_llmdropdown (lines 2624-2633) still lacks Cerebras – users can’t select it →get_llm()will raise Invalid model provider.Bring the dropdown’s
options/options_metadatain line withMODEL_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 deduplicateThe 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 commentSame 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 LanguageModelComponentThis 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 earlierChatCerebrasimport / 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
LanguageModelComponentnode repeats the entire class definition with the same potential issues (import path,api_keykwarg, 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 secondLanguageModelComponentblockThe 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.gitignoreplacement – pattern likely misses the real database fileA
.gitignoreinsidesrc/backend/base/langflow/only ignoreslangflow.dbif 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:
- Confirm where
langflow.dbis produced.- 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.dbThen delete
src/backend/base/langflow/.gitignoreentirely.src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (2)
1454-1469: Missing icon metadata for the new provider.
options_metadatacurrently 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_LISTnow 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 fromMODEL_PROVIDERS_LISTat 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 fromMODEL_PROVIDERS_DICTinstead.
MODEL_PROVIDERS_LIST = ["Anthropic", "Google Generative AI", "Groq", "OpenAI", "🧠 Cerebras"]hard-codes the same info already present inMODEL_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 listsTwo tiny but recurring spacing glitches slipped in with the Cerebras addition:
from langflow.base.models.cerebras_constants import CEREBRAS_CHAT_MODEL_NAMES,CEREBRAS_REASONING_MODEL_NAMESoptions=[\"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_metadatauses{ "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 importfrom 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 useOpenAI,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 listPython 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_metadatauses{"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 constantPROVIDER_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_NAMESMinor, but the missing space after the comma hurts readability and fails most linters.
4649-4662: Duplicated provider logic – consider mapping table
build_modelnow contains four near-identicalif 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_metadatacurrently sets{"icon": "🧠"}. Front-end icon maps expect symbolic names (e.g.Cerebras,BrainCircuit) defined inicons.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 divergenceIdentical
LanguageModelComponentcode 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_NAMESis 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 fordisplay_name/icon.src/backend/base/langflow/initial_setup/starter_projects/Research Agent.json (1)
2323-2333: Duplicate block – keep one source of truthThe full
LanguageModelComponentsource 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: Useisoperator for boolean comparisons to avoid linting warnings.The direct boolean comparison triggers E712 linting warnings. Use the
isoperator 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: Useisoperator 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)
| 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"]) |
There was a problem hiding this comment.
🛠️ 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.
| 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 |
There was a problem hiding this comment.
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.
| 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") |
There was a problem hiding this comment.
💡 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 -10Length 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.
| 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 |
There was a problem hiding this comment.
💡 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 pyLength 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.
| "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": { |
There was a problem hiding this comment.
🛠️ 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.
| 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, | ||
| } |
There was a problem hiding this comment.
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.
| 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.
| flows = (await session.exec(select(Flow))).all() | ||
|
|
There was a problem hiding this comment.
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.
| 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.
| 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) | ||
|
|
There was a problem hiding this comment.
🛠️ 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.
| 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() |
There was a problem hiding this comment.
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.
| 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() |
There was a problem hiding this comment.
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.
| 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.
Added Celebras Cloud LLM Provider in langflow
https://www.cerebras.ai/
Summary by CodeRabbit
New Features
Improvements
Refactor
Chores