feat: Add CreateData component for dynamic input generation#9526
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 WalkthroughAdds a new dynamic form builder component CrateData in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CrateData as CrateData Component
participant Builder as Build System
participant Graph as Graph Runtime
User->>Builder: Configure form_fields (table)
Builder->>CrateData: call update_build_config(build_config, form_fields)
rect rgba(200,230,255,0.25)
note right of CrateData: Dynamic inputs generation
CrateData->>CrateData: Clear existing dynamic_* entries
CrateData->>CrateData: Map field types -> input widgets
CrateData-->>Builder: Updated build_config with dynamic_* inputs
end
User->>Graph: Provide values/links to dynamic_* inputs
Graph->>CrateData: Execute process_form()
rect rgba(230,255,200,0.25)
note right of CrateData: Value extraction and Data output
CrateData->>CrateData: get_dynamic_values() + _extract_simple_value()
CrateData->>CrateData: Update status (connections count/info)
CrateData-->>Graph: Data(form_data)
end
Graph->>CrateData: Execute get_message()
rect rgba(255,240,200,0.25)
note right of CrateData: Human-readable summary
CrateData->>CrateData: Format values + counts
CrateData-->>Graph: Message(message)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (4)
src/backend/base/langflow/components/processing/new_create_data.py (4)
361-368: Minor: Clarify status phrasing and handle zero-field caseIf there are zero fields, avoid "0/0 fields connected". Optional but improves UX.
- self.status = f"Form processed successfully. {connected_fields}/{total_fields} fields connected to components." + if total_fields: + self.status = f"Form processed successfully. {connected_fields}/{total_fields} fields connected to components." + else: + self.status = "Form processed successfully. No fields configured."
373-399: Message rendering: preserve original label, not sanitized nameYou already use the original
field_namefor display; with the sanitization change above, keep using the human label (raw name) for readability. No change needed if you adopt the earlier diffs; just a heads-up to avoid accidentally switching to the sanitized version in the message.
61-92: Design/UX: Consider allowing per-field default valuesRight now every dynamic field starts with empty defaults (or 0/0.0/False). If you want truly dynamic forms for APIs, supporting a
default_valuecolumn in the table schema is valuable.If interested, I can draft a follow-up adding:
default_valuecolumn (str) and type-aware coercion.requiredcolumn (bool) with UI indication.
107-115: Make update_build_config backward-compatible (accept optional field_value/field_name)Short: repo contains components and tests that call update_build_config with different arities — make the parameters optional and add a safe fallback so this component won't break callers that pass only build_config.
Files to update / check:
- src/backend/base/langflow/components/processing/new_create_data.py (this PR).
- src/backend/base/langflow/custom/custom_component/custom_component.py (base/custom components).
- Spot-check tests and callers (e.g. src/backend/tests/unit/custom/custom_component/test_component.py) and helper callers like langflow.custom.utils.update_component_build_config.
Apply this minimal, backward-compatible patch:
-def update_build_config(self, build_config: Dict, field_value: Any, field_name: str = None) -> Dict: +def update_build_config(self, build_config: Dict, field_value: Any | None = None, field_name: str | None = None) -> Dict: @@ - if field_name == "form_fields": - # Clear existing dynamic inputs from build config - keys_to_remove = [key for key in build_config.keys() if key.startswith("dynamic_")] - for key in keys_to_remove: - del build_config[key] + # Only run dynamic update for our target field (or initial call with no field_name) + if field_name not in (None, "form_fields"): + return build_config + + # Fallback when caller didn't provide field_value + if field_value is None: + field_value = getattr(self, "form_fields", []) or [] + + # Clear existing dynamic inputs from build config + keys_to_remove = [key for key in build_config.keys() if key.startswith("dynamic_")] + for key in keys_to_remove: + del build_config[key]Reasoning: many components already implement update_build_config(build_config, field_value, field_name) while some callers/tests invoke it with only build_config. Making field_value optional and using a local fallback (self.form_fields) preserves both calling styles and prevents unexpected runtime errors.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/backend/base/langflow/components/processing/new_create_data.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/backend/base/langflow/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
src/backend/base/langflow/components/**/*.py: Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Implement async component methods using async def and await for asynchronous operations
Use asyncio.create_task for background work in async components and ensure proper cleanup on cancellation
Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
Files:
src/backend/base/langflow/components/processing/new_create_data.py
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/base/langflow/components/processing/new_create_data.py
src/backend/**/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)
In your Python component class, set the
iconattribute to a string matching the frontend icon mapping exactly (case-sensitive).
Files:
src/backend/base/langflow/components/processing/new_create_data.py
🧬 Code graph analysis (1)
src/backend/base/langflow/components/processing/new_create_data.py (3)
src/backend/base/langflow/inputs/inputs.py (7)
StrInput(128-184)IntInput(343-375)MultilineInput(259-269)TableInput(38-73)SecretStrInput(285-340)FloatInput(378-410)HandleInput(76-87)src/backend/base/langflow/schema/message.py (2)
Message(39-288)json(299-301)src/backend/base/langflow/schema/data.py (1)
Data(23-285)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Run Ruff Check and Format
- GitHub Check: Update Starter Projects
- GitHub Check: Ruff Style Check (3.13)
🔇 Additional comments (2)
src/backend/base/langflow/components/processing/new_create_data.py (2)
1-9: Nit: Remove unused imports
- The
Listandjsonimports insrc/backend/base/langflow/components/processing/new_create_data.pyappear unused after your recent changes.- Once you’ve run your formatting and linting locally with:
make format_backend && make lint
please remove these imports if they’re flagged as unused.
237-248: Removeinput_typesfrom BoolInput instantiationBoolean inputs don’t use an
input_typesparameter, and theBoolInputconstructor does not accept it—passinginput_types=[]will raise a TypeError at runtime.Apply this change:
- build_config[dynamic_input_name] = BoolInput( + build_config[dynamic_input_name] = BoolInput( name=dynamic_input_name, display_name=display_name, info=help_text, value=default_bool, - input_types=[], required=required, )Please verify the
BoolInput__init__signature insrc/backend/base/langflow/inputs/input_mixin.pyto confirm that no unsupported keyword arguments are being passed.
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (4)
src/backend/base/langflow/components/processing/new_create_data.py (4)
72-72: Break long line to satisfy E501 (max 120 chars).The info string exceeds the line limit.
- info="Define the dynamic form fields. Each row creates a new input field that can connect to other components.", + info=( + "Define the dynamic form fields. Each row creates a new input field " + "that can connect to other components." + ),
124-151: Avoid shadowing the function parameterfield_name; use a distinct local likeraw_field_name.Shadowing reduces clarity and can introduce bugs if the outer value is later needed.
- field_name = field_config.get("field_name", f"field_{i}") - display_name = field_name # Use field_name as display_name + raw_field_name = field_config.get("field_name", f"field_{i}") + display_name = raw_field_name # Use field_name as display_name @@ - dynamic_input_name = f"dynamic_{field_name}" + dynamic_input_name = f"dynamic_{raw_field_name}"Optionally sanitize names to be attribute-safe:
+ # Sanitize to a safe identifier for attribute access + safe_name = re.sub(r"[^0-9a-zA-Z_]+", "_", raw_field_name).strip("_") or f"field_{i}" + dynamic_input_name = f"dynamic_{safe_name}"If you adopt sanitization, add
import re:-from typing import Any +from typing import Any +import re
264-265: Use simpler conditional per SIM212.- input_types=["Data"] if not input_types_list else input_types_list, + input_types=input_types_list if input_types_list else ["Data"],
354-367: Implement Include Metadata setting; preserve existing behavior by default.
include_metadatais currently unused. When enabled, include connection info and schema in the output while keeping default output unchanged.def process_form(self) -> Data: """Process all dynamic form inputs and return clean data with just field values.""" # Get all dynamic values (just the key:value pairs) dynamic_values = self.get_dynamic_values() @@ - # Return clean Data object with just the field values - return Data(data=dynamic_values) + # Optionally include metadata + include_meta = bool(getattr(self, "include_metadata", False)) + if include_meta: + payload = { + "values": dynamic_values, + "_meta": { + "connection_info": getattr(self, "_connection_info", {}), + "schema": getattr(self, "form_fields", []), + }, + } + return Data(data=payload) + return Data(data=dynamic_values)
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/backend/base/langflow/components/processing/new_create_data.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/backend/base/langflow/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
src/backend/base/langflow/components/**/*.py: Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Implement async component methods using async def and await for asynchronous operations
Use asyncio.create_task for background work in async components and ensure proper cleanup on cancellation
Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
Files:
src/backend/base/langflow/components/processing/new_create_data.py
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/base/langflow/components/processing/new_create_data.py
src/backend/**/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)
In your Python component class, set the
iconattribute to a string matching the frontend icon mapping exactly (case-sensitive).
Files:
src/backend/base/langflow/components/processing/new_create_data.py
🧬 Code graph analysis (1)
src/backend/base/langflow/components/processing/new_create_data.py (3)
src/backend/base/langflow/inputs/inputs.py (7)
BoolInput(413-425)FloatInput(378-410)HandleInput(76-87)IntInput(343-375)MultilineInput(259-269)StrInput(128-184)TableInput(38-73)src/backend/base/langflow/schema/data.py (1)
Data(23-285)src/backend/base/langflow/schema/message.py (1)
Message(39-288)
🪛 GitHub Check: Ruff Style Check (3.13)
src/backend/base/langflow/components/processing/new_create_data.py
[failure] 312-312: Ruff (BLE001)
src/backend/base/langflow/components/processing/new_create_data.py:312:28: BLE001 Do not catch blind exception: Exception
[failure] 264-264: Ruff (SIM212)
src/backend/base/langflow/components/processing/new_create_data.py:264:37: SIM212 Use input_types_list if input_types_list else ["Data"] instead of ["Data"] if not input_types_list else input_types_list
[failure] 106-106: Ruff (RUF013)
src/backend/base/langflow/components/processing/new_create_data.py:106:85: RUF013 PEP 484 prohibits implicit Optional
[failure] 72-72: Ruff (E501)
src/backend/base/langflow/components/processing/new_create_data.py:72:121: E501 Line too long (124 > 120)
[failure] 19-57: Ruff (D415)
src/backend/base/langflow/components/processing/new_create_data.py:19:5: D415 First line should end with a period, question mark, or exclamation point
🪛 GitHub Actions: Ruff Style Check
src/backend/base/langflow/components/processing/new_create_data.py
[error] 19-19: Ruff check failed: D415 - First line should end with a period, question mark, or exclamation point.
🔇 Additional comments (3)
src/backend/base/langflow/components/processing/new_create_data.py (3)
101-105: Outputs look good.Two outputs—structured Data and a formatted Message—cover both machine and human consumption well.
280-353: Robust simple-value extraction.The normalization logic handles scalars, mappings, Message text, and Data payloads sensibly. Good defensive defaults.
68-99: General: dynamic input generation design is solid.
- Real-time refresh with TableInput is appropriate.
- Clearing and rebuilding only
dynamic_keys keeps build_config tidy.
edwinjosechittilappilly
left a comment
There was a problem hiding this comment.
@Empreiteiro Please add unit tests as well. Also if required feel free to create a base class for processing so the component code could be clean.
outdated
…equest repository and ref
|
…-ai#9526) * feat: Add CreateData component for dynamic input generation * [autofix.ci] apply automated fixes * feat: Refactor imports from langflow to lfx * Add tests for create data * Restore old create data component * Update dynamic_create_data.py * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * chore: update component index * [autofix.ci] apply automated fixes * chore: enhance component index update workflow with script existence check * chore: update checkout step in component index workflow to use pull request repository and ref --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
…-ai#9526) * feat: Add CreateData component for dynamic input generation * [autofix.ci] apply automated fixes * feat: Refactor imports from langflow to lfx * Add tests for create data * Restore old create data component * Update dynamic_create_data.py * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * chore: update component index * [autofix.ci] apply automated fixes * chore: enhance component index update workflow with script existence check * chore: update checkout step in component index workflow to use pull request repository and ref --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
…-ai#9526) * feat: Add CreateData component for dynamic input generation * [autofix.ci] apply automated fixes * feat: Refactor imports from langflow to lfx * Add tests for create data * Restore old create data component * Update dynamic_create_data.py * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * chore: update component index * [autofix.ci] apply automated fixes * chore: enhance component index update workflow with script existence check * chore: update checkout step in component index workflow to use pull request repository and ref --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
…-ai#9526) * feat: Add CreateData component for dynamic input generation * [autofix.ci] apply automated fixes * feat: Refactor imports from langflow to lfx * Add tests for create data * Restore old create data component * Update dynamic_create_data.py * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * chore: update component index * [autofix.ci] apply automated fixes * chore: enhance component index update workflow with script existence check * chore: update checkout step in component index workflow to use pull request repository and ref --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
…-ai#9526) * feat: Add CreateData component for dynamic input generation * [autofix.ci] apply automated fixes * feat: Refactor imports from langflow to lfx * Add tests for create data * Restore old create data component * Update dynamic_create_data.py * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * Update src/lfx/src/lfx/components/processing/dynamic_create_data.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * chore: update component index * [autofix.ci] apply automated fixes * chore: enhance component index update workflow with script existence check * chore: update checkout step in component index workflow to use pull request repository and ref --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>



Dynamic Form Component
Summary by CodeRabbit