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.
Requirements
AG2 requires Python 3.9 or newer. For this notebook, please installautogen:
Creating the Functions
We need to create functions for our Agents to call. This function calls the Dad Joke API with a search term that the agent creates and returns a list of dad jokes.Create Function Schemas
In order to use the functions within our GPTAssistantAgents, we need to generate function schemas. This can be done by usingget_function_schema
Creating the Agents
In this section we create and configure our Dad and Sad Joker AgentsSet up the User Proxy
The Dad Agent
We create the Dad agent usingGPTAssistantAgent, 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
The Sad Joker Agent
We then create and configure the Sad Joker agent in a similar manner to the Dad agent above.write_to_txt function with the Sad Joker
GPTAssistantAgent