-
Notifications
You must be signed in to change notification settings - Fork 72
/
code_agent.py
32 lines (28 loc) · 1.15 KB
/
code_agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from autogen import config_list_from_json
import autogen
# Get api key
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
llm_config = {"config_list": config_list, "seed": 42, "request_timeout": 120}
# Create user proxy agent, coder, product manager
user_proxy = autogen.UserProxyAgent(
name="User_proxy",
system_message="A human admin who will give the idea and run the code provided by Coder.",
code_execution_config={"last_n_messages": 2, "work_dir": "groupchat"},
human_input_mode="ALWAYS",
)
coder = autogen.AssistantAgent(
name="Coder",
llm_config=llm_config,
)
pm = autogen.AssistantAgent(
name="product_manager",
system_message="You will help break down the initial idea into a well scoped requirement for the coder; Do not involve in future conversations or error fixing",
llm_config=llm_config,
)
# Create groupchat
groupchat = autogen.GroupChat(
agents=[user_proxy, coder, pm], messages=[])
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
# Start the conversation
user_proxy.initiate_chat(
manager, message="Build a classic & basic pong game with 2 players in python")