You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
response = agent_executor.astream_events({"input": "check the weather info of Shanghai"},version="v2") --- 1 tool calling
response = agent_executor.astream_events({"input": "check the weather info and traffic info of Shanghai"},version="v2") --- multi tools calling
the problem is:
if the query is "check the weather info of Shanghai", only 'get_weather' tool will be called and successfully returned directly; but if the query is "check the weather info and traffic info of Shanghai", both two tools will be called, but failed to returned directly, the tools' answer will be fed into the chat model and generate a final answer, which is not expected to happen.
so, is there any solution to solve the above problem?
Motivation
I'm always frustrated when using an agent binded with many tools, in these tools some should be returned directly and the rest ones' answers should be fed into the chat model to generate a final response, in this case, things not going as expected because it always generate a final answer even all tools are set as 'return_direct=True'.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Checked
Feature request
@tool(return_direct=True)
def get_weather(city: str) -> str:
"""get the city weather info"""
return "pls wait..."
@tool(return_direct=True)
def get_traffic(city: str) -> str:
"""get the city traffic info"""
return "pls wait..."
system_prompt = ChatPromptTemplate.from_messages(
[
SystemMessagePromptTemplate.from_template("You are a helpful assistant."),
MessagesPlaceholder(variable_name='chat_history', optional=True),
HumanMessagePromptTemplate.from_template("{input}\n"),
MessagesPlaceholder(variable_name='agent_scratchpad')
]
)
agent = create_tool_calling_agent(chat_llm, [get_traffic, get_weather], system_prompt)
agent_executor = AgentExecutor(agent=agent, tools=[get_traffic, get_weather], return_intermediate_steps=True, handle_parsing_errors='true')
response = agent_executor.astream_events({"input": "check the weather info of Shanghai"},version="v2") --- 1 tool calling
response = agent_executor.astream_events({"input": "check the weather info and traffic info of Shanghai"},version="v2") --- multi tools calling
the problem is:
if the query is "check the weather info of Shanghai", only 'get_weather' tool will be called and successfully returned directly; but if the query is "check the weather info and traffic info of Shanghai", both two tools will be called, but failed to returned directly, the tools' answer will be fed into the chat model and generate a final answer, which is not expected to happen.
so, is there any solution to solve the above problem?
Motivation
I'm always frustrated when using an agent binded with many tools, in these tools some should be returned directly and the rest ones' answers should be fed into the chat model to generate a final response, in this case, things not going as expected because it always generate a final answer even all tools are set as 'return_direct=True'.
Proposal (If applicable)
No response
Beta Was this translation helpful? Give feedback.
All reactions