refactor(setup): generalize tool/agent node logic and update starter templates#8618
Conversation
….com/langflow-ai/langflow into fix-gmail-custom-component-templates
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis update broadens the logic for identifying "tool or agent" nodes in the setup script and significantly restructures the starter project JSON templates. The starter projects now use a generalized Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ChatInput
participant LanguageModelComponent
participant Memory
participant Prompt
participant Output
User->>ChatInput: Submit message (with metadata)
ChatInput->>Memory: Store/retrieve session data
ChatInput->>Prompt: Forward message
Prompt->>LanguageModelComponent: Format and send prompt
LanguageModelComponent->>LanguageModelComponent: Select provider (OpenAI/Anthropic/Google)
LanguageModelComponent->>Output: Return model response
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
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (7)
src/backend/base/langflow/initial_setup/setup.py (1)
69-72: Extract agent keys into a constant for clarity
The inline set of agent identifiers ({"Agent", "LanguageModelComponent"}) is better defined as a module-level constant (e.g. AGENT_COMPONENT_KEYS) to improve readability and simplify future updates.src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (5)
9-15: Normalize React Flow handle encoding
The embedded handle metadata uses non-standard delimiters (œ) which may complicate parsing or serialization. Consider switching to a JSON-stringified, URL-safe format (e.g. Base64 orencodeURIComponent(JSON.stringify(...))) forid,sourceHandle, andtargetHandleto improve compatibility and maintainability.Also applies to: 17-24, 25-31
385-393: MessagetoDataComponent metadata check
The component is markedlegacy = true(line 402) andbeta = true(line 390). Decide if both flags are necessary or if one should be retired to reduce confusion.Also applies to: 402-410, 412-414
508-510: Optional: Exposeclean_dataearlier
Adding"clean_data"to theChatOutputfield_orderenables post-processing controls—consider surfacing this toggle in theChatInputtemplate as well or providing a default in the top-level project settings for consistency.
1449-1457: Refactor TypeConverterComponent inputs/outputs
The newTypeConverterComponentis a great abstraction. For clarity, you might:
- Rename
HandleInput.namefrom"input_data"to"value"to match other components.- Dynamically adjust output tab titles to include types for UI clarity.
Also applies to: 1474-1480, 1492-1500
1576-1581: LanguageModelComponent provider options
The generalized model node now supports OpenAI, Anthropic, and Google—excellent. Check that theoptions_metadataicons (line 1746–1759) map correctly to each provider in the UI, and consider sorting providers alphabetically or by usage frequency.Also applies to: 1585-1585, 1590-1597
src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json (1)
702-705: Node update: Chat Output – addedclean_datainput
A new booleanclean_datafield is now included in the ChatOutput’sfield_orderand template. This aligns with the component’s_validate_inputandconvert_to_stringlogic. Consider renaming the display name to “Clean Data” for clarity.Also applies to: 710-710
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/backend/base/langflow/initial_setup/setup.py(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json(24 hunks)src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json(28 hunks)src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json(58 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (37)
src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json (11)
9-14: Approve ChatInput→Prompt edge update
The edge correctly maps theChatInputoutputmessageto the Prompt node’sUSER_INPUTfield with consistent IDs and handle metadata.Also applies to: 17-18, 26-31
38-43: Approve Memory→Prompt edge update
The edge seamlessly routesMemory’smessages_textoutput to the Prompt node’sCHAT_HISTORYfield, with matching IDs and types.Also applies to: 46-52, 55-55, 57-60
68-72: Approve URL→Prompt (EXAMPLE_COMPONENTS) edge
The URL node’sraw_resultsis correctly wired into the Prompt’sEXAMPLE_COMPONENTSinput, maintaining handle consistency.Also applies to: 75-82, 84-84, 86-89
96-98: Approve URL→Prompt (CUSTOM_COMPONENT_CODE) edge
The mapping from the URL node to theCUSTOM_COMPONENT_CODEplaceholder in Prompt is properly defined.Also applies to: 104-109, 113-113, 115-118
125-131: Approve URL→Prompt (BASE_COMPONENT_CODE) edge
The edge linkingraw_resultstoBASE_COMPONENT_CODEis accurate and consistent with the updated Prompt schema.Also applies to: 133-138, 142-147
154-156: Approve Prompt→LanguageModelComponent edge
The Prompt node’spromptoutput is correctly delivered to the LanguageModelComponent’sinput_valuefield.Also applies to: 162-166, 170-170, 172-175
178-179: Approve LanguageModelComponent→ChatOutput edge
LanguageModelComponent’stext_outputis properly routed into the ChatOutput component’sinput_valuehandle with matching types.Also applies to: 182-187, 190-196, 200-205
213-213: Approve Memory node defaults
Setting"selected_output": "messages_text"ensures the default output is the text representation, aligning with the node’s purpose.Also applies to: 509-511
535-536: Approve Prompt node defaults
The Prompt node’s ID and"selected_output": "prompt"are correctly configured to use the built prompt as the default output.Also applies to: 759-761
1922-1922: Approve ChatInput node metadata
The ChatInput component’scategory,description, anddisplay_nameupdates align with the new generalized input schema.Also applies to: 1928-1928, 1931-1932
2545-2550: Approve LanguageModelComponent node definition
The newLanguageModelComponentnode is correctly introduced with appropriate base_classes, category “models”, descriptive metadata, and the expandedfield_orderfor multi-provider support.Also applies to: 2552-2552, 2555-2556, 2560-2567
src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (8)
37-43: Verify DataFrame edgetypeconsistency
The edge fromArXivComponenttoLoopComponentis marked with"type": "other", yet it carries aDataFrame. Confirm that downstream consumers expect"other"for DataFrame flows or align this with a dedicated"dataframe"type for clarity.Also applies to: 45-51, 53-59
65-71: Approve loop‐to‐parser multi‐type connection
TheLoopComponentnow outputsDataitems and feeds them intoParserComponentwhich accepts bothDataFrameandData—this is correctly represented ininputTypes. Good catch on broadening parser compatibility.Also applies to: 73-80, 82-88
94-100: Expand classification for new tool components
Introducing theMessagetoData→LoopComponentedge impliesMessagetoDatais now treated as a tool/agent. Ensure thesetup.pylogic that classifies nodes as tools or agents has been updated to includeMessagetoData.Also applies to: 102-108, 110-116
122-128: Include TypeConverter in tool detection
The loop’s “done” output now flows intoTypeConverterComponent. Confirm that your initial setup script (setup.py) detectsTypeConverterComponentas a processing node and not mistakenly skips it.Also applies to: 130-136, 140-146
152-158: Validate ChatOutput connection from TypeConverter
TheTypeConverterComponent→ChatOutputedge correctly unifies message types, but double-check thatChatOutputhandlesDataFrameandDataorigins viaHandleInput. If necessary, explicitly list those ininputTypes.Also applies to: 160-168, 170-176
181-187: Parser → LanguageModel flow approved
The new edge fromParserComponentintoLanguageModelComponentis consistent:ParserComponentemitsMessage, and the model’sinput_valueexpectsMessage. Implementation matches the generalized multi-provider LLM design.Also applies to: 189-196, 197-201
205-213: LanguageModel → MessagetoData loop verified
Chaining theLanguageModelComponentoutput back intoMessagetoDatamaintains a clean translation loop. ThefieldName: "message"and types align correctly with the converter’s signature.Also applies to: 216-222, 224-228
235-243: Review ArXivComponent default parameters
- The
max_resultsdefault is now3(line 303), down from10. Confirm this change aligns with user expectations.- Toggling
tool_modeoff onsearch_type(line 358) may hide this input in tool flows; ensure that’s intended.Also applies to: 303-303, 358-358, 367-367, 371-371, 373-373
src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json (18)
9-31: Edge refactoring: TextInput → Prompt mapping updated
The source and target handle IDs (TextInput-i5Z2Y,Prompt-JXzxV) and types ("Message") have been refreshed to match the new node identifiers and output/Input types. All references look consistent, but verify that no stale IDs remain elsewhere.
36-59: Edge refactoring: Output Format TextInput → Prompt mapping updated
The second TextInput node (TextInput-OAt8o) now correctly feeds into the same Prompt node with updated IDs and"Message"types. Ensure this edge aligns with the newCONTENT_GUIDELINESpattern and the Prompt’scustom_fields.
64-87: Edge refactoring: Output Language TextInput → Prompt mapping updated
TextInput-58oH9has been reconnected toPrompt-JXzxV, standardizing on"Message"for inputs. Confirm that the Prompt template’s variable list still coversOUTPUT_LANGUAGE.
93-115: Edge refactoring: Profile Details TextInput → Prompt mapping updated
TextInput-3nKXgnow targets the unified Prompt node. Input types and IDs are aligned. Validate thatPROFILE_DETAILSis still included in the Prompt’stemplatefields.
120-142: Edge refactoring: Profile Type TextInput → Prompt mapping updated
TextInput-MlxGCis wired intoPrompt-JXzxVwith the new identifier and"Message"type. No missing connections detected.
149-171: Edge refactoring: Tone And Style TextInput → Prompt mapping updated
TextInput-rIJMYmappings are consistent with the other TextInput edges. ThefieldNameremainsTONE_AND_STYLEand input type"Message".
173-181: Edge refactoring: Prompt → LanguageModelComponent connection
The Prompt node now outputspromptto thesystem_messageinput ofLanguageModelComponent-URKKz. IDs and types align ("Message"), supporting the new component.
200-207: Edge refactoring: ChatInput → LanguageModelComponent input wiring
ChatInput-JpNZbnow feeds intoLanguageModelComponent-URKKzviainput_value. Check thatChatInputoutputs remainMessageand match the component’s expected input types.
227-245: Edge refactoring: LanguageModelComponent → ChatOutput mapping
The language model’stext_outputnow properly connects toChatOutput-GgTGu’sinput_value, with input types expanded to[Data, DataFrame, Message]. Confirmsafe_convertin ChatOutput handles these types.
259-269: Node update: Chat Input minimization & UI fields
The ChatInput node has been minimized by default ("minimized": true) and now hides advanced controls (tool_mode:false). The newlist_add_labelandtool_modeflags are consistent.Also applies to: 286-286, 318-318, 324-324
575-587: Node update: Content Guidelines TextInput ID bump
TextInput-i5Z2Yhas been re-generated with an updated ID and retains its base classes and template code. No broken references detected.Also applies to: 661-661
1582-1584: Node update: Prompt – addedtool_placeholderinput
The Prompt node’sfield_ordernow includestool_placeholderand the node is no longer minimized by default. The code template reflects this input.Also applies to: 1589-1589
1618-1620: Node update: Prompt input types standardized
All Prompt template inputs now uniformly accept"Message". This removes legacy"Text"types and simplifies processing.
1837-1849: Node update: LanguageModelComponent metadata & inputs
The LanguageModelComponent’s description, display name, icon, andfield_orderhave been generalized to support multiple providers (provider,model_name,api_key,stream,temperature). Structure looks correct.
1898-1914: Template tweak:api_keyinput field refined
TheSecretStrInputforapi_keynow carries generic info"Model Provider API key"andreal_time_refresh:true. Confirm that build configs correctly update its display name per provider selection.
1916-1971: Code update: LanguageModelComponent implementation refreshed
The Python code now dynamically dispatches to ChatOpenAI, ChatAnthropic, or ChatGoogleGenerativeAI based onprovider. Error messages for missing API keys are clear. Ensure unit tests cover each branch.
1934-1987: Template inputs: align component inputs with code logic
Fieldsinput_value,model_name,provider,stream,system_message, andtemperaturehave matching_input_type, names, and defaults. Themodel_namedropdown no longer usescombobox, which simplifies UI.
2098-2100: UI flag: LanguageModelComponent is visible (showNode:true)
Ensures the component appears in the flow palette. This matches its central role.
…langflow into fic-llm-reset-issue
…templates (langflow-ai#8618) * update several templates * updated templates * change custom component maker * Update Twitter Thread Generator.json * updates from main * llm reset issue * Update setup.py * Update Custom Component Maker.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * udpate templates * [autofix.ci] apply automated fixes * Update setup.py * Update Custom Component Maker.json * [autofix.ci] apply automated fixes * Update Custom Component Maker.json * text fixes --------- Co-authored-by: Yuqi Tang <yuqi.tang@datastax.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Mike Fortman <michael.fortman@datastax.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
…templates (langflow-ai#8618) * update several templates * updated templates * change custom component maker * Update Twitter Thread Generator.json * updates from main * llm reset issue * Update setup.py * Update Custom Component Maker.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * udpate templates * [autofix.ci] apply automated fixes * Update setup.py * Update Custom Component Maker.json * [autofix.ci] apply automated fixes * Update Custom Component Maker.json * text fixes --------- Co-authored-by: Yuqi Tang <yuqi.tang@datastax.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Mike Fortman <michael.fortman@datastax.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Summary by CodeRabbit
New Features
Improvements
Bug Fixes