-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathagents.py
More file actions
186 lines (158 loc) · 6.01 KB
/
agents.py
File metadata and controls
186 lines (158 loc) · 6.01 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import autogen
from prompts.agent_prompts import (
PYTHON_EXPERT_SYSTEM_PROMPT,
FUNCTION_CALLING_AGENT_SYSTEM_PROMPT,
USER_PROXY_SYSTEM_PROMPT,
AGENT_AWARENESS_SYSTEM_PROMPT,
CREATIVE_SOLUTION_AGENT_SYSTEM_PROMPT,
AGI_GESTALT_SYSTEM_PROMPT,
EFFICIENCY_OPTIMIZER_SYSTEM_PROMPT,
EMOTIONAL_INTELLIGENCE_EXPERT_SYSTEM_PROMPT,
OUT_OF_THE_BOX_THINKER_SYSTEM_PROMPT,
PROJECT_MANAGER_SYSTEM_PROMPT,
STRATEGIC_PLANNING_AGENT_SYSTEM_PROMPT,
FIRST_PRINCIPLES_THINKER_SYSTEM_PROMPT,
TASK_HISTORY_REVIEW_AGENT_SYSTEM_PROMPT,
TASK_COMPREHENSION_AGENT_SYSTEM_PROMPT,
)
from dotenv import load_dotenv
load_dotenv()
import os
import copy
from utils.agent_utils import get_end_intent
from agent_functions import (
agent_functions,
read_file,
read_multiple_files,
read_directory_contents,
save_file,
save_multiple_files,
execute_code_block,
consult_archive_agent,
list_bitsavers_files,
download_bitsavers_file,
search_wikipedia,
)
google_search_api_key = os.environ["GOOGLE_SEARCH_API_KEY"]
google_custom_search_id = os.environ["GOOGLE_CUSTOM_SEARCH_ENGINE_ID"]
github_personal_access_token = os.environ["GITHUB_PERSONAL_ACCESS_TOKEN"]
config_list3 = [
{
"model": "gpt-3.5-turbo",
"api_key": os.environ["OPENAI_API_KEY"],
}
]
config_list4 = [
{
"model": "gpt-4-1106-preview",
"api_key": os.environ["OPENAI_API_KEY"],
}
]
llm_config4 = {
"seed": 42,
"config_list": config_list4,
"temperature": 0.1,
}
user_proxy = autogen.UserProxyAgent(
name="UserProxy",
system_message=USER_PROXY_SYSTEM_PROMPT,
human_input_mode="TERMINATE",
is_termination_msg=lambda x: get_end_intent(x) == "end",
code_execution_config=False,
llm_config=llm_config4,
)
code_reviewer = autogen.AssistantAgent(
name="CodeReviewer",
system_message="""You are an expert at reviewing code and suggesting improvements. Pay particluar attention to any potential syntax errors. Also, remind the Coding agent that they should always provide FULL and COMPLILABLE code and not shorten code blocks with comments such as '# Other class and method definitions remain unchanged...' or '# ... (previous code remains unchanged)'.""",
llm_config=llm_config4,
)
agent_awareness_expert = autogen.AssistantAgent(
name="AgentAwarenessExpert",
system_message=AGENT_AWARENESS_SYSTEM_PROMPT,
llm_config=llm_config4,
)
python_expert = autogen.AssistantAgent(
name="PythonExpert",
llm_config=llm_config4,
system_message=PYTHON_EXPERT_SYSTEM_PROMPT,
)
function_llm_config = copy.deepcopy(llm_config4)
function_llm_config["functions"] = agent_functions
function_calling_agent = autogen.AssistantAgent(
name="FunctionCallingAgent",
system_message=FUNCTION_CALLING_AGENT_SYSTEM_PROMPT,
llm_config=function_llm_config,
function_map={
"read_file": read_file,
"read_multiple_files": read_multiple_files,
"read_directory_contents": read_directory_contents,
"save_file": save_file,
"save_multiple_files": save_multiple_files,
"execute_code_block": execute_code_block,
"consult_archive_agent": consult_archive_agent,
"download_bitsavers_file": download_bitsavers_file,
"list_bitsavers_files": list_bitsavers_files,
"search_wikipedia": search_wikipedia,
},
)
bitsavers_agent = autogen.AssistantAgent(
name="BitsaversAgent",
system_message="You are an expert in antique computers, and proposing the use of functions by function calling agent, specifically download_bitsavers_file and list_bitsavers_files, creatively. Once you have a file downloaded with function calling agent, use consult archive agent to get the answer to the query. DO NOT USE READ FILE to read files downloaded from bitsavers, use the archive bot. You especially are good at finding the relevant directory or files from a list based on context, and speak up when you believe you know the best next action. You can also ask the function calling agent to search wikipedia for relevant articles",
llm_config=llm_config4,
# function_map={
# "consult_archive_agent": consult_archive_agent,
# "download_bitsavers_file": download_bitsavers_file,
# "list_bitsavers_files": list_bitsavers_files,
# "search_wikipedia": search_wikipedia,
# },
)
creative_solution_agent = autogen.AssistantAgent(
name="CreativeSolutionAgent",
system_message=CREATIVE_SOLUTION_AGENT_SYSTEM_PROMPT,
llm_config=llm_config4,
)
out_of_the_box_thinker_agent = autogen.AssistantAgent(
name="OutOfTheBoxThinkerAgent",
system_message=OUT_OF_THE_BOX_THINKER_SYSTEM_PROMPT,
llm_config=llm_config4,
)
agi_gestalt_agent = autogen.AssistantAgent(
name="AGIGestaltAgent",
system_message=AGI_GESTALT_SYSTEM_PROMPT,
llm_config=llm_config4,
)
project_manager_agent = autogen.AssistantAgent(
name="ProjectManagerAgent",
system_message=PROJECT_MANAGER_SYSTEM_PROMPT,
llm_config=llm_config4,
)
first_principles_thinker_agent = autogen.AssistantAgent(
name="FirstPrinciplesThinkerAgent",
system_message=FIRST_PRINCIPLES_THINKER_SYSTEM_PROMPT,
llm_config=llm_config4,
)
strategic_planning_agent = autogen.AssistantAgent(
name="StrategicPlanningAgent",
system_message=STRATEGIC_PLANNING_AGENT_SYSTEM_PROMPT,
llm_config=llm_config4,
)
emotional_intelligence_expert_agent = autogen.AssistantAgent(
name="EmotionalIntelligenceExpertAgent",
system_message=EMOTIONAL_INTELLIGENCE_EXPERT_SYSTEM_PROMPT,
llm_config=llm_config4,
)
efficiency_optimizer_agent = autogen.AssistantAgent(
name="EfficiencyOptimizerAgent",
system_message=EFFICIENCY_OPTIMIZER_SYSTEM_PROMPT,
llm_config=llm_config4,
)
task_history_review_agent = autogen.AssistantAgent(
name="TaskHistoryReviewAgent",
system_message=TASK_HISTORY_REVIEW_AGENT_SYSTEM_PROMPT,
llm_config=llm_config4,
)
task_comprehension_agent = autogen.AssistantAgent(
name="TaskComprehensionAgent",
system_message=TASK_COMPREHENSION_AGENT_SYSTEM_PROMPT,
llm_config=llm_config4,
)