GPTAssistantAgent + Multi Agents

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

GPTAssistantAgent + Multi Agents.

Group Chat

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'
)

coder_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]
)

analyst_assistant = client.beta.assistants.create(
name="Data Analyst",
instructions="You are a data analyst",
model="gpt-4-1106-preview",
tools = [ { "type": "code_interpreter" } ],
file_ids=[file.id]
)

coder_llm_config = {
"assistant_id": coder_assistant.id
}

analyst_llm_config = {
"assistant_id": analyst_assistant.id
}

coder = 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=coder_llm_config
)

analyst = GPTAssistantAgent(
name="Data_Analyst",
instructions="""
You are a data analyst that offers insight into data.
""",
llm_config=analyst_llm_config,
)

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

groupchat = autogen.GroupChat(agents=[user_proxy, coder, analyst], messages=[], max_round=10)
manager = autogen.GroupChatManager(groupchat=groupchat)

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

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