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
@samuelcolvin I am not sure if I understand the PR. Is it ending the run after the tool execution or before?
For example, if I don't use any framework in OpenAI I have to manually inspect the tool_calls and call them myself. I want to be able to do that here for some agents.
If you want to simply end the with specific data type, just use result_type, you can change the name of that tool with result_tool_name, e.g.:
frompydanticimportBaseModelfrompydantic_aiimportAgentclassCityLocation(BaseModel):
city: strcountry: stragent=Agent('openai:gpt-4', result_type=CityLocation, result_tool_name='city_location')
result=agent.run_sync('Where the olympics held in 2012?')
print(result.data)
#> city='London' country='United Kingdom'print(result.cost())
If you want the option to end the run within an arbitrary tool, call ctx.stop_run(result) within a tool once #142 is implemented. Of course, you can call this anywhere in your function.
It seems like for all agents, tool calls are automatic. I.e Pydantic automatically runs the tool and passes the result back and continues the run.
Can I manually intervene such that I want to manually run the tools and manage if I want to continue the run or not depending on the result?
The text was updated successfully, but these errors were encountered: