Skip to content

Commit bf7f59c

Browse files
committed
refactor(tool_call): improve data handling in ToolCallSchema
1 parent e2dc1e8 commit bf7f59c

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

flowllm/core/schema/tool_call.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,29 @@ def init_tool_call(cls, data: dict):
9090
tool_type = data.get("type", "")
9191
tool_type_dict = data.get(tool_type, {})
9292

93+
# Create a new dict to avoid modifying the original data
94+
result = data.copy()
95+
9396
if "name" in tool_type_dict:
94-
data["name"] = tool_type_dict["name"]
97+
result["name"] = tool_type_dict["name"]
9598

9699
if "arguments" in tool_type_dict:
97-
data["arguments"] = tool_type_dict["arguments"]
100+
result["arguments"] = tool_type_dict["arguments"]
98101

99102
if "description" in tool_type_dict:
100-
data["description"] = tool_type_dict["description"]
103+
result["description"] = tool_type_dict["description"]
101104

102105
if "parameters" in tool_type_dict:
103106
parameters = tool_type_dict["parameters"]
104107
properties: dict = parameters.get("properties", {})
105108
required: list = parameters.get("required", [])
106-
data["input_schema"] = {}
109+
result["input_schema"] = {}
107110
for name, param_attrs in properties.items():
108111
tool_attr = ToolAttr(**param_attrs)
109112
tool_attr.required = name in required
110-
data["input_schema"][name] = tool_attr
113+
result["input_schema"][name] = tool_attr
111114

112-
return data
115+
return result
113116

114117
@property
115118
def argument_dict(self) -> dict:

0 commit comments

Comments
 (0)