forked from pee-tw/autogen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoding_task.py
More file actions
49 lines (38 loc) · 1.3 KB
/
coding_task.py
File metadata and controls
49 lines (38 loc) · 1.3 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from autogen import UserProxyAgent, GroupChat, GroupChatManager
from agents import engineer, executor, generic_config
user_proxy = UserProxyAgent(
name="Admin",
system_message=(
"A human admin. Interact with the planner to discuss the plan. "
"Plan execution needs to be approved by this admin."
),
code_execution_config=False,
)
def state_transition(last_speaker, groupchat_instance):
messages = groupchat_instance.messages
last_message = messages[-1]["content"]
if last_speaker is engineer:
if "```" in last_message:
return executor
else:
# Otherwise, let the engineer to continue
return engineer
elif last_speaker is executor:
if "Traceback (most recent call last):" in last_message:
return engineer
return "auto"
groupchat = GroupChat(
agents=[user_proxy, engineer, executor],
messages=[],
max_round=50,
allow_repeat_speaker=False,
speaker_selection_method=state_transition,
)
manager = GroupChatManager(
groupchat=groupchat, llm_config={"config_list": [generic_config]}
)
chat_message = """
Write a Python function to draw a christmas tree with colors
Call the function to print the tree without any arguments
"""
user_proxy.initiate_chat(manager, message=chat_message)