Use tools in a GPTAssistantAgent Multi-Agent System by utilizing functions such as calling an API and writing to a file.
GPTAssistantAgent
to be augmented with “tools” —
pre-defined functions or capabilities — that extend its ability to
handle specific tasks, similar to how one might natively utilize tools
in the OpenAI Assistant’s
API.
In this notebook, we create a basic Multi-Agent System using Autogen’s
GPTAssistantAgent
to convert Dad jokes on a specific topic into Sad
jokes. It consists of a “Dad” agent which has the ability to search the
Dad Joke API and a “Sad Joker” agent
which converts the Dad jokes into Sad jokes. The Sad Joker then writes
the sad jokes into a txt file.
In this process we demonstrate how to call tools and perform function
calling for GPTAssistantAgent
.
autogen
:
get_function_schema
GPTAssistantAgent
, in order for us to
enable the Dad to use the get_dad_jokes
function we need to provide it
the function’s specification in our llm_config
.
We format the tools
within our llm_config
in the same format as
provided in the OpenAI Assistant tools
docs.
get_dad_jokes
function with the Dad
GPTAssistantAgent
write_to_txt
function with the Sad Joker
GPTAssistantAgent