Created
April 8, 2024 17:57
-
-
Save joegr/6da7efd6ac3111f6a3976f4602395e12 to your computer and use it in GitHub Desktop.
using autogen and differently configured llms, this script simulates the freudian conscious interactions between the ego and superego
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
import autogen | |
import os | |
from autogen.agentchat.contrib.society_of_mind_agent import SocietyOfMindAgent | |
#CONCIOUSNESS (INTERROGATES THE OUTSIDE WORLD THRU USER PROXY AGENT) configurations below | |
EGOconf = { | |
"model":"gpt-3.5-turbo", | |
"api_key": os.environ["OPENAI_API_KEY"], | |
"timeout":400, | |
"cache_seed":1, | |
"temperature":0.2, | |
} | |
SUPEREGOconf = { | |
"model":"gpt-3.5-turbo", | |
"api_key": os.environ["OPENAI_API_KEY"], | |
"timeout":600, | |
"cache_seed":2, | |
"temperature":0, | |
} | |
proxyconf = { | |
"model":"gpt-3.5-turbo", | |
"api_key": os.environ["OPENAI_API_KEY"], | |
"temperature":0, | |
} | |
######################### agent configs | |
user_proxy = autogen.UserProxyAgent( | |
"user_proxy", | |
human_input_mode="NEVER", | |
code_execution_config=False, | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
) | |
EGO = autogen.UserProxyAgent( | |
"inner-ego", | |
human_input_mode="NEVER", | |
code_execution_config={ | |
"work_dir":"coding", | |
"use_docker":False, | |
}, | |
llm_config=EGOconf, | |
is_termination_msg=lambda x: x.get("content","").find("TERMINATE") >= 0, | |
) | |
EGO_ = autogen.AssistantAgent( | |
"inner-ego-assistant", | |
llm_config=EGOconf, | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
) | |
SUPEREGO = autogen.UserProxyAgent( | |
"inner-superego", | |
human_input_mode="NEVER", | |
llm_config=SUPEREGOconf, | |
code_execution_config={ | |
"work_dir":"coding", | |
"use_docker":False, | |
}, | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
) | |
SUPEREGO_ = autogen.AssistantAgent( | |
"inner-superego-assistant", | |
llm_config=SUPEREGOconf, | |
is_termination_msg=lambda x: x.get("content","").find("TERMINATE") >= 0, | |
) | |
### Chat configs | |
#ego_con_selfchat = autogen.GroupChat(## | |
## agents=[EGO, EGO_], | |
## messages=[], | |
## speaker_selection_method="round_robin", | |
## allow_repeat_speaker=False, | |
## max_round=2, | |
## ) | |
#superego_ego_conchat = autogen.GroupChat( | |
## agents=[SUPEREGO, EGO], | |
## messages=[], | |
## speaker_selection_method="round_robin", | |
## allow_repeat_speaker=False, | |
## max_round=4, | |
##) | |
##superego_con_selfchat = autogen.GroupChat( | |
## agents=[SUPEREGO, SUPEREGO_], | |
## messages=[], | |
## speaker_selection_method="round_robin", | |
## allow_repeat_speaker=False, | |
## max_round=2, | |
##) | |
som_ego_superego_chat = autogen.GroupChat( | |
agents=[EGO_,SUPEREGO_], | |
messages=[], | |
speaker_selection_method="round_robin", | |
allow_repeat_speaker=False, | |
max_round=2, | |
) | |
### Chat managers | |
##ego_con_selfchat_manager = autogen.GroupChatManager( | |
## groupchat=ego_con_selfchat, | |
## is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
## llm_config=EGOconf, | |
##)## | |
##superego_con_selfchat_manager = autogen.GroupChatManager( | |
## groupchat=superego_con_selfchat, | |
## is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
## llm_config=SUPEREGOconf, | |
##) | |
##superego_ego_conchat_manager = autogen.GroupChatManager( | |
## groupchat=superego_ego_conchat, | |
## is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,## | |
## llm_config=EGOconf, | |
##) | |
som_ego_superego_chat_manager = autogen.GroupChatManager( | |
groupchat=som_ego_superego_chat, | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
llm_config=proxyconf, | |
) | |
SOM = SocietyOfMindAgent( | |
"som", | |
chat_manager=som_ego_superego_chat_manager, | |
llm_config=proxyconf, | |
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, | |
) | |
task = """ | |
I have a recurring dream of my teeth falling out. What does my dream mean? Cite freud if possible. | |
""" | |
user_proxy.initiate_chat(SOM,message=task, max_turns=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment