Agent Backed by OpenAI Assistant API
The GPTAssistantAgent is a powerful component of the AutoGen framework, utilizing OpenAI’s Assistant API to enhance agents with advanced capabilities. This agent enables the integration of multiple tools such as the Code Interpreter, File Search, and Function Calling, allowing for a highly customizable and dynamic interaction model.
Version Requirements:
- AutoGen: Version 0.2.27 or higher.
- OpenAI: Version 1.21 or higher.
Key Features of the GPTAssistantAgent:
-
Multi-Tool Mastery: Agents can leverage a combination of OpenAI’s built-in tools, like Code Interpreter and File Search, alongside custom tools you create or integrate via Function Calling.
-
Streamlined Conversation Management: Benefit from persistent threads that automatically store message history and adjust based on the model’s context length. This simplifies development by allowing you to focus on adding new messages rather than managing conversation flow.
-
File Access and Integration: Enable agents to access and utilize files in various formats. Files can be incorporated during agent creation or throughout conversations via threads. Additionally, agents can generate files (e.g., images, spreadsheets) and cite referenced files within their responses.
For a practical illustration, here are some examples:
- Chat with OpenAI Assistant using function call demonstrates how to leverage function calling to enable intelligent function selection.
- GPTAssistant with Code Interpreter showcases the integration of the Code Interpreter tool which executes Python code dynamically within applications.
- Group Chat with GPTAssistantAgent demonstrates how to use the GPTAssistantAgent in AutoGen’s group chat mode, enabling collaborative task performance through automated chat with agents powered by LLMs, tools, or humans.
Create a OpenAI Assistant in Autogen
Use OpenAI Assistant Built-in Tools and Function Calling
Code Interpreter
The Code Interpreter empowers your agents to write and execute Python code in a secure environment provide by OpenAI. This unlocks several capabilities, including but not limited to:
- Process data: Handle various data formats and manipulate data on the fly.
- Generate outputs: Create new data files or even visualizations like graphs.
- …
Using the Code Interpreter with the following configuration.
To get the file.id
, you can employ two methods:
-
OpenAI Playground: Leverage the OpenAI Playground, an interactive platform accessible at https://platform.openai.com/playground, to upload your files and obtain the corresponding file IDs.
-
Code-Based Uploading: Alternatively, you can upload files and retrieve their file IDs programmatically using the following code snippet:
File Search
The File Search tool empowers your agents to tap into knowledge beyond its pre-trained model. This allows you to incorporate your own documents and data, such as product information or code files, into your agent’s capabilities.
Using the File Search with the following configuration.
Here’s how to obtain the vector_store.id using two methods:
-
OpenAI Playground: Leverage the OpenAI Playground, an interactive platform accessible at https://platform.openai.com/playground, to create a vector store, upload your files, and add it into your vector store. Once complete, you’ll be able to retrieve the associated
vector_store.id
. -
Code-Based Uploading:Alternatively, you can upload files and retrieve their file IDs programmatically using the following code snippet:
Function calling
Function Calling empowers you to extend the capabilities of your agents with your pre-defined functionalities, which allows you to describe custom functions to the Assistant, enabling intelligent function selection and argument generation.
Using the Function calling with the following configuration.