Skip to content

fix: Clean up some more base templates#8708

Merged
erichare merged 8 commits into
mainfrom
fix-other-templates
Jun 24, 2025
Merged

fix: Clean up some more base templates#8708
erichare merged 8 commits into
mainfrom
fix-other-templates

Conversation

@Yukiyukiyeah
Copy link
Copy Markdown
Contributor

@Yukiyukiyeah Yukiyukiyeah commented Jun 24, 2025

Fix Research Translation Loop, Simple Agent, and Travel Planning Agent

Summary by CodeRabbit

  • New Features

    • Enhanced the "Document Q&A" starter project with improved file handling, flexible parsing, dynamic prompt templating, and support for multiple language model providers (OpenAI, Anthropic, Google).
    • Upgraded the "Research Translation Loop" with a versatile type converter for seamless transitions between Message, Data, and DataFrame formats.
  • Improvements

    • Updated node connections, metadata, and versioning across all starter projects for better modularity, extensibility, and maintainability.
    • Refined model selection options and user interface elements for a smoother experience.
  • Bug Fixes

    • Addressed minor issues related to node identifiers and visual layout in starter projects.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 24, 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

The changes update three Langflow starter project JSON files. "Document Q&A" is extensively restructured with new components, multi-provider language model support, and revised node connections. "Memory Chatbot" and "Research Translation Loop" mainly receive node ID updates, version bumps, and minor component enhancements, notably a new TypeConverterComponent in the latter.

Changes

File(s) Change Summary
.../starter_projects/Document Q&A.json Major restructuring: replaced OpenAIModel with LanguageModelComponent (multi-provider), introduced new FileComponent, PromptComponent, and ParserComponent. Updated node IDs, edges, and metadata. Enhanced file handling, prompt templating, and modularity.
.../starter_projects/Memory Chatbot.json Node and edge IDs regenerated, version numbers updated, node positions adjusted. No changes to component logic or public interfaces.
.../starter_projects/Research Translation Loop.json Node and edge IDs regenerated. Replaced MessagetoDataComponent with new TypeConverterComponent supporting dynamic output type selection and bidirectional conversion. Updated LanguageModelComponent model options. Minor node position tweaks.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FileComponent
    participant ParserComponent
    participant PromptComponent
    participant ChatInput
    participant LanguageModelComponent
    participant ChatOutput

    User->>FileComponent: Uploads file
    FileComponent->>ParserComponent: Sends loaded data
    ParserComponent->>PromptComponent: Sends parsed text
    User->>ChatInput: Sends query
    ChatInput->>LanguageModelComponent: Sends message
    PromptComponent->>LanguageModelComponent: Sends prompt template
    LanguageModelComponent->>ChatOutput: Sends generated response
    ChatOutput->>User: Displays answer
Loading

Possibly related PRs

Suggested labels

bug, size:XXL, lgtm

Suggested reviewers

  • erichare
  • ogabrielluiz
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch fix-other-templates

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.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 24, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (5)
src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (2)

1061-1077: Avoid shipping a literal API key placeholder

"value": "OPENAI_API_KEY" lands in the final exported JSON.
If a user forgets to replace it, OpenAI will receive the string OPENAI_API_KEY as a key and respond with 401, which is hard to diagnose.

- "value": "OPENAI_API_KEY"
+ "value": ""

Add a runtime check that fails fast when api_key is empty and surface a UI hint directing users to the note node showing how to obtain a key.


1418-1434: convert_to_* helpers assume .to_message() / .to_data() availability

The helper functions call v.to_message() / v.to_data() without guards.
Passing a plain dict or third-party class missing these methods will raise AttributeError.

- return v if isinstance(v, Message) else v.to_message()
+ if isinstance(v, Message):
+     return v
+ if hasattr(v, "to_message"):
+     return v.to_message()
+ raise TypeError(f"Unsupported type {type(v).__name__} for Message conversion")

Mirror this defensive pattern for Data and DataFrame conversions.

src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (2)

1143-1166: Potential KeyError due to placeholder {dt}

ParserComponent.pattern defaults to "Text: {dt}", but neither the ArXiv dataframe columns nor the Data objects produced upstream expose a dt key/column.
At runtime str.format(**row.to_dict()) (or with data.data) will raise KeyError: 'dt' and break the flow the moment mode == "Parser".

-            "value": "Text: {dt}"
+            "value": "Text: {text}"  # or whatever key really exists

Update the placeholder (and, if necessary, the default separator) to match an actual field (title, summary, text, …) returned by ArXivComponent or produced by prior nodes.


1400-1410: Edge-case: list-of-str inputs not fully converted

convert_to_message/convert_to_data only special-case a single str, but if input_data is a list of raw strings the first element is used and the remainder silently dropped.

Guard against this by:

-input_value = self.input_data[0] if isinstance(self.input_data, list) else self.input_data
+if isinstance(self.input_data, list):
+    input_value = [Message(text=v) if isinstance(v, str) else v for v in self.input_data]
+else:
+    input_value = Message(text=self.input_data) if isinstance(self.input_data, str) else self.input_data

and adapt downstream conversion helpers to handle lists where appropriate.

Also applies to: 1811-1832

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

540-570: Fix isinstance usage – union types are not accepted at runtime

isinstance(obj, A | B) raises TypeError; the second argument must be a type or tuple of types.
Both occurrences inside _validate_input will therefore crash as soon as the function is executed.

-        if isinstance(item, Message | Data | DataFrame | str) for item in self.input_value
+        if isinstance(item, (Message, Data, DataFrame, str)) for item in self.input_value
...
-        if not isinstance(
-            self.input_value,
-            Message | Data | DataFrame | str | list | Generator | type(None),
-        ):
+        if not isinstance(
+            self.input_value,
+            (Message, Data, DataFrame, str, list, Generator, type(None)),
+        ):

Please patch both sites – the comprehension and the later not isinstance check – otherwise the Chat Output component will never run.

🧹 Nitpick comments (4)
src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (2)

1650-1667: Default of n_messages = 100 may cause large prompt payloads

Retrieving 100 historical messages by default can explode token count and degrade latency / cost on GPT-4-tier models.

Options:

  1. Lower the default to something safer (e.g. 10-20).
  2. Add a max_tokens safeguard that truncates history when the LM budget is exceeded.

1835-1838: Viewport starts far outside the canvas

Negative x/y and fractional zoom may render the flow off-screen for first-time users. Consider resetting the viewport to (0,0,1) before shipping starter templates.

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

1370-1388: Duplicate implementation of TypeConverterComponent – DRY violation

The exact same TypeConverterComponent class definition is embedded twice (nodes TypeConverterComponent-FyeIR and TypeConverterComponent-shkBL). Maintaining two copies invites drift and bugs.

Refactor to keep a single definition and reference it from both nodes, e.g. by:

  1. Moving the class into a shared module inside langflow/custom.
  2. In each node’s code field, simply from shared.type_converter import TypeConverterComponent.

This will also shave ~150 lines off each template.

Also applies to: 1793-1810

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

1185-1205: Gracefully handle missing API keys in LanguageModelComponent

The default value "OPENAI_API_KEY" is a placeholder, but the code treats any non-empty string as a real key and will attempt a request that fails authentication.

Consider:

-        if provider == "OpenAI":
-            if not self.api_key:
+        if provider == "OpenAI":
+            if not self.api_key or self.api_key == "OPENAI_API_KEY":
                 msg = "OpenAI API key is required when using OpenAI provider"
                 raise ValueError(msg)

Repeat for Anthropic/Google. Alternatively, fall back to os.getenv(...).

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a3e205 and e6bd8f8.

📒 Files selected for processing (3)
  • src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (22 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (24 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (24 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Label PR
  • GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (3)
src/backend/base/langflow/initial_setup/starter_projects/Memory Chatbot.json (1)

24-31: ```shell
#!/bin/bash
set -e

echo "Listing starter_projects directory:"
find src/backend/base/langflow/initial_setup/starter_projects -maxdepth 1 -type f

echo -e "\nSearching for non-ASCII delimiter 'œ' in Memory Chatbot.json:"
rg -n 'œ' src/backend/base/langflow/initial_setup/starter_projects/Memory\ Chatbot.json || true

echo -e "\nDisplaying lines 20-40 of Memory Chatbot.json for context:"
sed -n '20,40p' src/backend/base/langflow/initial_setup/starter_projects/Memory\ Chatbot.json


</details>
<details>
<summary>src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (1)</summary>

`1596-1606`: **Verify model list – several entries are not publicly available**

The `model_name` dropdown now lists variants such as `gpt-4.1`, `gpt-4.1-mini`, `gpt-4o` etc. These identifiers are not (yet) released / stable in OpenAI’s API and will cause 400-errors.

Please double-check the allowed model names for each provider and keep the list in sync with the official docs, otherwise end-users will hit hard failures.

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

`1010-1025`: **`ParserComponent.update_build_config` adds `clean_data` unconditionally**

`field_value` is the *mode string* (“Parser”/“Stringify”), so the truth-test is always `True`; `clean_data` ends up present even in “Parser” mode.

```diff
-            if field_value:
+            if field_value == "Stringify":
                 clean_data = BoolInput(

This keeps the UI consistent with the description (“Stringify → enable clean_data”).

Likely an incorrect or invalid review comment.

@erichare erichare self-requested a review June 24, 2025 15:30
Copy link
Copy Markdown
Collaborator

@erichare erichare left a comment

Choose a reason for hiding this comment

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

The simple agent template works perfectly and looks great!
Screenshot 2025-06-24 at 8 31 09 AM
Screenshot 2025-06-24 at 8 31 06 AM
The research loop template has this error for me - i experienced this too, and i think its because of the dynamic outputs of Type Convert... maybe @edwinjosechittilappilly has some ideas?

@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jun 24, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 24, 2025
@erichare erichare self-requested a review June 24, 2025 15:44
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 24, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 24, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 24, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 24, 2025
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 24, 2025
@erichare erichare added this pull request to the merge queue Jun 24, 2025
Merged via the queue into main with commit 5b5f1dd Jun 24, 2025
73 of 74 checks passed
@erichare erichare deleted the fix-other-templates branch June 24, 2025 17:47
ogabrielluiz pushed a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
* fix: Clean up some more base templates

* update simple agent and research translation loop

* update travel planning agent

* update

* change outpu

* update translation loop

---------

Co-authored-by: Eric Hare <ericrhare@gmail.com>
Khurdhula-Harshavardhan pushed a commit to JigsawStack/langflow that referenced this pull request Jul 1, 2025
* fix: Clean up some more base templates

* update simple agent and research translation loop

* update travel planning agent

* update

* change outpu

* update translation loop

---------

Co-authored-by: Eric Hare <ericrhare@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants