bstraehle commited on
Commit
4d969ce
1 Parent(s): d56f6b1

Update multi_agent.py

Browse files
Files changed (1) hide show
  1. multi_agent.py +25 -61
multi_agent.py CHANGED
@@ -1,78 +1,42 @@
1
- import autogen
 
 
 
 
2
 
3
  def run_multi_agent(llm, task):
4
  llm_config = {"model": llm}
5
 
6
- user_proxy = autogen.ConversableAgent(
7
- name="Admin",
8
- system_message="Give the task, and send "
9
- "instructions to writer to refine the blog post.",
10
- code_execution_config=False,
11
- llm_config=llm_config,
12
- human_input_mode="NEVER",
13
  )
14
 
15
- planner = autogen.ConversableAgent(
16
- name="Planner",
17
- system_message="Given a task, please determine "
18
- "what information is needed to complete the task. "
19
- "Please note that the information will all be retrieved using"
20
- " Python code. Please only suggest information that can be "
21
- "retrieved using Python code. "
22
- "After each step is done by others, check the progress and "
23
- "instruct the remaining steps. If a step fails, try to "
24
- "workaround",
25
- description="Planner. Given a task, determine what "
26
- "information is needed to complete the task. "
27
- "After each step is done by others, check the progress and "
28
- "instruct the remaining steps",
29
- llm_config=llm_config,
30
  )
31
 
32
- engineer = autogen.AssistantAgent(
33
- name="Engineer",
34
  llm_config=llm_config,
35
- description="An engineer that writes code based on the plan "
36
- "provided by the planner.",
37
- )
38
-
39
- executor = autogen.ConversableAgent(
40
- name="Executor",
41
- system_message="Execute the code written by the "
42
- "engineer and report the result.",
43
  human_input_mode="NEVER",
44
- code_execution_config={
45
- "last_n_messages": 3,
46
- "work_dir": "coding",
47
- "use_docker": False,
48
- },
49
  )
50
 
51
- writer = autogen.ConversableAgent(
52
- name="Writer",
53
- llm_config=llm_config,
54
- system_message="Writer."
55
- "Please write blogs in markdown format (with relevant titles)"
56
- " and put the content in pseudo ```md``` code block. "
57
- "You take feedback from the admin and refine your blog.",
58
- description="Writer."
59
- "Write blogs based on the code execution results and take "
60
- "feedback from the admin to refine the blog."
61
- )
62
 
63
- groupchat = autogen.GroupChat(
64
- agents=[user_proxy, engineer, writer, executor, planner],
65
- messages=[],
66
- max_round=25,
67
- )
68
 
69
- manager = autogen.GroupChatManager(
70
- groupchat=groupchat, llm_config=llm_config
 
71
  )
72
 
73
- groupchat_result = user_proxy.initiate_chat(
74
- manager,
75
- message=task,
76
- )
77
 
78
- return groupchat_result
 
1
+ from autogen import ConversableAgent, AssistantAgent
2
+ from autogen.coding import LocalCommandLineCodeExecutor
3
+
4
+ #import os
5
+ #from IPython.display import Image
6
 
7
  def run_multi_agent(llm, task):
8
  llm_config = {"model": llm}
9
 
10
+ executor = LocalCommandLineCodeExecutor(
11
+ timeout=60,
12
+ work_dir="coding",
 
 
 
 
13
  )
14
 
15
+ code_executor_agent = ConversableAgent(
16
+ name="code_executor_agent",
17
+ llm_config=False,
18
+ code_execution_config={"executor": executor},
19
+ human_input_mode="NEVER",
20
+ default_auto_reply=
21
+ "Please continue. If everything is done, reply 'TERMINATE'.",
 
 
 
 
 
 
 
 
22
  )
23
 
24
+ code_writer_agent = AssistantAgent(
25
+ name="code_writer_agent",
26
  llm_config=llm_config,
27
+ code_execution_config=False,
 
 
 
 
 
 
 
28
  human_input_mode="NEVER",
 
 
 
 
 
29
  )
30
 
31
+ code_writer_agent_system_message = code_writer_agent.system_message
 
 
 
 
 
 
 
 
 
 
32
 
33
+ print(code_writer_agent_system_message)
 
 
 
 
34
 
35
+ chat_result = code_executor_agent.initiate_chat(
36
+ code_writer_agent,
37
+ message=message,
38
  )
39
 
40
+ #Image(os.path.join("coding", "ytd_stock_gains.png"))
 
 
 
41
 
42
+ return chat_result