Update multi_agent.py
Browse files- multi_agent.py +25 -61
multi_agent.py
CHANGED
@@ -1,78 +1,42 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def run_multi_agent(llm, task):
|
4 |
llm_config = {"model": llm}
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
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 |
-
|
16 |
-
name="
|
17 |
-
|
18 |
-
"
|
19 |
-
"
|
20 |
-
|
21 |
-
"
|
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 |
-
|
33 |
-
name="
|
34 |
llm_config=llm_config,
|
35 |
-
|
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 |
-
|
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 |
-
|
64 |
-
agents=[user_proxy, engineer, writer, executor, planner],
|
65 |
-
messages=[],
|
66 |
-
max_round=25,
|
67 |
-
)
|
68 |
|
69 |
-
|
70 |
-
|
|
|
71 |
)
|
72 |
|
73 |
-
|
74 |
-
manager,
|
75 |
-
message=task,
|
76 |
-
)
|
77 |
|
78 |
-
return
|
|
|
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
|