Skip to content

refactor(setup): generalize tool/agent node logic and update starter templates#8618

Merged
edwinjosechittilappilly merged 32 commits into
mainfrom
fic-llm-reset-issue
Jun 20, 2025
Merged

refactor(setup): generalize tool/agent node logic and update starter templates#8618
edwinjosechittilappilly merged 32 commits into
mainfrom
fic-llm-reset-issue

Conversation

@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Jun 18, 2025

Summary by CodeRabbit

  • New Features

    • Starter projects now include a unified Language Model component supporting OpenAI, Anthropic, and Google providers, allowing flexible model selection and configuration.
    • Added new components for message-to-data conversion and type conversion, enhancing data flow and modularity in project templates.
  • Improvements

    • Updated ChatInput and ChatOutput components with enhanced input fields and options, including data cleaning and file support.
    • Refined prompt templates and data connections for improved workflow clarity and flexibility across starter projects.
  • Bug Fixes

    • Adjusted node classification logic to better recognize tool and agent components, ensuring correct behavior in project flows.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 18, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This 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 LanguageModelComponent supporting multiple providers, updated node IDs, revised data flows, and new or modified component definitions for chat, memory, prompt, and type conversion.

Changes

File(s) Change Summary
src/backend/base/langflow/initial_setup/setup.py Expanded the condition for identifying "tool or agent" nodes to include those with the key "LanguageModelComponent" in addition to "Agent" and nodes with tool_mode set to True.
src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json Replaced Anthropic/TypeConverter components with new ChatInput and LanguageModelComponent supporting multiple providers; updated node IDs, edge connections, data types, and field names; revised memory, prompt, and URL components; incremented version to 1.4.3.
src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json Replaced Anthropic model with new MessagetoData, TypeConverterComponent, and provider-agnostic LanguageModelComponent; updated node IDs, edges, and data types; revised parser, loop, chat input/output components; incremented version to 1.4.3.
src/backend/base/langflow/initial_setup/starter_projects/Twitter Thread Generator.json Replaced OpenAI-specific model with generalized LanguageModelComponent supporting multiple providers; updated node IDs, edges, and input/output field names; revised prompt and chat components; incremented version to 1.4.3.

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
Loading

Suggested labels

refactor, lgtm

Suggested reviewers

  • ogabrielluiz
  • mfortman11
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch fic-llm-reset-issue

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.

@edwinjosechittilappilly edwinjosechittilappilly marked this pull request as ready for review June 18, 2025 14:33
@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jun 18, 2025
@coderabbitai coderabbitai Bot changed the title @coderabbitai refactor(setup): generalize tool/agent node logic and update starter templates Jun 18, 2025
@github-actions github-actions Bot added the refactor Maintenance tasks and housekeeping label Jun 18, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 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 or encodeURIComponent(JSON.stringify(...))) for id, sourceHandle, and targetHandle to improve compatibility and maintainability.

Also applies to: 17-24, 25-31


385-393: MessagetoDataComponent metadata check
The component is marked legacy = true (line 402) and beta = 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: Expose clean_data earlier
Adding "clean_data" to the ChatOutput field_order enables post-processing controls—consider surfacing this toggle in the ChatInput template as well or providing a default in the top-level project settings for consistency.


1449-1457: Refactor TypeConverterComponent inputs/outputs
The new TypeConverterComponent is a great abstraction. For clarity, you might:

  • Rename HandleInput.name from "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 the options_metadata icons (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 – added clean_data input
A new boolean clean_data field is now included in the ChatOutput’s field_order and template. This aligns with the component’s _validate_input and convert_to_string logic. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d34bc3 and e6991c1.

📒 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 the ChatInput output message to the Prompt node’s USER_INPUT field with consistent IDs and handle metadata.

Also applies to: 17-18, 26-31


38-43: Approve Memory→Prompt edge update
The edge seamlessly routes Memory’s messages_text output to the Prompt node’s CHAT_HISTORY field, 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’s raw_results is correctly wired into the Prompt’s EXAMPLE_COMPONENTS input, 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 the CUSTOM_COMPONENT_CODE placeholder 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 linking raw_results to BASE_COMPONENT_CODE is accurate and consistent with the updated Prompt schema.

Also applies to: 133-138, 142-147


154-156: Approve Prompt→LanguageModelComponent edge
The Prompt node’s prompt output is correctly delivered to the LanguageModelComponent’s input_value field.

Also applies to: 162-166, 170-170, 172-175


178-179: Approve LanguageModelComponent→ChatOutput edge
LanguageModelComponent’s text_output is properly routed into the ChatOutput component’s input_value handle 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’s category, description, and display_name updates align with the new generalized input schema.

Also applies to: 1928-1928, 1931-1932


2545-2550: Approve LanguageModelComponent node definition
The new LanguageModelComponent node is correctly introduced with appropriate base_classes, category “models”, descriptive metadata, and the expanded field_order for 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 edge type consistency
The edge from ArXivComponent to LoopComponent is marked with "type": "other", yet it carries a DataFrame. 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
The LoopComponent now outputs Data items and feeds them into ParserComponent which accepts both DataFrame and Data—this is correctly represented in inputTypes. Good catch on broadening parser compatibility.

Also applies to: 73-80, 82-88


94-100: Expand classification for new tool components
Introducing the MessagetoDataLoopComponent edge implies MessagetoData is now treated as a tool/agent. Ensure the setup.py logic that classifies nodes as tools or agents has been updated to include MessagetoData.

Also applies to: 102-108, 110-116


122-128: Include TypeConverter in tool detection
The loop’s “done” output now flows into TypeConverterComponent. Confirm that your initial setup script (setup.py) detects TypeConverterComponent as a processing node and not mistakenly skips it.

Also applies to: 130-136, 140-146


152-158: Validate ChatOutput connection from TypeConverter
The TypeConverterComponentChatOutput edge correctly unifies message types, but double-check that ChatOutput handles DataFrame and Data origins via HandleInput. If necessary, explicitly list those in inputTypes.

Also applies to: 160-168, 170-176


181-187: Parser → LanguageModel flow approved
The new edge from ParserComponent into LanguageModelComponent is consistent: ParserComponent emits Message, and the model’s input_value expects Message. Implementation matches the generalized multi-provider LLM design.

Also applies to: 189-196, 197-201


205-213: LanguageModel → MessagetoData loop verified
Chaining the LanguageModelComponent output back into MessagetoData maintains a clean translation loop. The fieldName: "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_results default is now 3 (line 303), down from 10. Confirm this change aligns with user expectations.
  • Toggling tool_mode off on search_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 new CONTENT_GUIDELINES pattern and the Prompt’s custom_fields.


64-87: Edge refactoring: Output Language TextInput → Prompt mapping updated
TextInput-58oH9 has been reconnected to Prompt-JXzxV, standardizing on "Message" for inputs. Confirm that the Prompt template’s variable list still covers OUTPUT_LANGUAGE.


93-115: Edge refactoring: Profile Details TextInput → Prompt mapping updated
TextInput-3nKXg now targets the unified Prompt node. Input types and IDs are aligned. Validate that PROFILE_DETAILS is still included in the Prompt’s template fields.


120-142: Edge refactoring: Profile Type TextInput → Prompt mapping updated
TextInput-MlxGC is wired into Prompt-JXzxV with the new identifier and "Message" type. No missing connections detected.


149-171: Edge refactoring: Tone And Style TextInput → Prompt mapping updated
TextInput-rIJMY mappings are consistent with the other TextInput edges. The fieldName remains TONE_AND_STYLE and input type "Message".


173-181: Edge refactoring: Prompt → LanguageModelComponent connection
The Prompt node now outputs prompt to the system_message input of LanguageModelComponent-URKKz. IDs and types align ("Message"), supporting the new component.


200-207: Edge refactoring: ChatInput → LanguageModelComponent input wiring
ChatInput-JpNZb now feeds into LanguageModelComponent-URKKz via input_value. Check that ChatInput outputs remain Message and match the component’s expected input types.


227-245: Edge refactoring: LanguageModelComponent → ChatOutput mapping
The language model’s text_output now properly connects to ChatOutput-GgTGu’s input_value, with input types expanded to [Data, DataFrame, Message]. Confirm safe_convert in 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 new list_add_label and tool_mode flags are consistent.

Also applies to: 286-286, 318-318, 324-324


575-587: Node update: Content Guidelines TextInput ID bump
TextInput-i5Z2Y has 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 – added tool_placeholder input
The Prompt node’s field_order now includes tool_placeholder and 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, and field_order have been generalized to support multiple providers (provider, model_name, api_key, stream, temperature). Structure looks correct.


1898-1914: Template tweak: api_key input field refined
The SecretStrInput for api_key now carries generic info "Model Provider API key" and real_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 on provider. Error messages for missing API keys are clear. Ensure unit tests cover each branch.


1934-1987: Template inputs: align component inputs with code logic
Fields input_value, model_name, provider, stream, system_message, and temperature have matching _input_type, names, and defaults. The model_name dropdown no longer uses combobox, 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.

@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Jun 18, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Jun 18, 2025
@github-actions github-actions Bot added the refactor Maintenance tasks and housekeeping label Jun 20, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Jun 20, 2025
@edwinjosechittilappilly edwinjosechittilappilly added this pull request to the merge queue Jun 20, 2025
Merged via the queue into main with commit 4832093 Jun 20, 2025
66 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the fic-llm-reset-issue branch June 20, 2025 19:01
ogabrielluiz added a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
…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>
Khurdhula-Harshavardhan pushed a commit to JigsawStack/langflow that referenced this pull request Jul 1, 2025
…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>
@coderabbitai coderabbitai Bot mentioned this pull request Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor Maintenance tasks and housekeeping size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants