fix(setup): preserve advanced attribute and generalize starter project JSON#8529
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 the logic for updating node template fields in the setup script to skip the "advanced" attribute, ensuring it is preserved in starter project templates. Additionally, the "Basic Prompting" starter project JSON is refactored: node types and IDs are updated, OpenAI-specific components are generalized to support multiple providers, and node input metadata and internal logic are enhanced. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ChatInput
participant Prompt
participant LanguageModelComponent
participant ChatOutput
User->>ChatInput: Enter message
ChatInput->>Prompt: Send input
Prompt->>LanguageModelComponent: Build prompt, send to model
LanguageModelComponent->>LanguageModelComponent: Select provider (OpenAI/Anthropic/Google)
LanguageModelComponent->>LanguageModelComponent: Generate response
LanguageModelComponent->>ChatOutput: Send response
ChatOutput->>User: Display response
✨ 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: 1
🧹 Nitpick comments (1)
src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json (1)
998-1005: Display name should not hard-code “OpenAI”
"display_name": "OpenAI API Key"is stored even though the component can switch providers at runtime.
When the user changesproviderto “Anthropic” or “Google”, the label in the UI will still say OpenAI API Key untilupdate_build_configruns on the backend – this feels inconsistent.Consider initialising with a neutral label, e.g.:
-"display_name": "OpenAI API Key", +"display_name": "API Key",
update_build_configalready patches the label based on the chosen provider, so this change will not break functionality but will avoid a transient mismatch.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/backend/base/langflow/initial_setup/setup.py(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json(44 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
src/backend/base/langflow/initial_setup/setup.py
137-137: Variable SKIPPED_FIELD_ATTRIBUTES in function should be lowercase
(N806)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: Run Ruff Check and Format
- GitHub Check: Update Starter Projects
- GitHub Check: Ruff Style Check (3.13)
🔇 Additional comments (1)
src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json (1)
537-552: Node id prefixed with “undefined” may break handle resolutionThe note node is given the id
"undefined-9ON0z".
Down-stream logic (e.g.update_edges_with_latest_component_versions) often infers node type from the prefix before the first-.
Anundefinedprefix can therefore:
- Prevent automatic reconciliation when a node is missing.
- Make edge IDs harder to parse/debug.
Please rename the id to follow the
<NodeType>-<random>convention, e.g.Note-9ON0z.
| to_check_attributes = FIELD_FORMAT_ATTRIBUTES | ||
| # Skip specific field attributes that should respect the starter project template values. | ||
| # Currently we skip 'advanced' so that a field marked as advanced in the component code | ||
| # will NOT overwrite the value specified in the starter project template. This preserves | ||
| # the intended UX configuration of the starter projects. | ||
| SKIPPED_FIELD_ATTRIBUTES = {"advanced"} | ||
| # Iterate through the attributes we want to potentially update | ||
| for attr in to_check_attributes: | ||
| # Respect the template value by not updating if the attribute is in the skipped set | ||
| if attr in SKIPPED_FIELD_ATTRIBUTES: | ||
| continue | ||
| if ( | ||
| attr in field_dict |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Respect PEP-8 in local constant and avoid per-call re-allocation
SKIPPED_FIELD_ATTRIBUTES is declared inside the loop, in ALL-CAPS, and recreated for every field.
- PEP-8 reserves ALL-CAPS for module-level constants – Ruff (
N806) already warns about this. - Re-instantiating the same
setin every iteration is unnecessary.
Suggested refactor:
-# Skip specific field attributes that should respect the starter project template values.
-# Currently we skip 'advanced' so that a field marked as advanced in the component code
-# will NOT overwrite the value specified in the starter project template. This preserves
-# the intended UX configuration of the starter projects.
-SKIPPED_FIELD_ATTRIBUTES = {"advanced"}
+# Field attributes that must **never** be overwritten by component defaults.
+# Kept at module scope to follow PEP-8 (constant naming) and avoid re-allocation.
+SKIPPED_FIELD_ATTRIBUTES: set[str] = {"advanced"}and later:
-for attr in to_check_attributes:
- # Respect the template value by not updating if the attribute is in the skipped set
- if attr in SKIPPED_FIELD_ATTRIBUTES:
+for attr in to_check_attributes:
+ # Preserve starter-template overrides
+ if attr in SKIPPED_FIELD_ATTRIBUTES:Move the constant to the top of the module (alongside other imports/constants).
This keeps naming consistent, removes the Ruff warning, and saves a tiny bit of CPU.
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 Ruff (0.11.9)
137-137: Variable SKIPPED_FIELD_ATTRIBUTES in function should be lowercase
(N806)
🤖 Prompt for AI Agents
In src/backend/base/langflow/initial_setup/setup.py around lines 132 to 144, the
set SKIPPED_FIELD_ATTRIBUTES is declared inside a loop using ALL-CAPS naming,
which violates PEP-8 as ALL-CAPS should be reserved for module-level constants,
and it is unnecessarily recreated on each iteration. To fix this, move the
declaration of SKIPPED_FIELD_ATTRIBUTES to the top of the module alongside other
constants and imports, rename it to lowercase or mixed case if needed to reflect
its local usage, and then reference it inside the loop without re-instantiating
it each time.
…t JSON (langflow-ai#8529) * update the template * update to fix format issues
This pull request introduces updates to the
initial_setupmodule, focusing on enhancing the handling of starter project templates and improving the configuration of project components. The changes include refining field attribute updates to respect starter project template values and modifying theBasic Prompting.jsonfile to improve UX and compatibility with newer versions.Updates to Field Attributes in Project Components:
src/backend/base/langflow/initial_setup/setup.py: Added logic to skip specific field attributes (e.g.,advanced) during updates to ensure they respect the starter project template values, preserving the intended UX configuration.Enhancements to Starter Project Configuration:
src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json: Updated node and edge IDs, adjusted node measurements, and refined attributes such aslist_add_labelandtool_modefor better UX. [1] [2] [3] [4]src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json: Changedlf_versionto1.4.3to align with the latest compatibility requirements. [1] [2]Improved Input Field Definitions:
src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json: Added_input_typemetadata for various input fields (e.g.,MultilineInput,DropdownInput) and enhanced field properties likecomboboxandoptions_metadata. [1] [2] [3]Miscellaneous UX Improvements:
src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json: Added labels likelist_add_labelfor multiple fields to improve user interactions when adding items, and adjusted field placeholders and metadata for clarity. [1] [2] [3]Summary by CodeRabbit
New Features
Refactor
Style
Chores