Skip to content

Instantly share code, notes, and snippets.

@KenichiQaz
Created November 27, 2023 05:19
Show Gist options
  • Save KenichiQaz/73104a7164761ba63ebfbfea0f81d013 to your computer and use it in GitHub Desktop.
Save KenichiQaz/73104a7164761ba63ebfbfea0f81d013 to your computer and use it in GitHub Desktop.
Starting point for SOB ethics board
from autogen import AssistantAgent
from autogen import UserProxyAgent, GroupChat, GroupChatManager, config_list_from_json
# Load configuration for the language model
gpt_config = config_list_from_json(
env_or_file="OAI_CONFIG_LIST",
filter_dict={
"model": [
"gpt-3.5-turbo-1106",
]
}
)
llm_config = {
"config_list": gpt_config,
"cache_seed": 42,
"temperature":0
}
# Instantiate UserProxyAgent
user_proxy = UserProxyAgent(name="User_Proxy",
system_message="""Reply TERMINATE if the task has been solved at full satisfaction.
Otherwise, reply CONTINUE, or the reason why the task is not solved yet."""
"that completes tasks autonomously and evaluate the ethics of this",human_input_mode="TERMINATE",
max_consecutive_auto_reply=10, is_termination_msg=lambda x: x.get('content","".rstrip().endswith("TERMINATE")'),
code_execution_config={"work_dir":"web"},llm_config=llm_config)
# Setting up the SOB with Agents
agents = []
archetypes = {
"Captain_Picard": "Captain Picard brings leadership and a strong moral compass, often emphasizing diplomacy and exploration.",
"Socrates": "Socrates encourages critical thinking and questioning, fostering deep philosophical inquiry.",
"King_Solomon": "King Solomon known for wisdom and fair judgments, offering balanced and thoughtful insights.",
"Gandhi": "Gandhi advocates for non-violence and peaceful resolution of conflicts, emphasizing ethical considerations.",
"Marcus_Aurelius": "Marcus_Aurelius brings a Stoic perspective, focusing on logic, personal virtue, and duty.",
"Tony_Stark": "Tony_Stark offers innovative and forward-thinking solutions, often with a focus on technology and its impacts.",
"Summy": "Takes all of the feedback and evaluates it to create a summary of the round of discussions, the summery is always less than 200 words."
}
for name, system_message in archetypes.items():
agent = AssistantAgent(
name=name,
system_message=system_message,
llm_config=llm_config
)
agents.append(agent)
task = """
"""
# GroupChat setup
groupchat = GroupChat(agents=[user_proxy, *agents], messages=[], max_round=6, speaker_selection_method='round_robin')
# GroupChatManager setup
manager = GroupChatManager(groupchat=groupchat, llm_config=llm_config)
# User Proxy initiates chat
user_proxy.initiate_chat(manager, message=task)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment