fix issue 21157: only convert non-str parameter

pull/21674/head
Wang Han 11 months ago
parent 809a0ab6bf
commit f805f82446

@ -154,6 +154,7 @@ class AgentNode(ToolNode):
# variable_pool.convert_template expects a string template, # variable_pool.convert_template expects a string template,
# but if passing a dict, convert to JSON string first before rendering # but if passing a dict, convert to JSON string first before rendering
try: try:
if not isinstance(agent_input.value, str):
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)
@ -162,6 +163,7 @@ class AgentNode(ToolNode):
# variable_pool.convert_template returns a string, # variable_pool.convert_template returns a string,
# so we need to convert it back to a dictionary # so we need to convert it back to a dictionary
try: try:
if not isinstance(agent_input.value, str):
parameter_value = json.loads(parameter_value) parameter_value = json.loads(parameter_value)
except json.JSONDecodeError: except json.JSONDecodeError:
parameter_value = parameter_value parameter_value = parameter_value

Loading…
Cancel
Save