fix: make tool mode updates possible (#7931)
* refactor: streamline node update logic in setup.py Simplified the conditions for updating project components by consolidating checks for tool mode and output types. This enhances readability and maintainability of the code while ensuring that updates are applied correctly based on the latest component versions. * fix: refine field removal logic in update_projects_components_with_latest_component_versions * feat: add 'description' to NODE_FORMAT_ATTRIBUTES in constants.py Enhanced the NODE_FORMAT_ATTRIBUTES list by including 'description' to improve metadata handling for nodes. --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
parent
4f36583601
commit
8c0813f3d8
2 changed files with 8 additions and 11 deletions
|
|
@ -19,6 +19,7 @@ NODE_FORMAT_ATTRIBUTES = [
|
|||
"metadata",
|
||||
# remove display_name to prevent overwriting the display_name from the latest template
|
||||
# "display_name",
|
||||
"description",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,21 +56,14 @@ def update_projects_components_with_latest_component_versions(project_data, all_
|
|||
node_data = node.get("data").get("node")
|
||||
node_type = node.get("data").get("type")
|
||||
|
||||
# Skip updating if tool_mode is True
|
||||
if node_data.get("tool_mode", False) or node_data.get("key") == "Agent":
|
||||
continue
|
||||
|
||||
# Skip nodes with outputs of the specified format
|
||||
# NOTE: to account for the fact that the Simple Agent has dynamic outputs
|
||||
if any(output.get("types") == ["Tool"] for output in node_data.get("outputs", [])):
|
||||
continue
|
||||
|
||||
if node_type in all_types_dict_flat:
|
||||
latest_node = all_types_dict_flat.get(node_type)
|
||||
latest_template = latest_node.get("template")
|
||||
node_data["template"]["code"] = latest_template["code"]
|
||||
|
||||
if "outputs" in latest_node:
|
||||
is_tool_or_agent = node_data.get("tool_mode", False) or node_data.get("key") == "Agent"
|
||||
has_tool_outputs = any(output.get("types") == ["Tool"] for output in node_data.get("outputs", []))
|
||||
if "outputs" in latest_node and not has_tool_outputs and not is_tool_or_agent:
|
||||
node_data["outputs"] = latest_node["outputs"]
|
||||
if node_data["template"]["_type"] != latest_template["_type"]:
|
||||
node_data["template"]["_type"] = latest_template["_type"]
|
||||
|
|
@ -146,7 +139,10 @@ def update_projects_components_with_latest_component_versions(project_data, all_
|
|||
# Remove fields that are not in the latest template
|
||||
if node_type != "Prompt":
|
||||
for field_name in list(node_data["template"].keys()):
|
||||
if field_name not in latest_template:
|
||||
is_tool_mode_and_field_is_tools_metadata = (
|
||||
node_data.get("tool_mode", False) and field_name == "tools_metadata"
|
||||
)
|
||||
if field_name not in latest_template and not is_tool_mode_and_field_is_tools_metadata:
|
||||
node_data["template"].pop(field_name)
|
||||
log_node_changes(node_changes_log)
|
||||
return project_data_copy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue