chore: modify comments

This commit is contained in:
Novice 2025-03-21 09:26:00 +08:00
parent 45b1f31b94
commit 35a5a21c79

View File

@ -143,14 +143,16 @@ class AgentNode(ToolNode):
raise ValueError(f"Variable {agent_input.value} does not exist") raise ValueError(f"Variable {agent_input.value} does not exist")
parameter_value = variable.value parameter_value = variable.value
elif agent_input.type in {"mixed", "constant"}: elif agent_input.type in {"mixed", "constant"}:
# Convert dictionary to string to retrieve the variable's value # variable_pool.convert_template expects a string template,
# but if passing a dict, convert to JSON string first before rendering
try: try:
parameter_value = json.dumps(agent_input.value, ensure_ascii=False) parameter_value = json.dumps(agent_input.value, ensure_ascii=False)
except TypeError: except TypeError:
parameter_value = str(agent_input.value) parameter_value = str(agent_input.value)
segment_group = variable_pool.convert_template(parameter_value) segment_group = variable_pool.convert_template(parameter_value)
parameter_value = segment_group.log if for_log else segment_group.text parameter_value = segment_group.log if for_log else segment_group.text
# Convert string to dictionary to handle array[tools] and model-selector type # variable_pool.convert_template returns a string,
# so we need to convert it back to a dictionary
try: try:
parameter_value = json.loads(parameter_value) parameter_value = json.loads(parameter_value)
except json.JSONDecodeError: except json.JSONDecodeError: