Skip to content

Commit

Permalink
bugfix: pass kwargs from Agent.run to Tool.call
Browse files Browse the repository at this point in the history
  • Loading branch information
JianxinMa committed Apr 29, 2024
1 parent 4fef8fe commit 89e02ad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion qwen_agent/agents/fncall_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _run(self, messages: List[Message], lang: Literal['en', 'zh'] = 'en', **kwar
messages.extend(output)
use_tool, tool_name, tool_args, _ = self._detect_tool(response[-1])
if use_tool:
tool_result = self._call_tool(tool_name, tool_args, messages=messages)
tool_result = self._call_tool(tool_name, tool_args, messages=messages, **kwargs)
fn_msg = Message(
role=FUNCTION,
name=tool_name,
Expand Down
2 changes: 1 addition & 1 deletion qwen_agent/agents/react_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _run(self, messages: List[Message], lang: Literal['en', 'zh'] = 'en', **kwar
break

# Add the tool result
observation = self._call_tool(action, action_input, messages=messages)
observation = self._call_tool(action, action_input, messages=messages, **kwargs)
observation = f'\nObservation: {observation}\nThought: '
response += observation
yield [Message(role=ASSISTANT, content=response)]
Expand Down
4 changes: 3 additions & 1 deletion qwen_agent/memory/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def _run(self,
max_ref_token: int = DEFAULT_MAX_REF_TOKEN,
parser_page_size: int = DEFAULT_PARSER_PAGE_SIZE,
lang: str = 'en',
ignore_cache: bool = False) -> Iterator[List[Message]]:
ignore_cache: bool = False,
**kwargs) -> Iterator[List[Message]]:
"""This agent is responsible for processing the input files in the message.
This method stores the files in the knowledge base, and retrievals the relevant parts
Expand Down Expand Up @@ -95,6 +96,7 @@ def _run(self,
ignore_cache=ignore_cache,
max_token=max_ref_token,
parser_page_size=parser_page_size,
**kwargs,
)

yield [Message(role=ASSISTANT, content=content, name='memory')]

0 comments on commit 89e02ad

Please sign in to comment.