From e95b6bbc42c435cedfd017bfbac09e3db1513489 Mon Sep 17 00:00:00 2001 From: zyzhang1130 <36942574+zyzhang1130@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:27:52 +0800 Subject: [PATCH] # Overwrite the parser attribute with the custom format_instruction to reinforce the output adhere to json format within this example. --- .../di_multiagent.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/data_interpreter_mulit-agent/di_multiagent.py b/examples/data_interpreter_mulit-agent/di_multiagent.py index be3a9c7ba..784b667dd 100644 --- a/examples/data_interpreter_mulit-agent/di_multiagent.py +++ b/examples/data_interpreter_mulit-agent/di_multiagent.py @@ -28,6 +28,7 @@ from agentscope.service.service_response import ServiceResponse from agentscope.service.service_status import ServiceExecStatus +from agentscope.parsers import RegexTaggedContentParser # Global variables for agents with type annotations planner_agent: PlannerAgent @@ -345,10 +346,10 @@ def init_agents() -> None: { "config_name": "dashscope_chat", "model_type": "dashscope_chat", - "model_name": "qwen-max", + "model_name": "qwen-plus", "api_key": dashscope_api_key, "generate_args": { - "temperature": 0.7, + "temperature": 0.0, }, }, ], @@ -388,6 +389,18 @@ def init_agents() -> None: service_toolkit=service_toolkit, ) + # Overwrite the parser attribute with the custom format_instruction to reinforce the output adhere to json format. + solver_agent.parser = RegexTaggedContentParser( + format_instruction="""Respond with specific tags as outlined below in json format: + {what you thought} + {the function name you want to call} + <{argument name}>{argument value} + <{argument name}>{argument value} + ...""", # noqa + try_parse_json=True, + required_keys=["thought", "function"], + ) + verifier_agent = VerifierAgent( name="verifier", sys_prompt="You're a helpful assistant.",