Last active
February 12, 2024 04:53
-
-
Save langecrew/1696f3a32d5cc3c17c77d9598f778d2b to your computer and use it in GitHub Desktop.
Society of Mind Agent
This file contains hidden or 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
[ | |
{ | |
"model": "gpt-4", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
}, | |
{ | |
"model": "gpt-4-1106-preview", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
}, | |
{ | |
"model": "gpt-4-turbo-preview", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
} | |
] |
This file contains hidden or 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
import autogen | |
from autogen.agentchat.contrib.society_of_mind_agent import SocietyOfMindAgent | |
llm_config = { | |
"timeout": 600, | |
"cache_seed": None, # change the seed for different trials | |
"config_list": autogen.config_list_from_json( | |
"OAI_CONFIG_LIST", | |
filter_dict={ | |
"model": ["gpt-4-1106-preview"] | |
}, | |
), | |
"temperature": 0, | |
} | |
assistant = autogen.AssistantAgent( | |
"inner-assistant", | |
llm_config=llm_config, | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
) | |
code_interpreter = autogen.UserProxyAgent( | |
"inner-code-interpreter", | |
human_input_mode="NEVER", | |
code_execution_config={ | |
"work_dir": "coding", | |
"use_docker": False, | |
}, | |
default_auto_reply="", | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
) | |
groupchat = autogen.GroupChat( | |
agents=[assistant, code_interpreter], | |
messages=[], | |
speaker_selection_method="round_robin", # With two agents, this is equivalent to a 1:1 conversation. | |
allow_repeat_speaker=False, | |
max_round=8, | |
) | |
manager = autogen.GroupChatManager( | |
groupchat=groupchat, | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
llm_config=llm_config, | |
) | |
society_of_mind_agent = SocietyOfMindAgent( | |
"society_of_mind", | |
chat_manager=manager, | |
code_execution_config={ | |
"work_dir": "coding", | |
"use_docker": False, | |
}, | |
llm_config=llm_config, | |
) | |
user_proxy = autogen.UserProxyAgent( | |
"user_proxy", | |
human_input_mode="NEVER", | |
code_execution_config=False, | |
default_auto_reply="", | |
is_termination_msg=lambda x: True, | |
) | |
task = "What is tomorrow's forecast, in a random city of your choice? Use a free API such as open-meteo." | |
user_proxy.initiate_chat(society_of_mind_agent, message=task) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment