Skip to content

Commit

Permalink
small update for variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerprogramming committed Jan 28, 2024
1 parent 09bb6fb commit f6572a0
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions autogen_agentbuilder/main.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
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"]})
llm_config = {
"temperature": 0.7
}
config_list = autogen.config_list_from_json(config_file_or_env, filter_dict={
"model": ["gpt-4"]
})

position_list = utility.position_list
agent_prompt = utility.agent_sys_msg_prompt
library_path_or_json = "./agent_library_example.json"
library_path_or_json = "./agents.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 = (
Expand All @@ -31,30 +28,42 @@ def generate_agents():
"role": "user",
"content": agent_prompt.format(
position=pos,
default_sys_msg=autogen.AssistantAgent.DEFAULT_SYSTEM_MESSAGE,
),
default_sys_msg=autogen.AssistantAgent.DEFAULT_SYSTEM_MESSAGE
)
}
]
)
.choices[0]
.message.content
.message
.content
)
sys_msg_list.append({"name": pos, "profile": resp_agent_sys_msg})

sys_msg_list.append(
{
"name": pos,
"profile": resp_agent_sys_msg
}
)

generate_agents()

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)


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"
config_file_or_env=config_file_or_env,
builder_model="gpt-4",
agent_model="gpt-4",
)

agent_list, _ = new_builder.build_from_library(utility.building_task, library_path_or_json, llm_config)
saved_path = new_builder.save("./autogen_ab")

# 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,
Expand Down

0 comments on commit f6572a0

Please sign in to comment.