fix: Clean up some more base templates#8708
Conversation
|
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 WalkthroughThe 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
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
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
|
There was a problem hiding this comment.
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 stringOPENAI_API_KEYas a key and respond with401, which is hard to diagnose.- "value": "OPENAI_API_KEY" + "value": ""Add a runtime check that fails fast when
api_keyis 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()availabilityThe helper functions call
v.to_message()/v.to_data()without guards.
Passing a plaindictor third-party class missing these methods will raiseAttributeError.- 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
DataandDataFrameconversions.src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (2)
1143-1166: Potential KeyError due to placeholder{dt}
ParserComponent.patterndefaults to"Text: {dt}", but neither the ArXiv dataframe columns nor theDataobjects produced upstream expose adtkey/column.
At runtimestr.format(**row.to_dict())(or withdata.data) will raiseKeyError: 'dt'and break the flow the momentmode == "Parser".- "value": "Text: {dt}" + "value": "Text: {text}" # or whatever key really existsUpdate the placeholder (and, if necessary, the default separator) to match an actual field (
title,summary,text, …) returned byArXivComponentor produced by prior nodes.
1400-1410: Edge-case: list-of-str inputs not fully converted
convert_to_message/convert_to_dataonly special-case a singlestr, but ifinput_datais 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_dataand 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: Fixisinstanceusage – union types are not accepted at runtime
isinstance(obj, A | B)raisesTypeError; the second argument must be a type or tuple of types.
Both occurrences inside_validate_inputwill 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 isinstancecheck – 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 ofn_messages = 100may cause large prompt payloadsRetrieving 100 historical messages by default can explode token count and degrade latency / cost on GPT-4-tier models.
Options:
- Lower the default to something safer (e.g. 10-20).
- Add a
max_tokenssafeguard that truncates history when the LM budget is exceeded.
1835-1838: Viewport starts far outside the canvasNegative
x/yand 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 ofTypeConverterComponent– DRY violationThe exact same
TypeConverterComponentclass definition is embedded twice (nodesTypeConverterComponent-FyeIRandTypeConverterComponent-shkBL). Maintaining two copies invites drift and bugs.Refactor to keep a single definition and reference it from both nodes, e.g. by:
- Moving the class into a shared module inside
langflow/custom.- In each node’s
codefield, simplyfrom 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 inLanguageModelComponentThe 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
📒 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 -eecho "Listing starter_projects directory:"
find src/backend/base/langflow/initial_setup/starter_projects -maxdepth 1 -type fecho -e "\nSearching for non-ASCII delimiter 'œ' in Memory Chatbot.json:"
rg -n 'œ' src/backend/base/langflow/initial_setup/starter_projects/Memory\ Chatbot.json || trueecho -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
left a comment
There was a problem hiding this comment.
The simple agent template works perfectly and looks great!


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?
* 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>
* 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>
Fix Research Translation Loop, Simple Agent, and Travel Planning Agent
Summary by CodeRabbit
New Features
Improvements
Bug Fixes