Skip to content

Commit

Permalink
Overwrite the parser attribute with the custom format_instruction to …
Browse files Browse the repository at this point in the history
…reinforce the output adhere to json format within this example
  • Loading branch information
zyzhang1130 committed Dec 11, 2024
1 parent b178779 commit d22313e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions examples/data_interpreter_mulit-agent/di_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from agentscope.agents.agent import AgentBase
from agentscope.message import Msg
from agentscope.models import ModelResponse
from agentscope.parsers.json_object_parser import MarkdownJsonObjectParser
from agentscope.parsers import MarkdownJsonObjectParser
from agentscope.parsers import RegexTaggedContentParser
from agentscope.service import ServiceToolkit

from agentscope.service.service_response import ServiceResponse
from agentscope.service.service_status import ServiceExecStatus

Expand Down Expand Up @@ -198,6 +198,18 @@ def __init__(
max_iters=max_iters,
verbose=verbose,
)

# Overwrite the parser attribute with the custom format_instruction to reinforce the output adhere to json format.
self.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"],
)

def reply(self, x: Optional[Union[Msg, Sequence[Msg]]] = None) -> Msg:
Verification_PROMPT = """- Given `overall_task` and `solved_dependent_sub_tasks` as context, verify if the information in `result` can succesfully solve `current_sub_task` with your reasoning trace.
Expand Down

0 comments on commit d22313e

Please sign in to comment.