Skip to main content
Open In Colab Open on GitHub The latest released Assistants API by OpenAI allows users to build AI assistants within their own applications. The Assistants API currently supports three types of tools: Code Interpreter, Retrieval, and Function calling. In this notebook, we demonstrate how to enable GPTAssistantAgent to use code interpreter.

Requirements

AG2 requires Python>=3.9. To run this notebook example, please install:
Install autogen:
For more information, please refer to the installation guide.

Set your API Endpoint

The config_list_from_json function loads a list of configurations from an environment variable or a json file.
Learn more about configuring LLMs for agents here.

Perform Tasks Using Code Interpreter

We demonstrate task solving using GPTAssistantAgent with code interpreter. Pass code_interpreter in tools parameter to enable GPTAssistantAgent with code interpreter. It will write code and automatically execute it in a sandbox. The agent will receive the results from the sandbox environment and act accordingly.

Example 1: Math Problem Solving

In this example, we demonstrate how to use code interpreter to solve math problems.

Example 2: Plotting with Code Interpreter

Code Interpreter can outputs files, such as generating image diagrams. In this example, we demonstrate how to draw figures and download it.
Now we have the file id. We can download and display it.