Skip to content

fix(setup): preserve advanced attribute and generalize starter project JSON#8529

Merged
edwinjosechittilappilly merged 2 commits into
mainfrom
feat-const-fields-templates
Jun 13, 2025
Merged

fix(setup): preserve advanced attribute and generalize starter project JSON#8529
edwinjosechittilappilly merged 2 commits into
mainfrom
feat-const-fields-templates

Conversation

@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Jun 13, 2025

This pull request introduces updates to the initial_setup module, 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 the Basic Prompting.json file to improve UX and compatibility with newer versions.

Updates to Field Attributes in Project Components:

Enhancements to Starter Project Configuration:

Improved Input Field Definitions:

Miscellaneous UX Improvements:

Summary by CodeRabbit

  • New Features

    • Introduced a more flexible language model component supporting multiple providers (OpenAI, Anthropic, Google) with dynamic provider selection and API key handling.
    • Added new input options and enhanced metadata for prompt and chat components, improving customization and usability.
  • Refactor

    • Updated starter project structure and node connections to reflect the shift from a single-provider model to a multi-provider approach.
    • Improved prompt and chat node implementations for better message handling and template processing.
  • Style

    • Adjusted UI layout, node positions, and viewport settings for a more organized project view.
  • Chores

    • Updated project version metadata to reflect the latest changes.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 13, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

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

File(s) Change Summary
src/backend/base/langflow/initial_setup/setup.py Modified function to skip updating the "advanced" attribute in node template fields, preserving its value in starter project templates.
src/backend/base/langflow/initial_setup/starter_projects/Basic Prompting.json Refactored starter project: updated node IDs/types, generalized OpenAIModel to LanguageModelComponent supporting multiple providers, enhanced node input metadata, revised internal code for prompt and chat components, adjusted node connections, removed OpenAI-specific parameters, and updated project metadata and layout.

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
Loading
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch feat-const-fields-templates
  • Post Copyable Unit Tests in Comment

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.

@dosubot dosubot Bot added the enhancement New feature or request label Jun 13, 2025
@coderabbitai coderabbitai Bot changed the title @coderabbit fix(setup): preserve advanced attribute and generalize starter project JSON Jun 13, 2025
@github-actions github-actions Bot added bug Something isn't working and removed enhancement New feature or request labels Jun 13, 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: 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 changes provider to “Anthropic” or “Google”, the label in the UI will still say OpenAI API Key until update_build_config runs 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_config already 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

📥 Commits

Reviewing files that changed from the base of the PR and between b8f72d9 and 8eb17d6.

📒 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 resolution

The 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 -.
An undefined prefix 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.

Comment on lines 132 to 144
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ 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.

  1. PEP-8 reserves ALL-CAPS for module-level constants – Ruff (N806) already warns about this.
  2. Re-instantiating the same set in 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.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 13, 2025
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 13, 2025
@edwinjosechittilappilly edwinjosechittilappilly added this pull request to the merge queue Jun 13, 2025
Merged via the queue into main with commit ca23dc4 Jun 13, 2025
52 of 53 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the feat-const-fields-templates branch June 13, 2025 01:53
ogabrielluiz pushed a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
…t JSON (langflow-ai#8529)

* update the template

* update to fix format issues
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants