Skip to content

Commit

Permalink
fix: preserve template values in custom component updates
Browse files Browse the repository at this point in the history
  • Loading branch information
italojohnny committed Jan 21, 2025
1 parent 94d192f commit a4f5f33
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/backend/base/langflow/api/v1/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,14 @@ async def custom_component_update(
field_name=code_request.field,
)
component_node["template"] = updated_build_config

# Preserve previous field values by merging filtered template data into
# the component node's template. Only include entries where the value
# is a dictionary containing the key "value".
template_data = code_request.model_dump().get("template", {})
filtered_data = {k: v for k, v in template_data.items() if isinstance(v, dict) and "value" in v}
component_node["template"] |= filtered_data

if isinstance(cc_instance, Component):
await cc_instance.run_and_validate_update_outputs(
frontend_node=component_node,
Expand Down

0 comments on commit a4f5f33

Please sign in to comment.