Skip to content

Commit

Permalink
# Overwrite the parser attribute with the custom format_instruction t…
Browse files Browse the repository at this point in the history
…o reinforce the output adhere to json format within this example.
  • Loading branch information
zyzhang1130 committed Dec 11, 2024
1 parent d22313e commit e95b6bb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions examples/data_interpreter_mulit-agent/di_multiagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
},
],
Expand Down Expand Up @@ -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:
<thought>{what you thought}</thought>
<function>{the function name you want to call}</function>
<{argument name}>{argument value}</{argument name}>
<{argument name}>{argument value}</{argument name}>
...""", # noqa
try_parse_json=True,
required_keys=["thought", "function"],
)

verifier_agent = VerifierAgent(
name="verifier",
sys_prompt="You're a helpful assistant.",
Expand Down

0 comments on commit e95b6bb

Please sign in to comment.