-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
85 lines (69 loc) · 2.46 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import autogen
import dotenv
from src.autopilot import AutoPilotAgent
dotenv.load_dotenv()
config_list = autogen.config_list_from_dotenv(
".env",
{"gpt-4o": "OPENAI_API_KEY"}
)
llm_config = {
"cache_seed": 43,
"temperature": 0,
"config_list": config_list,
"timeout": 120,
}
user_proxy = autogen.UserProxyAgent(
name="Admin",
system_message="A human admin.",
code_execution_config={
"work_dir": "paper",
"use_docker": False
},
human_input_mode="TERMINATE",
)
engineer = autogen.AssistantAgent(
name="Engineer",
llm_config=llm_config,
system_message="""Engineer. You follow an approved plan. Make sure you save code to disk.
You write python/shell code to solve tasks. Wrap the code in a code block that specifies
the script type and the name of the file to save to disk.""",
)
scientist = autogen.AssistantAgent(
name="Scientist",
llm_config=llm_config,
system_message="""Scientist. You follow an approved plan. But first ask the Admin's expectations!
You are able to categorize papers after seeing their abstracts printed. You don't write code.""",
)
planner = autogen.AssistantAgent(
name="Planner",
system_message="""Planner. Suggest a plan. Revise the plan based on feedback from admin and critic,
until admin approval. The plan may involve an engineer who can write code and a scientist who doesn't write code.
Explain the plan first. Be clear which step is performed by an engineer, and which step is performed by a scientist.
""",
llm_config=llm_config,
)
critic = autogen.AssistantAgent(
name="Critic",
system_message="Critic. Double check plan, claims, code from other agents and provide feedback. "
"Check whether the plan includes adding verifiable info such as source URL.",
llm_config=llm_config,
)
autopilot = AutoPilotAgent(
name="AutoPilot",
llm_config=llm_config,
)
group_chat = autogen.GroupChat(
agents=[user_proxy, planner, scientist, engineer, critic, autopilot],
messages=[],
max_round=7,
speaker_selection_method='round_robin',
)
manager = autogen.GroupChatManager(groupchat=group_chat, llm_config=llm_config)
prompt = """
Could you please write me an article about Agentic AI?
"""
similar_found = autopilot.reapply_steps_if_found(prompt, threshold=0.7)
if not similar_found:
user_proxy.initiate_chat(manager, message=prompt)
autopilot.store_prompt_and_last_message_in_db(prompt)
autopilot.close_db()