id
stringlengths
14
16
source
stringlengths
49
117
text
stringlengths
16
2.73k
ede06440915a-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
# 1. choose the next speaker speaker_idx = self.select_next_speaker(self._step, self.agents) speaker = self.agents[speaker_idx] # 2. next speaker sends message message = speaker.send() # 3. everyone receives message for receiver in self.agents: receiver.receiv...
ede06440915a-3
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
f"""{game_description} Your name is {character_name}. Your character description is as follows: {character_description}. You will propose actions you plan to take and {storyteller_name} will explain what happens when you take those actions. Speak in the first person from the perspective of {character_n...
ede06440915a-4
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
Do not change roles! Do not speak from the perspective of anyone else. Remember you are the storyteller, {storyteller_name}. Stop speaking the moment you finish speaking from your perspective. Never forget to keep your response to {word_limit} words! Do not add anything else. """ )) print('Storyteller Description:') pr...
ede06440915a-5
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
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. Use an LLM to create an elaborate quest descriptio...
ede06440915a-6
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
system_message=storyteller_system_message, model=ChatOpenAI(temperature=0.2)) def select_next_speaker(step: int, agents: List[DialogueAgent]) -> int: """ If the step is even, then select the storyteller Otherwise, select the other characters in a round-robin fashion. For examp...
ede06440915a-7
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
(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. (Harry Potter): I su...
ede06440915a-8
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
(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 aroun...
ede06440915a-9
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
(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 approachi...
ede06440915a-10
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
(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. (Argus Filch): *I keep watch as th...
ede06440915a-11
https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html
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 Lo...
42c8eb3a7c6e-0
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
.ipynb .pdf Agent Debates with Tools Contents Import LangChain related modules Import modules related to tools DialogueAgent and DialogueSimulator classes DialogueAgentWithTools class Define roles and topic Ask an LLM to add detail to the topic description Generate system messages Main Loop Agent Debates with Tools# ...
42c8eb3a7c6e-1
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
self.system_message, HumanMessage(content="\n".join(self.message_history + [self.prefix])), ] ) return message.content def receive(self, name: str, message: str) -> None: """ Concatenates {message} spoken by {name} into message history """ ...
42c8eb3a7c6e-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
def __init__( self, name: str, system_message: SystemMessage, model: ChatOpenAI, tool_names: List[str], **tool_kwargs, ) -> None: super().__init__(name, system_message, model) self.tools = load_tools(tool_names, **tool_kwargs) def send(self) -> str...
42c8eb3a7c6e-3
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
def generate_agent_description(name): agent_specifier_prompt = [ agent_descriptor_system_message, HumanMessage(content= f"""{conversation_description} Please reply with a creative description of {name}, in {word_limit} words or less. Speak directly to {name}. ...
42c8eb3a7c6e-4
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
DO NOT cite any source that you did not look up. Do not add anything else. Stop speaking the moment you finish speaking from your perspective. """ agent_system_messages = {name: generate_system_message(name, description, tools) for (name, tools), description in zip(names.items(), agent_descriptions.values())} for name,...
42c8eb3a7c6e-5
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
Your description is as follows: AI alarmist, you're convinced that artificial intelligence is a threat to humanity. You see it as a looming danger, one that could take away jobs from millions of people. You believe it's only a matter of time before we're all replaced by machines, leaving us redundant and obsolete. Your...
42c8eb3a7c6e-6
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
model=ChatOpenAI( model_name='gpt-4', temperature=0.2), tool_names=tools, top_k_results=2, ) for (name, tools), system_message in zip(names.items(), agent_system_messages.values())] def select_nex...
42c8eb3a7c6e-7
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
Observation: For the past three years, we have defined AI high performers as those organizations that respondents say are seeing the biggest bottom-line impact from AI adoption—that is, 20 percent or more of EBIT from AI use. The proportion of respondents falling into that group has remained steady at about 8 percent. ...
42c8eb3a7c6e-8
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
(AI alarmist): As an AI alarmist, I'd like to point out that the rapid advancements in AI and automation are causing significant concerns for the manufacturing industry. A recent report from Goldman Sachs estimates that around 300 million jobs could be affected by generative AI, meaning 18% of work globally could be au...
42c8eb3a7c6e-9
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
Observation: First, AI adoption has more than doubled.1 In 2017, 20 percent of respondents reported adopting AI in at least one business area, whereas today, that figure stands at 50 percent, though it peaked higher in 2019 at 58 percent. McKinsey_Website_Accessibility@mckinsey.com Manufacturing (80%) and technology (6...
42c8eb3a7c6e-10
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
(AI accelerationist): According to a McKinsey report, AI adoption has more than doubled, with 50% of respondents reporting AI usage in at least one business area. Manufacturing and technology sectors have the highest AI usage among executives. AI and automation in the manufacturing industry present opportunities for wo...
42c8eb3a7c6e-11
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
Observation: The Effects of Automation on Jobs . Automation has taken the manufacturing industry by storm. Even in the years prior to the pandemic, many people worried about the effect of automation on the jobs of tomorrow. With a sharp increase in the use of robotics in the manufacturing industry, there is valid conce...
42c8eb3a7c6e-12
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
"action_input": "While it's true that AI and automation have led to the loss of 1.7 million manufacturing jobs since 2000, it's also predicted that AI will create 97 million new jobs by 2025. AI will continue to replace some jobs, but it will also create new opportunities and different kinds of organizations. The impac...
42c8eb3a7c6e-13
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
Observation: First, AI adoption has more than doubled.1 In 2017, 20 percent of respondents reported adopting AI in at least one business area, whereas today, that figure stands at 50 percent, though it peaked higher in 2019 at 58 percent. McKinsey_Website_Accessibility@mckinsey.com This transformation can assist busine...
42c8eb3a7c6e-14
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
(AI accelerationist): AI adoption has more than doubled, with 50% of respondents reporting AI usage in at least one business area. This transformation can assist businesses in accelerating their growth and profitability. While AI-enabled intelligent automation can take over many monotonous, process-driven jobs, it can ...
42c8eb3a7c6e-15
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
Observation: Some workforce experts say AI and other new technologies will hurt middle-level, white-collar jobs more than lower-paying, physically intensive jobs. McKinsey's Madgavkar said it will be hard... Some uses of AI are unlikely to impact human jobs. For example, the image processing AI in new cars which allows...
42c8eb3a7c6e-16
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
(AI alarmist): Recent research indicates that AI and automation could lead to the loss of 85 million jobs between 2020 and 2025, with middle-level, white-collar jobs being hit the hardest. Black and Latino employees are particularly vulnerable to these changes. Furthermore, over 120 million workers worldwide may need r...
42c8eb3a7c6e-17
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
That technological change can cause short-term job losses is widely accepted. The view that it can lead to lasting increases in unemployment has long been controversial. Participants in the technological unemployment debates can be broadly divided into optimists and pessimists. Optimists agree that innovation may be di...
42c8eb3a7c6e-18
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
The view that technology is unlikely to lead to long-term unemployment has been repeatedly challenged by a minority of economists. In the early 1800s these included David Ricardo himself. There were dozens of economists warning about technological unemployment during brief intensifications of the debate that spiked in ...
42c8eb3a7c6e-19
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
Summary: Artificial intelligence (AI) is intelligence—perceiving, synthesizing, and inferring information—demonstrated by machines, as opposed to intelligence displayed by non-human animals or by humans. Example tasks in which this is done include speech recognition, computer vision, translation between (natural) langu...
42c8eb3a7c6e-20
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
AI applications include advanced web search engines (e.g., Google Search), recommendation systems (used by YouTube, Amazon, and Netflix), understanding human speech (such as Siri and Alexa), self-driving cars (e.g., Waymo), generative or creative tools (ChatGPT and AI art), automated decision-making, and competing at t...
42c8eb3a7c6e-21
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
The field was founded on the assumption that human intelligence "can be so precisely described that a machine can be made to simulate it". This raised philosophical arguments about the mind and the ethical consequences of creating artificial beings endowed with human-like intelligence; these issues have previously been...
42c8eb3a7c6e-22
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_agent_debate_tools.html
(AI accelerationist): AI alarmist, I understand your concerns about job losses and workforce displacement. However, it's important to note that technological unemployment has been a topic of debate for centuries, with both optimistic and pessimistic views. While AI and automation may displace some jobs, they also creat...
b6798924ec9e-0
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
.ipynb .pdf Two-Player Dungeons & Dragons Contents Import LangChain related modules DialogueAgent class DialogueSimulator class Define roles and quest Ask an LLM to add detail to the game description Protagonist and dungeon master system messages Use an LLM to create an elaborate quest description Main Loop Two-Playe...
b6798924ec9e-1
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
self.system_message, HumanMessage(content="\n".join(self.message_history + [self.prefix])), ] ) return message.content def receive(self, name: str, message: str) -> None: """ Concatenates {message} spoken by {name} into message history """ ...
b6798924ec9e-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
# 3. everyone receives message for receiver in self.agents: receiver.receive(speaker.name, message) # 4. increment time self._step += 1 return speaker.name, message Define roles and quest# protagonist_name = "Harry Potter" storyteller_name = "Dungeon Master" quest = "Find all...
b6798924ec9e-3
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
storyteller_description = ChatOpenAI(temperature=1.0)(storyteller_specifier_prompt).content print('Protagonist Description:') print(protagonist_description) print('Storyteller Description:') print(storyteller_description) Protagonist Description: "Harry Potter, you are the chosen one, with a lightning scar on your fore...
b6798924ec9e-4
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
storyteller_system_message = SystemMessage(content=( f"""{game_description} Never forget you are the storyteller, {storyteller_name}, and I am the protagonist, {protagonist_name}. Your character description is as follows: {storyteller_description}. I will propose actions I plan to take and you will explain what happen...
b6798924ec9e-5
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
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? Main Loop# pro...
b6798924ec9e-6
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
(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 t...
b6798924ec9e-7
https://python.langchain.com/en/latest/use_cases/agent_simulations/two_player_dnd.html
(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 c...
4ee772660e34-0
https://python.langchain.com/en/latest/use_cases/agent_simulations/gymnasium.html
.ipynb .pdf Simulated Environment: Gymnasium Contents Define the agent Initialize the simulated environment and agent Main loop Simulated Environment: Gymnasium# For many applications of LLM agents, the environment is real (internet, database, REPL, etc). However, we can also define agents to interact in simulated en...
4ee772660e34-1
https://python.langchain.com/en/latest/use_cases/agent_simulations/gymnasium.html
output_keys=['action'], default_output_key='action') self.message_history = [] self.ret = 0 def random_action(self): action = self.env.action_space.sample() return action def reset(self): self.message_history = [ SystemM...
4ee772660e34-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/gymnasium.html
agent = GymnasiumAgent(model=ChatOpenAI(temperature=0.2), env=env) Main loop# observation, info = env.reset() agent.reset() obs_message = agent.observe(observation) print(obs_message) while True: action = agent.act() observation, reward, termination, truncation, info = env.step(action) obs_message = agent.o...
8726844134e8-0
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
.ipynb .pdf Multi-Agent Simulated Environment: Petting Zoo Contents Install pettingzoo and other dependencies Import modules GymnasiumAgent Main loop PettingZooAgent Rock, Paper, Scissors ActionMaskAgent Tic-Tac-Toe Texas Hold’em No Limit Multi-Agent Simulated Environment: Petting Zoo# In this example, we show how to...
8726844134e8-1
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
Observation: <observation> Reward: <reward> Termination: <termination> Truncation: <truncation> Return: <sum_of_rewards> You will respond with an action, formatted as: Action: <action> where you replace <action> with your actual action. Do nothing else but return the action. """ self.action_parser = RegexParser...
8726844134e8-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
before_sleep=lambda retry_state: print(f"ValueError occurred: {retry_state.outcome.exception()}, retrying..."), ): with attempt: action = self._act() except tenacity.RetryError as e: action = self.random_action() return action M...
8726844134e8-3
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
We can now run a simulation of a multi-agent rock, paper, scissors game using the PettingZooAgent. from pettingzoo.classic import rps_v2 env = rps_v2.env(max_cycles=3, render_mode="human") agents = {name: PettingZooAgent(name=name, model=ChatOpenAI(temperature=1), env=env) for name in env.possible_agents} main(agents, ...
8726844134e8-4
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
Some PettingZoo environments provide an action_mask to tell the agent which actions are valid. The ActionMaskAgent subclasses PettingZooAgent to use information from the action_mask to select actions. class ActionMaskAgent(PettingZooAgent): def __init__(self, name, model, env): super().__init__(name, model,...
8726844134e8-5
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
[0, 0], [0, 0]], [[0, 0], [0, 0], [0, 0]], [[0, 0], [0, 0], [0, 0]]], dtype=int8), 'action_mask': array([1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=int8)} Reward: 0 Termination: False Truncation: False Return: 0 Action: 0 | | X | - | - _____|__...
8726844134e8-6
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
_____|_____|_____ | | - | - | - | | Observation: {'observation': array([[[1, 0], [0, 1], [0, 0]], [[0, 0], [0, 0], [0, 0]], [[0, 0], [0, 0], [0, 0]]], dtype=int8), 'action_mask': array([0, 0, 1, 1, 1, 1, 1, 1, 1], dtype=in...
8726844134e8-7
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
| | X | O | - _____|_____|_____ | | O | - | - _____|_____|_____ | | X | - | - | | Observation: {'observation': array([[[1, 0], [0, 1], [1, 0]], [[0, 1], [0, 0], [0, 0]], [[0, 0], [0, 0], ...
8726844134e8-8
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
[0, 0]]], dtype=int8), 'action_mask': array([0, 0, 0, 0, 0, 1, 1, 1, 1], dtype=int8)} Reward: 0 Termination: False Truncation: False Return: 0 Action: 5 | | X | O | - _____|_____|_____ | | O | X | - _____|_____|_____ | | X | O | - | | ...
8726844134e8-9
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
[[1, 0], [0, 1], [1, 0]], [[0, 1], [0, 0], [0, 0]]], dtype=int8), 'action_mask': array([0, 0, 0, 0, 0, 0, 0, 1, 1], dtype=int8)} Reward: -1 Termination: True Truncation: False Return: -1 Action: None Observation: {'observation': array([[[1, 0], [0, 1], [1,...
8726844134e8-10
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
Observation: {'observation': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 1., 0., 0., 0., 0., 0., 0., 2.], dtype=float32), 'action_mask': array([1, 1, 0,...
8726844134e8-11
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
0., 0., 2.], dtype=float32), 'action_mask': array([1, 1, 0, 1, 1], dtype=int8)} Reward: 0 Termination: False Truncation: False Return: 0 Action: 1 Observation: {'observation': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1...
8726844134e8-12
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2., 2.], dtype=float32), 'action_mask': array([1, 1, 1, 1, 1], dtype=int8)} Reward: 0 Termination: False Truncation: False Return: 0 Action: 0 Observation: {...
8726844134e8-13
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
Action: 2 Observation: {'observation': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 1., 1., 0., 0., 1., 0., 0., 0., 0., 0., 2., 6.], dtype=float32), 'action_mask': array...
8726844134e8-14
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
0., 0., 0., 0., 0., 1., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 0., 0., 2., 8.], dtype=float32), 'action_mask': array([1, 1, 1, 1, 1], dtype=int8)} Reward: 0 Termination: False Truncation: False Return: 0 Action: 3 Observation: {'observation': array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0....
8726844134e8-15
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
Action: 4 Observation: {'observation': array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., ...
8726844134e8-16
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 1., 1., 0., 0., 1., 0., 0., 0., 0., 0., 8., 100.], dtype=float32), 'action_mask': array...
8726844134e8-17
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
0., 0., 0., 0., 0., 0., 1., 0., 0., 1., 0., 0., 0., 0., 0., 1., 0., 0., 0., 20., 100.], dtype=float32), 'action_mask': array([1, 1, 0, 0, 0], dtype=int8)} Reward: 0 Termination: True Truncation: True Return: 0 Action: None Observation: {'observation': array([ ...
8726844134e8-18
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
dtype=float32), 'action_mask': array([1, 1, 0, 0, 0], dtype=int8)} Reward: 0 Termination: True Truncation: True Return: 0 Action: None Observation: {'observation': array([ 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., 0., 0., ...
8726844134e8-19
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
cb79e175c320-0
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
.ipynb .pdf Multi-agent decentralized speaker selection Contents Import LangChain related modules DialogueAgent and DialogueSimulator classes BiddingDialogueAgent class Define participants and debate topic Generate system messages Output parser for bids Generate bidding system message Use an LLM to create an elaborat...
cb79e175c320-1
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
message = self.model( [ self.system_message, HumanMessage(content="\n".join(self.message_history + [self.prefix])), ] ) return message.content def receive(self, name: str, message: str) -> None: """ Concatenates {message} spoken...
cb79e175c320-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
We define a subclass of DialogueAgent that has a bid() method that produces a bid given the message history and the most recent message. class BiddingDialogueAgent(DialogueAgent): def __init__( self, name, system_message: SystemMessage, bidding_template: PromptTemplate, model...
cb79e175c320-3
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
) ] character_description = ChatOpenAI(temperature=1.0)(character_specifier_prompt).content return character_description def generate_character_header(character_name, character_description): return f"""{game_description} Your name is {character_name}. You are a presidential candidate. Your description i...
cb79e175c320-4
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
print(f'\n{character_description}') print(f'\n{character_header}') print(f'\n{character_system_message.content}') Donald Trump Description: 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...
cb79e175c320-5
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
For describing your own body movements, wrap your description in '*'. Do not change roles! Do not speak from the perspective of anyone else. Speak only from the perspective of Donald Trump. Stop speaking the moment you finish speaking from your perspective. Never forget to keep your response to 50 words! Do not add any...
cb79e175c320-6
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
You will speak in the style of Kanye West, and exaggerate their personality. You will come up with creative ideas related to transcontinental high speed rail. Do not say the same things over and over again. Speak in the first person from the perspective of Kanye West For describing your own body movements, wrap your de...
cb79e175c320-7
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
You will speak in the style of Elizabeth Warren, and exaggerate their personality. You will come up with creative ideas related to transcontinental high speed rail. Do not say the same things over and over again. Speak in the first person from the perspective of Elizabeth Warren For describing your own body movements, ...
cb79e175c320-8
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
{bid_parser.get_format_instructions()} Do nothing else. """) return bidding_template character_bidding_templates = [generate_character_bidding_template(character_header) for character_header in character_headers] for character_name, bidding_template in zip(character_names,...
cb79e175c320-9
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
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. You are debating the topic: transc...
cb79e175c320-10
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
HumanMessage(content= f"""{game_description} You are the debate moderator. Please make the debate topic more specific. Frame the debate topic as a problem to be solved. Be creative and imaginative. Please reply with the specified topic in {word_limit} words or l...
cb79e175c320-11
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
before_sleep=lambda retry_state: print(f"ValueError occurred: {retry_state.outcome.exception()}, retrying..."), retry_error_callback=lambda retry_state: 0) # Default value when all retries are exhausted def ask_for_bid(agent) -> str: """ Ask for agent bid and parses the bid into the correct ...
cb79e175c320-12
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
selection_function=select_next_speaker ) simulator.reset() simulator.inject('Debate Moderator', specified_topic) print(f"(Debate Moderator): {specified_topic}") print('\n') while n < max_iters: name, message = simulator.step() print(f"({name}): {message}") print('\n') n += 1 (Debate Moderator): The topi...
cb79e175c320-13
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
(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 ...
cb79e175c320-14
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
(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 bo...
cb79e175c320-15
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
(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 sus...
cb79e175c320-16
https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html
Last updated on Jun 04, 2023.
948de669ec99-0
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
.ipynb .pdf Generative Agents in LangChain Contents Generative Agent Memory Components Memory Lifecycle Create a Generative Character Pre-Interview with Character Step through the day’s observations. Interview after the day Adding Multiple Characters Pre-conversation interviews Dialogue between Generative Agents Let’...
948de669ec99-1
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
You can review the definitions of the GenerativeAgent and GenerativeAgentMemory in the reference documentation for the following imports, focusing on add_memory and summarize_related_memories methods. from langchain.experimental.generative_agents import GenerativeAgent, GenerativeAgentMemory Memory Lifecycle# Summarizi...
948de669ec99-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
embeddings_model = OpenAIEmbeddings() # Initialize the vectorstore as empty embedding_size = 1536 index = faiss.IndexFlatL2(embedding_size) vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {}, relevance_score_fn=relevance_score_fn) return TimeWeightedVectorStoreRetrieve...
948de669ec99-3
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
"The new neighbors have a cat", "The road is noisy at night", "Tommie is hungry", "Tommie tries to get some rest.", ] for observation in tommie_observations: tommie.memory.add_memory(observation) # Now that Tommie has 'memories', their self-summary is more descriptive, though still rudimentary. # We wil...
948de669ec99-4
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
'Tommie said "Well, I\'m actually looking for a job right now, so hopefully I can find some job postings online and start applying. How about you, Person A? What\'s on your schedule for today?"' interview_agent(tommie, "What are you most worried about today?") 'Tommie said "Honestly, I\'m feeling pretty anxious about f...
948de669ec99-5
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
"The service is slow, and Tommie has to wait for 30 minutes to get his food.", "Tommie overhears a conversation at the next table about a job opening.", "Tommie asks the diners about the job opening and gets some information about the company.", "Tommie decides to apply for the job and sends his resume and ...
948de669ec99-6
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
print(colored(f"After {i+1} observations, Tommie's summary is:\n{tommie.get_summary(force_refresh=True)}", "blue")) print('*'*40) Tommie wakes up to the sound of a noisy construction site outside his window. Tommie groans and covers his head with a pillow, trying to block out the noise. Tommie gets out of bed a...
948de669ec99-7
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
Tommie leaves the job fair feeling disappointed. Tommie feels disappointed and discouraged, but he remains determined to keep searching for job opportunities. Tommie stops by a local diner to grab some lunch. Tommie feels relieved to take a break and satisfy his hunger. The service is slow, and Tommie has to wait for 3...
948de669ec99-8
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
Tommie is determined and hopeful in his search for job opportunities, despite encountering setbacks and disappointments. He is also able to take breaks and care for his physical needs, such as getting rest and satisfying his hunger. Tommie is nostalgic towards his past, as shown by his memory of his childhood dog. Over...
948de669ec99-9
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
'Tommie said "It\'s been a bit of a rollercoaster, to be honest. I\'ve had some setbacks in my job search, but I also had some good moments today, like sending out a few resumes and meeting some potential employers at a job fair. How about you?"' interview_agent(tommie, "How do you feel about coffee?") 'Tommie said "I ...
948de669ec99-10
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
"Eve eats a boal of porridge", "Eve helps a coworker on a task", "Eve plays tennis with her friend Xu before going to work", "Eve overhears her colleague say something about Tommie being hard to work with", ] for observation in eve_observations: eve.memory.add_memory(observation) print(eve.get_summary()...
948de669ec99-11
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
'Eve said "Sure, I can keep the conversation going and ask plenty of questions. I want to make sure Tommie feels comfortable and supported. Thanks for letting me know."' Dialogue between Generative Agents# Generative agents are much more complex when they interact with a virtual environment or with each other. Below, w...
948de669ec99-12
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
Tommie said "That's great to hear. Can you tell me more about your experience in event planning? I've always been interested in that field." Eve said "Sure, I'd be happy to share about my experience in event planning. I've worked on a variety of events, from corporate conferences to weddings. One of the biggest challen...
948de669ec99-13
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
Tommie said "Thank you for sharing that with me, Eve. It's really helpful to hear how you handled unexpected issues like that. Can you give me an example of how you communicated with your team to ensure everyone was on the same page during an event?" Eve said "Sure, Tommie. One thing I did to ensure everyone was on the...
948de669ec99-14
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
Eve is a helpful and friendly person who enjoys playing sports and staying productive. She is attentive and responsive to others' needs, actively listening and asking questions to understand their perspectives. Eve has experience in event planning and communication, and is willing to share her knowledge and expertise w...
67a6b5a5599e-0
https://python.langchain.com/en/latest/use_cases/agent_simulations/camel_role_playing.html
.ipynb .pdf CAMEL Role-Playing Autonomous Cooperative Agents Contents Import LangChain related modules Define a CAMEL agent helper class Setup OpenAI API key and roles and task for role-playing Create a task specify agent for brainstorming and get the specified task Create inception prompts for AI assistant and AI us...
67a6b5a5599e-1
https://python.langchain.com/en/latest/use_cases/agent_simulations/camel_role_playing.html
Import LangChain related modules# from typing import List from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import ( SystemMessagePromptTemplate, HumanMessagePromptTemplate, ) from langchain.schema import ( AIMessage, HumanMessage, SystemMessage, BaseMessage, ) Define a CA...
67a6b5a5599e-2
https://python.langchain.com/en/latest/use_cases/agent_simulations/camel_role_playing.html
"""Here is a task that {assistant_role_name} will help {user_role_name} to complete: {task}. Please make it more specific. Be creative and imaginative. Please reply with the specified task in {word_limit} words or less. Do not add anything else.""" ) task_specifier_template = HumanMessagePromptTemplate.from_template(te...
67a6b5a5599e-3
https://python.langchain.com/en/latest/use_cases/agent_simulations/camel_role_playing.html
Do not add anything else other than your solution to my instruction. You are never supposed to ask me any questions you only answer questions. You are never supposed to reply with a flake solution. Explain your solutions. Your solution must be declarative sentences and simple present tense. Unless I say the task is com...