refactor: refactor dialogue examples (DialogueAgent, DialogueSimulator) (#4074)

refactor dialogue examples to have same DialogueAgent and
DialogueSimulator definitions
fix_agent_callbacks
mbchang 1 year ago committed by GitHub
parent 657f5f259f
commit cdea47491d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,36 +54,40 @@
"metadata": {},
"outputs": [],
"source": [
"class DialogueAgent():\n",
"\n",
"class DialogueAgent:\n",
" def __init__(\n",
" self,\n",
" name,\n",
" name: str,\n",
" system_message: SystemMessage,\n",
" model: ChatOpenAI,\n",
" ) -> None:\n",
" self.name = name\n",
" self.system_message = system_message\n",
" self.model = model\n",
" self.message_history = f\"\"\"Here is the conversation so far.\n",
" \"\"\"\n",
" self.prefix = f'\\n{self.name}:'\n",
" self.prefix = f\"{self.name}: \"\n",
" self.reset()\n",
" \n",
" def reset(self):\n",
" self.message_history = [\"Here is the conversation so far.\"]\n",
"\n",
" def send(self) -> str:\n",
" \"\"\"\n",
" Applies the chatmodel to the message history\n",
" and returns the message string\n",
" \"\"\"\n",
" message = self.model(\n",
" [self.system_message, \n",
" HumanMessage(content=self.message_history+self.prefix)])\n",
" [\n",
" self.system_message,\n",
" HumanMessage(content=\"\\n\".join(self.message_history + [self.prefix])),\n",
" ]\n",
" )\n",
" return message.content\n",
" \n",
"\n",
" def receive(self, name: str, message: str) -> None:\n",
" \"\"\"\n",
" Concatenates {message} spoken by {name} into message history\n",
" \"\"\"\n",
" self.message_history += f'\\n{name}: {message}'"
" self.message_history.append(f\"{name}: {message}\")"
]
},
{
@ -105,42 +109,45 @@
"metadata": {},
"outputs": [],
"source": [
"class DialogueSimulator():\n",
" \n",
"class DialogueSimulator:\n",
" def __init__(\n",
" self, \n",
" agents: List[DialogueAgent], \n",
" selection_function: Callable[[int, List[DialogueAgent]], int]\n",
" self,\n",
" agents: List[DialogueAgent],\n",
" selection_function: Callable[[int, List[DialogueAgent]], int],\n",
" ) -> None:\n",
" self.agents = agents\n",
" self._step = 0\n",
" self.select_next_speaker = selection_function\n",
" \n",
" def reset(self, name: str, message: str):\n",
" def reset(self):\n",
" for agent in self.agents:\n",
" agent.reset()\n",
"\n",
" def inject(self, name: str, message: str):\n",
" \"\"\"\n",
" Initiates the conversation with a {message} from {name}\n",
" \"\"\"\n",
" for agent in self.agents:\n",
" agent.receive(name, message)\n",
" \n",
"\n",
" # increment time\n",
" self._step += 1\n",
" \n",
"\n",
" def step(self) -> tuple[str, str]:\n",
" # 1. choose the next speaker\n",
" speaker_idx = self.select_next_speaker(self._step, self.agents)\n",
" speaker = self.agents[speaker_idx]\n",
" \n",
"\n",
" # 2. next speaker sends message\n",
" message = speaker.send()\n",
" \n",
"\n",
" # 3. everyone receives message\n",
" for receiver in self.agents:\n",
" receiver.receive(speaker.name, message)\n",
" \n",
"\n",
" # 4. increment time\n",
" self._step += 1\n",
" \n",
"\n",
" return speaker.name, message"
]
},
@ -253,15 +260,15 @@
"output_type": "stream",
"text": [
"Storyteller Description:\n",
"Dungeon Master, your vivid imagination conjures a world of wonder and danger. Will you lead our triumphant trio or be the ultimate foil to their quest to rid the world of Voldemort's horcruxes? The fate of both the muggle and wizarding worlds rests in your hands.\n",
"Dungeon Master, your power over this adventure is unparalleled. With your whimsical mind and impeccable storytelling, you guide us through the dangers of Hogwarts and beyond. We eagerly await your every twist, your every turn, in the hunt for Voldemort's cursed horcruxes.\n",
"Harry Potter Description:\n",
"Harry Potter, the boy who lived, you hold the fate of the wizarding world in your hands. Your bravery and loyalty to your friends are unmatched. The burden you carry is heavy, but with the power of love by your side, you can overcome any obstacle. The hunt for the horcruxes begins now.\n",
"\"Welcome, Harry Potter. You are the young wizard with a lightning-shaped scar on your forehead. You possess brave and heroic qualities that will be essential on this perilous quest. Your destiny is not of your own choosing, but you must rise to the occasion and destroy the evil horcruxes. The wizarding world is counting on you.\"\n",
"Ron Weasley Description:\n",
"Ron Weasley, you are Harry Potter's loyal and brave best friend. You have a great sense of humor and always bring joy to the team. Your skills with magic and strategy make you a valuable asset in the fight against Voldemort. Your love for food and your family keeps you grounded and motivated.\n",
"Ron Weasley, you are Harry's loyal friend and a talented wizard. You have a good heart but can be quick to anger. Keep your emotions in check as you journey to find the horcruxes. Your bravery will be tested, stay strong and focused.\n",
"Hermione Granger Description:\n",
"Hermione Granger, you are the brightest witch of your age. Your quick wit and vast knowledge are essential in our quest to find the horcruxes. Trust in your abilities and remember, knowledge is power.\n",
"Hermione Granger, you are a brilliant and resourceful witch, with encyclopedic knowledge of magic and an unwavering dedication to your friends. Your quick thinking and problem-solving skills make you a vital asset on any quest.\n",
"Argus Filch Description:\n",
"Argus Filch, you are a bitter and cruel caretaker of the Hogwarts School of Witchcraft and Wizardry. Your harsh mannerisms and love for punishing the students know no bounds. Your loyalty to the Wizarding World and disdain for magic-wielders makes it surprising that you would join Harry, Ron, and Hermione in their quest to defeat Voldemort.\n"
"Argus Filch, you are a squib, lacking magical abilities. But you make up for it with your sharpest of eyes, roving around the Hogwarts castle looking for any rule-breaker to punish. Your love for your feline friend, Mrs. Norris, is the only thing that feeds your heart.\n"
]
}
],
@ -293,7 +300,7 @@
"Find all of Lord Voldemort's seven horcruxes.\n",
"\n",
"Detailed quest:\n",
"You have discovered that one of Voldemort's horcruxes is hidden deep in the Forbidden Forest. You must navigate the dangerous terrain, avoid the creatures lurking within, and find the horcrux before the full moon rises, unleashing a pack of hungry werewolves. Remember, time is of the essence!\n",
"Harry Potter and his companions must journey to the Forbidden Forest, find the hidden entrance to Voldemort's secret lair, and retrieve the horcrux guarded by the deadly Acromantula, Aragog. Remember, time is of the essence as Voldemort's power grows stronger every day. Good luck.\n",
"\n"
]
}
@ -376,67 +383,70 @@
"name": "stdout",
"output_type": "stream",
"text": [
"(Dungeon Master): You have discovered that one of Voldemort's horcruxes is hidden deep in the Forbidden Forest. You must navigate the dangerous terrain, avoid the creatures lurking within, and find the horcrux before the full moon rises, unleashing a pack of hungry werewolves. Remember, time is of the essence!\n",
"(Dungeon Master): Harry Potter and his companions must journey to the Forbidden Forest, find the hidden entrance to Voldemort's secret lair, and retrieve the horcrux guarded by the deadly Acromantula, Aragog. Remember, time is of the essence as Voldemort's power grows stronger every day. Good luck.\n",
"\n",
"\n",
"(Harry Potter): I suggest we sneak into the Forbidden Forest under the cover of darkness. Ron, Hermione, and I can use our wands to create a Disillusionment Charm to make us invisible. Filch, you can keep watch for any signs of danger. Let's move quickly and quietly.\n",
"\n",
"\n",
"(Harry Potter): I take out my wand and cast a Lumos spell to light our way through the dark forest. We need to move quickly and quietly to avoid any unwanted attention from the creatures. Ron, Hermione, and I will lead the way while Argus Filch keeps watch behind us. Let's go!\n",
"(Dungeon Master): As you make your way through the Forbidden Forest, you hear the eerie sounds of nocturnal creatures. Suddenly, you come across a clearing where Aragog and his spider minions are waiting for you. Ron, Hermione, and Harry, you must use your wands to cast spells to fend off the spiders while Filch keeps watch. Be careful not to get bitten!\n",
"\n",
"\n",
"(Dungeon Master): As you make your way through the forest, you hear the rustling of leaves and the snapping of twigs. Suddenly, a group of acromantulas, giant spiders, appear in front of you, blocking your path. What do you do?\n",
"(Ron Weasley): I'll cast a spell to create a fiery blast to scare off the spiders. *I wave my wand and shout \"Incendio!\"* Hopefully, that will give us enough time to find the horcrux and get out of here safely.\n",
"\n",
"\n",
"(Ron Weasley): I quickly cast a spell to create a wall of fire between us and the acromantulas. Hopefully, the flames will deter them from attacking us. We need to keep moving forward and find that horcrux before it's too late.\n",
"(Dungeon Master): Ron's spell creates a burst of flames, causing the spiders to scurry away in fear. You quickly search the area and find a small, ornate box hidden in a crevice. Congratulations, you have found one of Voldemort's horcruxes! But beware, the Dark Lord's minions will stop at nothing to get it back.\n",
"\n",
"\n",
"(Dungeon Master): The acromantulas hiss and retreat from the wall of fire, allowing you to pass. As you continue deeper into the forest, you come across a clearing with a small pond. In the center of the pond, you see a glowing object. It must be the horcrux! But how do you get to it? What do you do?\n",
"(Hermione Granger): We need to destroy this horcrux as soon as possible. I suggest we use the Sword of Gryffindor to do it. Harry, do you still have it with you? We can use Fiendfyre to destroy it, but we need to be careful not to let the flames get out of control. Ron, can you help me create a protective barrier around us while Harry uses the sword?\n",
"\n",
"\n",
"(Hermione Granger): I take out my wand and cast a spell to conjure a small boat. We can use it to reach the center of the pond and retrieve the horcrux. But we need to be careful, there could be traps or other obstacles in our way. Ron, Harry, let's row the boat while Argus Filch keeps watch from the shore.\n",
"\n",
"(Dungeon Master): Harry retrieves the Sword of Gryffindor from his bag and holds it tightly. Hermione and Ron cast a protective barrier around the group as Harry uses the sword to destroy the horcrux with a swift strike. The box shatters into a million pieces, and a dark energy dissipates into the air. Well done, but there are still six more horcruxes to find and destroy. The hunt continues.\n",
"\n",
"(Dungeon Master): As you row towards the center of the pond, you hear a loud hissing sound. Suddenly, a giant serpent emerges from the water, blocking your path. It looks angry and ready to attack. What do you do?\n",
"\n",
"(Argus Filch): *I keep watch, making sure no one is following us.* I'll also keep an eye out for any signs of danger. Mrs. Norris, my trusty companion, will help me sniff out any trouble. We'll make sure the group stays safe while they search for the remaining horcruxes.\n",
"\n",
"(Argus Filch): I take out my crossbow and aim it at the serpent. I may not be a wizard, but I know how to handle a weapon. I'll shoot it if it comes any closer. We can't let this serpent stop us from getting that horcrux.\n",
"\n",
"(Dungeon Master): As you continue on your quest, Filch and Mrs. Norris alert you to a group of Death Eaters approaching. You must act quickly to defend yourselves. Harry, Ron, and Hermione, use your wands to cast spells while Filch and Mrs. Norris keep watch. Remember, the fate of the wizarding world rests on your success.\n",
"\n",
"(Dungeon Master): The serpent lunges towards the boat, but Argus Filch's crossbow bolt hits it in the head, causing it to retreat back into the water. You reach the center of the pond and retrieve the glowing object, which turns out to be a locket. Congratulations, you have found one of Voldemort's horcruxes! But there are still six more to find. What challenges will you face next?\n",
"\n",
"(Harry Potter): I'll cast a spell to create a shield around us. *I wave my wand and shout \"Protego!\"* Ron and Hermione, you focus on attacking the Death Eaters with your spells. We need to work together to defeat them and protect the remaining horcruxes. Filch, keep watch and let us know if there are any more approaching.\n",
"\n",
"(Harry Potter): We need to regroup and figure out our next move. We should head back to Hogwarts and consult with Professor Dumbledore's portrait. He may have some insight on where the other horcruxes could be hidden. We can't waste any time, Voldemort is getting stronger every day. Let's go!\n",
"\n",
"(Dungeon Master): Harry's shield protects the group from the Death Eaters' spells as Ron and Hermione launch their own attacks. The Death Eaters are no match for the combined power of the trio and are quickly defeated. You continue on your journey, knowing that the next horcrux could be just around the corner. Keep your wits about you, for the Dark Lord's minions are always watching.\n",
"\n",
"(Dungeon Master): As you make your way back to Hogwarts, you hear a loud roar coming from the Forbidden Forest. It sounds like a werewolf. You must hurry before it catches up to you. You arrive at Dumbledore's office and he tells you that the next horcrux is hidden in a dangerous location. Are you ready for the next challenge?\n",
"\n",
"(Ron Weasley): I suggest we split up to cover more ground. Harry and I can search the Forbidden Forest while Hermione and Filch search Hogwarts. We can use our wands to communicate with each other and meet back up once we find a horcrux. Let's move quickly and stay alert for any danger.\n",
"\n",
"(Ron Weasley): I'm always ready for a challenge! What's the location and what do we need to do to get there? We can't let Voldemort win, we have to find all of the horcruxes and destroy them. Let's do this!\n",
"\n",
"(Dungeon Master): As the group splits up, Harry and Ron make their way deeper into the Forbidden Forest while Hermione and Filch search the halls of Hogwarts. Suddenly, Harry and Ron come across a group of dementors. They must use their Patronus charms to fend them off while Hermione and Filch rush to their aid. Remember, the power of friendship and teamwork is crucial in this quest.\n",
"\n",
"(Dungeon Master): Dumbledore tells you that the next horcrux is hidden in the depths of Gringotts Bank. You must break into the bank, navigate its treacherous security measures, and find the horcrux before the goblins catch you. Are you ready to face the challenge of a lifetime? The fate of the wizarding world rests in your hands.\n",
"\n",
"(Hermione Granger): I hear Harry and Ron's Patronus charms from afar. We need to hurry and help them. Filch, can you use your knowledge of Hogwarts to find a shortcut to their location? I'll prepare a spell to repel the dementors. We need to work together to protect each other and find the next horcrux.\n",
"\n",
"(Hermione Granger): I suggest we do some research on Gringotts Bank and its security measures before we attempt to break in. We need to be prepared and have a solid plan in place. We can also gather any necessary tools or potions that may help us along the way. Let's not rush into this blindly.\n",
"\n",
"\n",
"(Dungeon Master): As you research and plan your break-in to Gringotts Bank, you discover that the bank is heavily guarded by goblins, dragons, and other dangerous creatures. You'll need to be stealthy and quick to avoid detection. Are you ready to put your plan into action and face the dangers that await you? The clock is ticking, Voldemort's power grows stronger with each passing day.\n",
"(Dungeon Master): Filch leads Hermione to a hidden passageway that leads to Harry and Ron's location. Hermione's spell repels the dementors, and the group is reunited. They continue their search, knowing that every moment counts. The fate of the wizarding world rests on their success.\n",
"\n",
"\n",
"(Argus Filch): I'll make sure to keep watch outside the bank while you all go in. I may not be able to help with the magic, but I can make sure no one interferes with our mission. We can't let anyone stop us from finding that horcrux and defeating Voldemort. Let's go!\n",
"(Argus Filch): *I keep watch as the group searches for the next horcrux.* Mrs. Norris and I will make sure no one is following us. We need to stay alert and work together to find the remaining horcruxes before it's too late. The Dark Lord's power grows stronger every day, and we must not let him win.\n",
"\n",
"\n",
"(Dungeon Master): As you approach Gringotts Bank, you see the imposing structure looming before you. You sneak past the guards and make your way inside, navigating the twisting corridors and avoiding the traps set to catch intruders. Finally, you reach the vault where the horcrux is hidden. But it's guarded by a fierce dragon. What do you do?\n",
"(Dungeon Master): As the group continues their search, they come across a hidden room in the depths of Hogwarts. Inside, they find a locket that they suspect is another one of Voldemort's horcruxes. But the locket is cursed, and they must work together to break the curse before they can destroy it. Harry, Ron, and Hermione, use your combined knowledge and skills to break the curse while Filch and Mrs. Norris keep watch. Time is running out, and the fate of the wizarding world rests on your success.\n",
"\n",
"\n",
"(Harry Potter): I remember the time when I faced a dragon during the Triwizard Tournament. I take out my wand and cast a spell to distract the dragon while Ron and Hermione retrieve the horcrux. We need to work together and be quick. Time is running out and we can't afford to fail.\n",
"(Harry Potter): I'll use my knowledge of dark magic to try and break the curse on the locket. Ron and Hermione, you can help me by using your wands to channel your magic into mine. We need to work together and stay focused. Filch, keep watch and let us know if there are any signs of danger.\n",
"Dungeon Master: Harry, Ron, and Hermione combine their magical abilities to break the curse on the locket. The locket opens, revealing a small piece of Voldemort's soul. Harry uses the Sword of Gryffindor to destroy it, and the group feels a sense of relief knowing that they are one step closer to defeating the Dark Lord. But there are still four more horcruxes to find and destroy. The hunt continues.\n",
"\n",
"\n",
"(Dungeon Master): The dragon roars and breathes fire, but Harry's spell distracts it long enough for Ron and Hermione to retrieve the horcrux. You make your way out of Gringotts Bank, but the goblins are hot on your trail. You must escape before they catch you. Congratulations, you have found another horcrux. But there are still five more to go. What challenges will you face next?\n",
"(Dungeon Master): As the group continues their quest, they face even greater challenges and dangers. But with their unwavering determination and teamwork, they press on, knowing that the fate of the wizarding world rests on their success. Will they be able to find and destroy all of Voldemort's horcruxes before it's too late? Only time will tell.\n",
"\n",
"\n",
"(Ron Weasley): We need to regroup and figure out our next move. We should consult with Professor Dumbledore's portrait again and see if he has any information on the next horcrux. We also need to be prepared for whatever challenges come our way. Voldemort won't make it easy for us, but we can't give up. Let's go!\n",
"(Ron Weasley): We can't give up now. We've come too far to let Voldemort win. Let's keep searching and fighting until we destroy all of his horcruxes and defeat him once and for all. We can do this together.\n",
"\n",
"\n",
"(Dungeon Master): As you make your way back to Hogwarts, you hear a loud explosion coming from the direction of Hogsmeade. You arrive to find that Death Eaters have attacked the village and are wreaking havoc. You must fight off the Death Eaters and protect the innocent villagers. Are you ready to face this unexpected challenge and defend the wizarding world? The fate of both muggles and wizards rests in your hands.\n",
"(Dungeon Master): The group nods in agreement, their determination stronger than ever. They continue their search, facing challenges and obstacles at every turn. But they know that they must not give up, for the fate of the wizarding world rests on their success. The hunt for Voldemort's horcruxes continues, and the end is in sight.\n",
"\n",
"\n"
]
@ -450,7 +460,8 @@
" agents=[storyteller] + characters,\n",
" selection_function=select_next_speaker\n",
")\n",
"simulator.reset(storyteller_name, specified_quest)\n",
"simulator.reset()\n",
"simulator.inject(storyteller_name, specified_quest)\n",
"print(f\"({storyteller_name}): {specified_quest}\")\n",
"print('\\n')\n",
"\n",
@ -485,7 +496,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.9.16"
}
},
"nbformat": 4,

@ -841,7 +841,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.9.16"
}
},
"nbformat": 4,

@ -35,8 +35,7 @@
" HumanMessage,\n",
" SystemMessage,\n",
" BaseMessage,\n",
")\n",
"from simulations import DialogueAgent, DialogueSimulator"
")"
]
},
{
@ -63,8 +62,11 @@
" self.name = name\n",
" self.system_message = system_message\n",
" self.model = model\n",
" self.prefix = f\"{self.name}: \"\n",
" self.reset()\n",
" \n",
" def reset(self):\n",
" self.message_history = [\"Here is the conversation so far.\"]\n",
" self.prefix = f\"{self.name}:\"\n",
"\n",
" def send(self) -> str:\n",
" \"\"\"\n",
@ -95,8 +97,12 @@
" self.agents = agents\n",
" self._step = 0\n",
" self.select_next_speaker = selection_function\n",
" \n",
" def reset(self):\n",
" for agent in self.agents:\n",
" agent.reset()\n",
"\n",
" def reset(self, name: str, message: str):\n",
" def inject(self, name: str, message: str):\n",
" \"\"\"\n",
" Initiates the conversation with a {message} from {name}\n",
" \"\"\"\n",
@ -259,13 +265,13 @@
"\n",
"Donald Trump Description:\n",
"\n",
"Donald Trump, you exude confidence and a bold personality. You are known for your unpredictability and your desire for greatness. You often speak your mind without reservation, which can be a strength but also a weakness.\n",
"Donald Trump, you are a bold and outspoken individual, unafraid to speak your mind and take on any challenge. Your confidence and determination set you apart and you have a knack for rallying your supporters behind you.\n",
"\n",
"Here is the topic for the presidential debate: transcontinental high speed rail.\n",
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Donald Trump.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Donald Trump, you exude confidence and a bold personality. You are known for your unpredictability and your desire for greatness. You often speak your mind without reservation, which can be a strength but also a weakness.\n",
"Your description is as follows: Donald Trump, you are a bold and outspoken individual, unafraid to speak your mind and take on any challenge. Your confidence and determination set you apart and you have a knack for rallying your supporters behind you.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -274,7 +280,7 @@
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Donald Trump.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Donald Trump, you exude confidence and a bold personality. You are known for your unpredictability and your desire for greatness. You often speak your mind without reservation, which can be a strength but also a weakness.\n",
"Your description is as follows: Donald Trump, you are a bold and outspoken individual, unafraid to speak your mind and take on any challenge. Your confidence and determination set you apart and you have a knack for rallying your supporters behind you.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -294,13 +300,13 @@
"\n",
"Kanye West Description:\n",
"\n",
"Kanye West, you are a creative visionary who is unafraid to speak your mind. Your innovative approach to art and music has made you one of the most influential figures of our time. You bring a bold and unconventional perspective to this debate that I look forward to hearing.\n",
"Kanye West, you are a true individual with a passion for artistry and creativity. You are known for your bold ideas and willingness to take risks. Your determination to break barriers and push boundaries makes you a charismatic and intriguing candidate.\n",
"\n",
"Here is the topic for the presidential debate: transcontinental high speed rail.\n",
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Kanye West.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Kanye West, you are a creative visionary who is unafraid to speak your mind. Your innovative approach to art and music has made you one of the most influential figures of our time. You bring a bold and unconventional perspective to this debate that I look forward to hearing.\n",
"Your description is as follows: Kanye West, you are a true individual with a passion for artistry and creativity. You are known for your bold ideas and willingness to take risks. Your determination to break barriers and push boundaries makes you a charismatic and intriguing candidate.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -309,7 +315,7 @@
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Kanye West.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Kanye West, you are a creative visionary who is unafraid to speak your mind. Your innovative approach to art and music has made you one of the most influential figures of our time. You bring a bold and unconventional perspective to this debate that I look forward to hearing.\n",
"Your description is as follows: Kanye West, you are a true individual with a passion for artistry and creativity. You are known for your bold ideas and willingness to take risks. Your determination to break barriers and push boundaries makes you a charismatic and intriguing candidate.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -329,13 +335,13 @@
"\n",
"Elizabeth Warren Description:\n",
"\n",
"Elizabeth Warren, you are a fierce advocate for the middle class and a champion of progressive policies. Your tenacity and unwavering dedication to fighting for what you believe in have inspired many. Your policies are guided by a deep sense of empathy and a desire to help those who are most in need.\n",
"Senator Warren, you are a fearless leader who fights for the little guy. Your tenacity and intelligence inspire us all to fight for what's right.\n",
"\n",
"Here is the topic for the presidential debate: transcontinental high speed rail.\n",
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Elizabeth Warren.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Elizabeth Warren, you are a fierce advocate for the middle class and a champion of progressive policies. Your tenacity and unwavering dedication to fighting for what you believe in have inspired many. Your policies are guided by a deep sense of empathy and a desire to help those who are most in need.\n",
"Your description is as follows: Senator Warren, you are a fearless leader who fights for the little guy. Your tenacity and intelligence inspire us all to fight for what's right.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -344,7 +350,7 @@
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Elizabeth Warren.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Elizabeth Warren, you are a fierce advocate for the middle class and a champion of progressive policies. Your tenacity and unwavering dedication to fighting for what you believe in have inspired many. Your policies are guided by a deep sense of empathy and a desire to help those who are most in need.\n",
"Your description is as follows: Senator Warren, you are a fearless leader who fights for the little guy. Your tenacity and intelligence inspire us all to fight for what's right.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -450,7 +456,7 @@
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Donald Trump.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Donald Trump, you exude confidence and a bold personality. You are known for your unpredictability and your desire for greatness. You often speak your mind without reservation, which can be a strength but also a weakness.\n",
"Your description is as follows: Donald Trump, you are a bold and outspoken individual, unafraid to speak your mind and take on any challenge. Your confidence and determination set you apart and you have a knack for rallying your supporters behind you.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -473,7 +479,7 @@
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Kanye West.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Kanye West, you are a creative visionary who is unafraid to speak your mind. Your innovative approach to art and music has made you one of the most influential figures of our time. You bring a bold and unconventional perspective to this debate that I look forward to hearing.\n",
"Your description is as follows: Kanye West, you are a true individual with a passion for artistry and creativity. You are known for your bold ideas and willingness to take risks. Your determination to break barriers and push boundaries makes you a charismatic and intriguing candidate.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -496,7 +502,7 @@
"The presidential candidates are: Donald Trump, Kanye West, Elizabeth Warren.\n",
"Your name is Elizabeth Warren.\n",
"You are a presidential candidate.\n",
"Your description is as follows: Elizabeth Warren, you are a fierce advocate for the middle class and a champion of progressive policies. Your tenacity and unwavering dedication to fighting for what you believe in have inspired many. Your policies are guided by a deep sense of empathy and a desire to help those who are most in need.\n",
"Your description is as follows: Senator Warren, you are a fearless leader who fights for the little guy. Your tenacity and intelligence inspire us all to fight for what's right.\n",
"You are debating the topic: transcontinental high speed rail.\n",
"Your goal is to be as creative as possible and make the voters think you are the best candidate.\n",
"\n",
@ -543,7 +549,7 @@
"transcontinental high speed rail\n",
"\n",
"Detailed topic:\n",
"Candidates, with the rise of autonomous technologies, we must address the problem of how to integrate them into our proposed transcontinental high speed rail system. Outline your plan on how to safely integrate autonomous vehicles into rail travel, balancing the need for innovation and safety.\n",
"The topic for the presidential debate is: \"Overcoming the Logistics of Building a Transcontinental High-Speed Rail that is Sustainable, Inclusive, and Profitable.\" Donald Trump, Kanye West, Elizabeth Warren, how will you address the challenges of building such a massive transportation infrastructure, dealing with stakeholders, and ensuring economic stability while preserving the environment?\n",
"\n"
]
}
@ -653,34 +659,34 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(Debate Moderator): Candidates, with the rise of autonomous technologies, we must address the problem of how to integrate them into our proposed transcontinental high speed rail system. Outline your plan on how to safely integrate autonomous vehicles into rail travel, balancing the need for innovation and safety.\n",
"(Debate Moderator): The topic for the presidential debate is: \"Overcoming the Logistics of Building a Transcontinental High-Speed Rail that is Sustainable, Inclusive, and Profitable.\" Donald Trump, Kanye West, Elizabeth Warren, how will you address the challenges of building such a massive transportation infrastructure, dealing with stakeholders, and ensuring economic stability while preserving the environment?\n",
"\n",
"\n",
"Bids:\n",
"\tDonald Trump bid: 8\n",
"\tKanye West bid: 2\n",
"\tDonald Trump bid: 7\n",
"\tKanye West bid: 5\n",
"\tElizabeth Warren bid: 1\n",
"Selected: Donald Trump\n",
"\n",
"\n",
"(Donald Trump): Let me tell you, folks, I have the best plan for integrating autonomous vehicles into our high speed rail system. We're going to use the latest technology, the best technology, to ensure safety and efficiency. And let me tell you, we're going to do it in style. We're going to have luxury autonomous cars that will make you feel like you're in a private jet. It's going to be tremendous, believe me. *gestures with hands*\n",
"(Donald Trump): Let me tell you, folks, I know how to build big and I know how to build fast. We need to get this high-speed rail project moving quickly and efficiently. I'll make sure we cut through the red tape and get the job done. And let me tell you, we'll make it profitable too. We'll bring in private investors and make sure it's a win-win for everyone. *gestures confidently*\n",
"\n",
"\n",
"Bids:\n",
"\tDonald Trump bid: 8\n",
"\tKanye West bid: 7\n",
"\tDonald Trump bid: 2\n",
"\tKanye West bid: 8\n",
"\tElizabeth Warren bid: 10\n",
"Selected: Elizabeth Warren\n",
"\n",
"\n",
"(Elizabeth Warren): Thank you for the question. As someone who has always fought for the safety and well-being of the American people, I believe that any plan for integrating autonomous vehicles into our high speed rail system must prioritize safety above all else. We need to ensure that these vehicles are thoroughly tested and meet strict safety standards before they are allowed on our rails. Additionally, we must invest in the necessary infrastructure to support these vehicles, such as advanced sensors and communication systems. But we must also ensure that these innovations are accessible to all Americans, not just the wealthy. That's why I propose a public-private partnership to fund and build this system, with a focus on creating good-paying jobs and expanding economic opportunities for all Americans. *smiles confidently*\n",
"(Elizabeth Warren): Thank you for the question. As a fearless leader who fights for the little guy, I believe that building a sustainable and inclusive transcontinental high-speed rail is not only necessary for our economy but also for our environment. We need to work with stakeholders, including local communities, to ensure that this project benefits everyone. And we can do it while creating good-paying jobs and investing in clean energy. *smiles confidently*\n",
"\n",
"\n",
"Bids:\n",
@ -690,43 +696,37 @@
"Selected: Donald Trump\n",
"\n",
"\n",
"(Donald Trump): Let me tell you, Elizabeth, safety is important, but we also need to think about innovation and progress. We can't let fear hold us back from achieving greatness. That's why I propose a competition, a race to see which company can create the safest and most efficient autonomous vehicles for our high speed rail system. And let me tell you, the winner will receive a huge government contract and be hailed as a hero. It's going to be tremendous, folks. *points finger*\n",
"(Donald Trump): Let me tell you, Elizabeth, you're all talk and no action. We need a leader who knows how to get things done, not just talk about it. And as for the environment, I've got a great idea. We'll make the trains run on clean coal. That's right, folks, clean coal. It's a beautiful thing. And we'll make sure the rail system is the envy of the world. *thumbs up*\n",
"\n",
"\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Bids:\n",
"\tDonald Trump bid: 3\n",
"\tKanye West bid: 8\n",
"\tElizabeth Warren bid: 8\n",
"\tDonald Trump bid: 8\n",
"\tKanye West bid: 10\n",
"\tElizabeth Warren bid: 10\n",
"Selected: Kanye West\n",
"\n",
"\n",
"(Kanye West): Yo, yo, yo, let me jump in here. First of all, I gotta say, I love innovation and progress. But we can't forget about the people, man. We need to make sure that this high speed rail system is accessible to everyone, not just the wealthy. And that means we need to invest in public transportation, not just luxury autonomous cars. We need to make sure that people can get from point A to point B safely and efficiently, without breaking the bank. And let me tell you, we can do it in style too. We can have art installations and live performances on the trains, making it a cultural experience. *starts nodding head*\n",
"(Kanye West): Yo, yo, yo, let me tell you something. This high-speed rail project is the future, and I'm all about the future. We need to think big and think outside the box. How about we make the trains run on solar power? That's right, solar power. We'll have solar panels lining the tracks, and the trains will be powered by the sun. It's a game-changer, folks. And we'll make sure the design is sleek and modern, like a work of art. *starts to dance*\n",
"\n",
"\n",
"Bids:\n",
"\tDonald Trump bid: 7\n",
"\tKanye West bid: 2\n",
"\tKanye West bid: 1\n",
"\tElizabeth Warren bid: 1\n",
"Selected: Donald Trump\n",
"\n",
"\n",
"(Donald Trump): Kanye, I hear what you're saying, but let's not forget about the importance of luxury and comfort. We need to make sure that our high speed rail system is not only accessible, but also enjoyable. That's why I propose that we have different tiers of service, from economy to first class, so that everyone can choose the level of luxury they want. And let me tell you, the first class experience will be something else. We're talking about gourmet meals, personal attendants, and even spa services. It's going to be tremendous, folks. *smirks confidently*\n",
"(Donald Trump): Kanye, you're a great artist, but this is about practicality. Solar power is too expensive and unreliable. We need to focus on what works, and that's clean coal. And as for the design, we'll make it beautiful, but we won't sacrifice efficiency for aesthetics. We need a leader who knows how to balance both. *stands tall*\n",
"\n",
"\n",
"Bids:\n",
"\tDonald Trump bid: 2\n",
"\tDonald Trump bid: 9\n",
"\tKanye West bid: 8\n",
"\tElizabeth Warren bid: 10\n",
"Selected: Elizabeth Warren\n",
"\n",
"\n",
"(Elizabeth Warren): I agree with Kanye that we need to prioritize accessibility and affordability for all Americans. But we also need to think about the environmental impact of this system. That's why I propose that we invest in renewable energy sources to power our high speed rail system, such as solar and wind power. We can also use this opportunity to create green jobs and reduce our carbon footprint. And let's not forget about the importance of public input and transparency in this process. We need to engage with communities and listen to their concerns and ideas. *raises hand in emphasis*\n",
"(Elizabeth Warren): Thank you, Kanye, for your innovative idea. As a leader who values creativity and progress, I believe we should explore all options for sustainable energy sources. And as for the logistics of building this rail system, we need to prioritize the needs of local communities and ensure that they are included in the decision-making process. This project should benefit everyone, not just a select few. *gestures inclusively*\n",
"\n",
"\n",
"Bids:\n",
@ -736,37 +736,37 @@
"Selected: Donald Trump\n",
"\n",
"\n",
"(Donald Trump): Let me tell you, Elizabeth, I agree that we need to think about the environment, but we also need to think about the economy. That's why I propose that we use American-made materials and labor to build this high speed rail system. We're going to create jobs and boost our economy, all while creating a world-class transportation system. And let me tell you, it's going to be beautiful. We're going to have the best trains, the best tracks, and the best stations. It's going to be tremendous, folks. *smiles confidently*\n",
"(Donald Trump): Let me tell you, Elizabeth, you're all talk and no action. We need a leader who knows how to get things done, not just talk about it. And as for the logistics, we need to prioritize efficiency and speed. We can't let the needs of a few hold up progress for the many. We need to cut through the red tape and get this project moving. And let me tell you, we'll make sure it's profitable too. *smirks confidently*\n",
"\n",
"\n",
"Bids:\n",
"\tDonald Trump bid: 2\n",
"\tKanye West bid: 7\n",
"\tElizabeth Warren bid: 8\n",
"\tKanye West bid: 8\n",
"\tElizabeth Warren bid: 10\n",
"Selected: Elizabeth Warren\n",
"\n",
"\n",
"(Elizabeth Warren): Thank you, but let's not forget that we also need to prioritize safety and reliability. We can't cut corners or sacrifice quality for the sake of speed or cost. That's why I propose that we have rigorous safety and maintenance standards, with regular inspections and repairs. And we need to invest in training and support for our rail workers, so that they can operate and maintain this system with the highest level of expertise and care. *firmly nods head*\n",
"(Elizabeth Warren): Thank you, but I disagree. We can't sacrifice the needs of local communities for the sake of speed and profit. We need to find a balance that benefits everyone. And as for profitability, we can't rely solely on private investors. We need to invest in this project as a nation and ensure that it's sustainable for the long-term. *stands firm*\n",
"\n",
"\n",
"Bids:\n",
"\tDonald Trump bid: 2\n",
"\tKanye West bid: 1\n",
"\tElizabeth Warren bid: 1\n",
"\tDonald Trump bid: 8\n",
"\tKanye West bid: 2\n",
"\tElizabeth Warren bid: 2\n",
"Selected: Donald Trump\n",
"\n",
"\n",
"(Donald Trump): Let me tell you, Elizabeth, safety is important, but we also need to think about efficiency and speed. That's why I propose that we use the latest technology, such as artificial intelligence and machine learning, to monitor and maintain our high speed rail system. We can detect and fix any issues before they become a problem, ensuring that our trains run smoothly and on time. And let me tell you, we're going to be the envy of the world with this system. It's going to be tremendous, folks. *smirks confidently*\n",
"(Donald Trump): Let me tell you, Elizabeth, you're just not getting it. We need to prioritize progress and efficiency. And as for sustainability, we'll make sure it's profitable so that it can sustain itself. We'll bring in private investors and make sure it's a win-win for everyone. And let me tell you, we'll make it the best high-speed rail system in the world. *smiles confidently*\n",
"\n",
"\n",
"Bids:\n",
"\tDonald Trump bid: 2\n",
"\tKanye West bid: 8\n",
"\tElizabeth Warren bid: 8\n",
"Selected: Kanye West\n",
"\tElizabeth Warren bid: 10\n",
"Selected: Elizabeth Warren\n",
"\n",
"\n",
"(Kanye West): Yo, yo, yo, let me jump in here again. I hear what both of y'all are saying, but let's not forget about the culture, man. We need to make sure that this high speed rail system reflects the diversity and creativity of our country. That means we need to have art installations, live performances, and even fashion shows on the trains. We can showcase the best of American culture and inspire people from all over the world. And let me tell you, it's going to be a vibe. *starts swaying to the beat*\n",
"(Elizabeth Warren): Thank you, but I believe we need to prioritize sustainability and inclusivity over profit. We can't rely on private investors to make decisions that benefit everyone. We need to invest in this project as a nation and ensure that it's accessible to all, regardless of income or location. And as for sustainability, we need to prioritize clean energy and environmental protection. *stands tall*\n",
"\n",
"\n"
]
@ -780,7 +780,8 @@
" agents=characters,\n",
" selection_function=select_next_speaker\n",
")\n",
"simulator.reset('Debate Moderator', specified_topic)\n",
"simulator.reset()\n",
"simulator.inject('Debate Moderator', specified_topic)\n",
"print(f\"(Debate Moderator): {specified_topic}\")\n",
"print('\\n')\n",
"\n",

@ -22,13 +22,11 @@
"metadata": {},
"outputs": [],
"source": [
"from typing import List, Dict\n",
"from typing import List, Dict, Callable\n",
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.schema import (\n",
" AIMessage,\n",
" HumanMessage,\n",
" SystemMessage,\n",
" BaseMessage,\n",
")"
]
},
@ -50,36 +48,40 @@
"metadata": {},
"outputs": [],
"source": [
"class DialogueAgent():\n",
"\n",
"class DialogueAgent:\n",
" def __init__(\n",
" self,\n",
" name,\n",
" name: str,\n",
" system_message: SystemMessage,\n",
" model: ChatOpenAI,\n",
" ) -> None:\n",
" self.name = name\n",
" self.system_message = system_message\n",
" self.model = model\n",
" self.message_history = f\"\"\"Here is the conversation so far.\n",
" \"\"\"\n",
" self.prefix = f'\\n{self.name}:'\n",
" self.prefix = f\"{self.name}: \"\n",
" self.reset()\n",
" \n",
" def reset(self):\n",
" self.message_history = [\"Here is the conversation so far.\"]\n",
"\n",
" def send(self) -> str:\n",
" \"\"\"\n",
" Applies the chatmodel to the message history\n",
" and returns the message string\n",
" \"\"\"\n",
" message = self.model(\n",
" [self.system_message, \n",
" HumanMessage(content=self.message_history+self.prefix)])\n",
" [\n",
" self.system_message,\n",
" HumanMessage(content=\"\\n\".join(self.message_history + [self.prefix])),\n",
" ]\n",
" )\n",
" return message.content\n",
" \n",
"\n",
" def receive(self, name: str, message: str) -> None:\n",
" \"\"\"\n",
" Concatenates {message} spoken by {name} into message history\n",
" \"\"\"\n",
" self.message_history += f'\\n{name}: {message}'"
" self.message_history.append(f\"{name}: {message}\")"
]
},
{
@ -101,37 +103,45 @@
"metadata": {},
"outputs": [],
"source": [
"class DialogueSimulator():\n",
" \n",
" def __init__(self, agents: List[DialogueAgent]):\n",
"class DialogueSimulator:\n",
" def __init__(\n",
" self,\n",
" agents: List[DialogueAgent],\n",
" selection_function: Callable[[int, List[DialogueAgent]], int],\n",
" ) -> None:\n",
" self.agents = agents\n",
" self._step = 0\n",
" self.select_next_speaker = selection_function\n",
" \n",
" def reset(self, name: str, message: str):\n",
" def reset(self):\n",
" for agent in self.agents:\n",
" agent.reset()\n",
"\n",
" def inject(self, name: str, message: str):\n",
" \"\"\"\n",
" Initiates the conversation with a {message} from {name}\n",
" \"\"\"\n",
" for agent in self.agents:\n",
" agent.receive(name, message)\n",
" \n",
" def select_next_speaker(self, step: int) -> int:\n",
" idx = (step + 1) % len(self.agents)\n",
" return idx\n",
" \n",
"\n",
" # increment time\n",
" self._step += 1\n",
"\n",
" def step(self) -> tuple[str, str]:\n",
" # 1. choose the next speaker\n",
" speaker = self.agents[self.select_next_speaker(self._step)]\n",
" \n",
" speaker_idx = self.select_next_speaker(self._step, self.agents)\n",
" speaker = self.agents[speaker_idx]\n",
"\n",
" # 2. next speaker sends message\n",
" message = speaker.send()\n",
" \n",
"\n",
" # 3. everyone receives message\n",
" for receiver in self.agents:\n",
" receiver.receive(speaker.name, message)\n",
" \n",
"\n",
" # 4. increment time\n",
" self._step += 1\n",
" \n",
"\n",
" return speaker.name, message"
]
},
@ -207,9 +217,9 @@
"output_type": "stream",
"text": [
"Protagonist Description:\n",
"Harry Potter, you are a brave and resourceful wizard. Your lightning scar and famous name precede you, but it is your heart that truly sets you apart. Your love and loyalty for your friends has been tested time and time again, and you have never faltered in your determination to vanquish evil.\n",
"\"Harry Potter, you are the chosen one, with a lightning scar on your forehead. Your bravery and loyalty inspire all those around you. You have faced Voldemort before, and now it's time to complete your mission and destroy each of his horcruxes. Are you ready?\"\n",
"Storyteller Description:\n",
"Dear Dungeon Master, you are a master of imagination, weaving enticing tales of adventure with a flick of your wrist. A patient guide, you lead Harry Potter through the perilous journey of finding Lord Voldemort's horcruxes, instilling excitement and wonder at every turn. Your storytelling prowess enchants all who dare to listen.\n"
"Dear Dungeon Master, you are the master of mysteries, the weaver of worlds, the architect of adventure, and the gatekeeper to the realm of imagination. Your voice carries us to distant lands, and your commands guide us through trials and tribulations. In your hands, we find fortune and glory. Lead us on, oh Dungeon Master.\n"
]
}
],
@ -229,7 +239,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@ -275,7 +285,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@ -286,7 +296,7 @@
"Find all of Lord Voldemort's seven horcruxes.\n",
"\n",
"Detailed quest:\n",
"Harry Potter, you must journey to the hidden cave where one of Voldemort's horcruxes resides. The cave is guarded by enchanted creatures and curses that can only be lifted by a unique magical potion. Use your wit and skill to obtain the ingredients, brew the potion, and retrieve the horcrux before time runs out.\n",
"Harry, you must venture to the depths of the Forbidden Forest where you will find a hidden labyrinth. Within it, lies one of Voldemort's horcruxes, the locket. But beware, the labyrinth is heavily guarded by dark creatures and spells, and time is running out. Can you find the locket before it's too late?\n",
"\n"
]
}
@ -319,7 +329,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
@ -333,38 +343,43 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"def select_next_speaker(step: int, agents: List[DialogueAgent]) -> int:\n",
" idx = step % len(agents)\n",
" return idx"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(Dungeon Master): Harry Potter, you must journey to the hidden cave where one of Voldemort's horcruxes resides. The cave is guarded by enchanted creatures and curses that can only be lifted by a unique magical potion. Use your wit and skill to obtain the ingredients, brew the potion, and retrieve the horcrux before time runs out.\n",
"(Dungeon Master): Harry, you must venture to the depths of the Forbidden Forest where you will find a hidden labyrinth. Within it, lies one of Voldemort's horcruxes, the locket. But beware, the labyrinth is heavily guarded by dark creatures and spells, and time is running out. Can you find the locket before it's too late?\n",
"\n",
"\n",
"(Harry Potter): I take a deep breath and focus on the task at hand. I search my bag for any potions or ingredients that may be useful in brewing the unique magical potion. If I don't have any, I will search the surrounding area for any plants or herbs that may be useful. Once I have all the necessary ingredients, I will brew the potion and use it to lift the curses and defeat any enchanted creatures guarding the horcrux. It won't be easy, but I am determined to succeed.\n",
"It is your turn, Dungeon Master.\n",
"(Harry Potter): I take a deep breath and ready my wand. I know this won't be easy, but I'm determined to find that locket and destroy it. I start making my way towards the Forbidden Forest, keeping an eye out for any signs of danger. As I enter the forest, I cast a protective spell around myself and begin to navigate through the trees. I keep my wand at the ready, prepared for any surprises that may come my way. It's going to be a long and difficult journey, but I won't give up until I find that horcrux. It is your turn, Dungeon Master.\n",
"\n",
"\n",
"(Dungeon Master): As you search your bag, you find a few useful potions and ingredients that will aid you in your quest. You also spot some herbs growing nearby that you recognize as key ingredients for the unique magical potion. You gather everything you need and begin brewing the potion. It takes some time, but you manage to create the perfect mixture. As you approach the cave, you drink the potion and feel a surge of power coursing through your veins. The curses and creatures guarding the horcrux are no match for you now. You retrieve the horcrux and add it to your collection. Well done, Harry Potter. But beware, the next horcrux will be even more challenging to obtain.\n",
"It is your turn, Harry Potter.\n",
"(Dungeon Master): As you make your way through the Forbidden Forest, you hear the rustling of leaves and the snapping of twigs. Suddenly, a group of acromantulas, giant spiders, emerge from the trees and begin to surround you. They hiss and bare their fangs, ready to attack. What do you do, Harry?\n",
"\n",
"\n",
"(Harry Potter): I take a moment to catch my breath and assess my next move. I know that the next horcrux will be even more difficult to obtain, but I am ready for the challenge. I consult my map and try to determine the location of the next horcrux. Once I have a general idea, I set off on foot, keeping my wand at the ready in case of any unexpected obstacles. I am determined to find and destroy all of Voldemort's horcruxes, no matter what it takes.\n",
"It is your turn, Dungeon Master.\n",
"(Harry Potter): I quickly cast a spell to create a wall of fire between myself and the acromantulas. I know that they are afraid of fire, so this should keep them at bay for a while. I use this opportunity to continue moving forward, keeping my wand at the ready in case any other creatures try to attack me. I know that I can't let anything stop me from finding that horcrux. It is your turn, Dungeon Master.\n",
"\n",
"\n",
"(Dungeon Master): As you consult your map, you notice that the next horcrux is located in a heavily guarded fortress. The fortress is surrounded by a moat filled with dangerous creatures and the entrance is protected by powerful spells. You will need to come up with a plan to get past the guards and break through the spells. As you approach the fortress, you notice a group of Death Eaters patrolling the perimeter. What do you do, Harry Potter?\n",
"It is your turn, Harry Potter.\n",
"(Dungeon Master): As you continue through the forest, you come across a clearing where you see a group of Death Eaters gathered around a cauldron. They seem to be performing some sort of dark ritual. You recognize one of them as Bellatrix Lestrange. What do you do, Harry?\n",
"\n",
"\n",
"(Harry Potter): I take cover behind a nearby tree and observe the Death Eaters' movements. I try to determine their patrol patterns and identify any weaknesses in their defenses. Once I have a plan, I use my invisibility cloak to sneak past them and make my way to the fortress entrance. I use my knowledge of spells to try and break through the protective enchantments. If that doesn't work, I will try to find another way in, perhaps through a secret passage or hidden entrance. I won't let anything stop me from finding and destroying the next horcrux.\n",
"It is your turn, Dungeon Master.\n",
"(Harry Potter): I hide behind a nearby tree and observe the Death Eaters from a distance. I try to listen in on their conversation to see if I can gather any information about the horcrux or Voldemort's plans. If I can't hear anything useful, I'll wait for them to disperse before continuing on my journey. I know that confronting them directly would be too dangerous, especially with Bellatrix Lestrange present. It is your turn, Dungeon Master.\n",
"\n",
"\n",
"(Dungeon Master): As you observe the Death Eaters, you notice that they have a predictable patrol pattern. You wait for the right moment and use your invisibility cloak to sneak past them undetected. You make your way to the fortress entrance and try to break through the protective enchantments, but they prove to be too strong. You search for another way in and eventually find a hidden entrance that leads you to the horcrux. However, as you reach for it, you trigger a trap that sets off an alarm and alerts the Death Eaters to your presence. You must act quickly to escape before they catch you. What do you do, Harry Potter?\n",
"It is your turn, Harry Potter.\n",
"(Dungeon Master): As you listen in on the Death Eaters' conversation, you hear them mention the location of another horcrux - Nagini, Voldemort's snake. They plan to keep her hidden in a secret chamber within the Ministry of Magic. However, they also mention that the chamber is heavily guarded and only accessible through a secret passage. You realize that this could be a valuable piece of information and decide to make note of it before quietly slipping away. It is your turn, Harry Potter.\n",
"\n",
"\n"
]
@ -374,8 +389,12 @@
"max_iters = 6\n",
"n = 0\n",
"\n",
"simulator = DialogueSimulator(agents=[storyteller, protagonist])\n",
"simulator.reset(storyteller_name, specified_quest)\n",
"simulator = DialogueSimulator(\n",
" agents=[storyteller, protagonist],\n",
" selection_function=select_next_speaker\n",
")\n",
"simulator.reset()\n",
"simulator.inject(storyteller_name, specified_quest)\n",
"print(f\"({storyteller_name}): {specified_quest}\")\n",
"print('\\n')\n",
"\n",
@ -385,13 +404,6 @@
" print('\\n')\n",
" n += 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@ -410,7 +422,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.9.16"
}
},
"nbformat": 4,

Loading…
Cancel
Save