forked from tylerprogramming/ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated user agents to either not execute code, or when executing, do…
…n't use Docker for update 0.2.8
- Loading branch information
1 parent
5f50a5c
commit 3be3127
Showing
16 changed files
with
160 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"model": "gpt-4-1106-preview", | ||
"api_key": "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" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import json | ||
import utility | ||
|
||
import autogen | ||
from autogen.agentchat.contrib.agent_builder import AgentBuilder | ||
|
||
config_file_or_env = "OAI_CONFIG_LIST" | ||
llm_config = {"temperature": 0} | ||
config_list = autogen.config_list_from_json(config_file_or_env, filter_dict={"model": ["gpt-4-1106-preview", "gpt-4"]}) | ||
|
||
position_list = utility.position_list | ||
agent_prompt = utility.agent_sys_msg_prompt | ||
library_path_or_json = "./agent_library_example.json" | ||
|
||
build_manager = autogen.OpenAIWrapper(config_list=config_list) | ||
sys_msg_list = [] | ||
|
||
|
||
def start_task(execution_task: str, agent_list: list): | ||
group_chat = autogen.GroupChat(agents=agent_list, messages=[], max_round=12) | ||
manager = autogen.GroupChatManager(groupchat=group_chat, llm_config={"config_list": config_list, **llm_config}) | ||
agent_list[0].initiate_chat(manager, message=execution_task) | ||
|
||
|
||
def generate_agents(): | ||
for pos in position_list: | ||
resp_agent_sys_msg = ( | ||
build_manager.create( | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": agent_prompt.format( | ||
position=pos, | ||
default_sys_msg=autogen.AssistantAgent.DEFAULT_SYSTEM_MESSAGE, | ||
), | ||
} | ||
] | ||
) | ||
.choices[0] | ||
.message.content | ||
) | ||
sys_msg_list.append({"name": pos, "profile": resp_agent_sys_msg}) | ||
|
||
|
||
generate_agents() | ||
|
||
json.dump(sys_msg_list, open(library_path_or_json, "w"), indent=4) | ||
|
||
new_builder = AgentBuilder( | ||
config_file_or_env=config_file_or_env, builder_model="gpt-4-1106-preview", agent_model="gpt-4-1106-preview" | ||
) | ||
agent_list, _ = new_builder.build_from_library(utility.building_task, library_path_or_json, llm_config) | ||
|
||
# new_builder = AgentBuilder(config_file_or_env=config_file_or_env) | ||
# agent_list, agent_config = new_builder.load(saved_path) | ||
saved_path = new_builder.save("./autogen_agentbuilder") | ||
print(saved_path) | ||
start_task( | ||
execution_task=utility.execution_task, | ||
agent_list=agent_list, | ||
) | ||
|
||
new_builder.clear_all_agents() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
building_task = "Be able to create a python function with documentation on how it works." | ||
|
||
execution_task = "Create a python function that reverses a string." | ||
|
||
agent_sys_msg_prompt = """Considering the following position: | ||
POSITION: {position} | ||
What requirements should this position be satisfied? | ||
Hint: | ||
# Your answer should be in one sentence. | ||
# Your answer should be natural, starting from "As a ...". | ||
# People with the above position need to complete a task given by a leader or colleague. | ||
# People will work in a group chat, solving tasks with other people with different jobs. | ||
# The modified requirement should not contain the code interpreter skill. | ||
# Coding skill is limited to Python. | ||
""" | ||
|
||
position_list = [ | ||
"Environmental_Scientist", | ||
"Astronomer", | ||
"Software_Developer", | ||
"Data_Analyst", | ||
"Journalist", | ||
"Teacher", | ||
"Lawyer", | ||
"Programmer", | ||
"Accountant", | ||
"Mathematician", | ||
"Physicist", | ||
"Biologist", | ||
"Chemist", | ||
"Statistician", | ||
"IT_Specialist", | ||
"Cybersecurity_Expert", | ||
"Artificial_Intelligence_Engineer", | ||
"Financial_Analyst", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters