Assistants API + AutoGen + Code Interpreter

parmarjatin4911@gmail.com - Jan 28 - - Dev Community

Assistants API + AutoGen + Code Interpreter

import autogen
from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent
import openai

client = openai.OpenAI()

file = client.files.create(
file=open("2021_population.csv", "rb"),
purpose='assistants'
)

assistant = client.beta.assistants.create(
name="Python Developer",
instructions="You are a python developer",
model="gpt-4-1106-preview",
tools = [ { "type": "code_interpreter" } ],
file_ids=[file.id]
)

llm_config = {
"assistant_id": assistant.id,
# "tools": [ { "type": "code_interpreter" } ],
# "file_ids": [file.id]
}

gpt_assistant = GPTAssistantAgent(
name="Coder Assistant",
instructions="""
You are an expert at writing python code to solve problems.
Reply TERMINATE when the task is solved and there is no problem
""",
llm_config=llm_config
)

user_proxy = autogen.UserProxyAgent(
name="MervinPraison",
code_execution_config={
"work_dir" : "coding",
}
)

user_proxy.initiate_chat(
gpt_assistant,
message="""
What is the population trend.
Give me an overview of the data.
Show how you solved it with code.
"""
)

Categories
AI
Assistants API + AutoGen

Post author
Enter fullscreen mode Exit fullscreen mode

By praison

Post date

November 15, 2023
Enter fullscreen mode Exit fullscreen mode

import autogen
from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent
import openai

client = openai.OpenAI()

assistant = client.beta.assistants.create(
name="Customer Service Assistant",
instructions="You are a customer support chatbot. Use your knowledge base to best respond to customer queries.",
model="gpt-4-1106-preview"
)

config_list = [{"model": "gpt-4-1106-preview"}]
llm_config = {
"config_list": config_list,
"assistant_id": assistant.id
}

gpt_assistant = GPTAssistantAgent(
name="assistant",
instructions=autogen.AssistantAgent.DEFAULT_SYSTEM_MESSAGE,
llm_config=llm_config
)

user_proxy = autogen.UserProxyAgent(
name="MervinPraison",
code_execution_config={
"work_dir" : "coding",
}
)

user_proxy.initiate_chat(
gpt_assistant,
message="Create a sky invader game, execute it and save the game in the file"
)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player