id
stringlengths
14
16
text
stringlengths
44
2.73k
source
stringlengths
49
114
af97060e60c5-2
{entities} Conversation: Human: {input} AI:""" prompt = PromptTemplate( input_variables=["entities", "input"], template=template ) And now we put it all together! llm = OpenAI(temperature=0) conversation = ConversationChain(llm=llm, prompt=prompt, verbose=True, memory=SpacyEntityMemory()) In the first example, with...
https://python.langchain.com/en/latest/modules/memory/examples/custom_memory.html
af97060e60c5-3
Relevant entity information: Harrison likes machine learning Conversation: Human: What do you think Harrison's favorite subject in college was? AI: > Finished ConversationChain chain. ' From what I know about Harrison, I believe his favorite subject in college was machine learning. He has expressed a strong interest in...
https://python.langchain.com/en/latest/modules/memory/examples/custom_memory.html
eb167db74f6d-0
.ipynb .pdf ConversationBufferMemory Contents Using in a chain ConversationBufferMemory# This notebook shows how to use ConversationBufferMemory. This memory allows for storing of messages and then extracts the messages in a variable. We can first extract it as a string. from langchain.memory import ConversationBuffe...
https://python.langchain.com/en/latest/modules/memory/types/buffer.html
eb167db74f6d-1
Current conversation: Human: Hi there! AI: > Finished chain. " Hi there! It's nice to meet you. How can I help you today?" conversation.predict(input="I'm doing well! Just having a conversation with an AI.") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation betw...
https://python.langchain.com/en/latest/modules/memory/types/buffer.html
eb167db74f6d-2
Human: Tell me about yourself. AI: > Finished chain. " Sure! I'm an AI created to help people with their everyday tasks. I'm programmed to understand natural language and provide helpful information. I'm also constantly learning and updating my knowledge base so I can provide more accurate and helpful answers." And tha...
https://python.langchain.com/en/latest/modules/memory/types/buffer.html
1bf6b1d2c4a1-0
.ipynb .pdf ConversationTokenBufferMemory Contents Using in a chain ConversationTokenBufferMemory# ConversationTokenBufferMemory keeps a buffer of recent interactions in memory, and uses token length rather than number of interactions to determine when to flush interactions. Let’s first walk through how to use the ut...
https://python.langchain.com/en/latest/modules/memory/types/token_buffer.html
1bf6b1d2c4a1-1
> Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: ...
https://python.langchain.com/en/latest/modules/memory/types/token_buffer.html
1bf6b1d2c4a1-2
AI: Sounds like a productive day! What kind of documentation are you writing? Human: For LangChain! Have you heard of it? AI: > Finished chain. " Yes, I have heard of LangChain! It is a decentralized language-learning platform that connects native speakers and learners in real time. Is that the documentation you're wr...
https://python.langchain.com/en/latest/modules/memory/types/token_buffer.html
676f68c202e4-0
.ipynb .pdf ConversationBufferWindowMemory Contents Using in a chain ConversationBufferWindowMemory# ConversationBufferWindowMemory keeps a list of the interactions of the conversation over time. It only uses the last K interactions. This can be useful for keeping a sliding window of the most recent interactions, so ...
https://python.langchain.com/en/latest/modules/memory/types/buffer_window.html
676f68c202e4-1
memory=ConversationBufferWindowMemory(k=2), verbose=True ) conversation_with_summary.predict(input="Hi, what's up?") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from ...
https://python.langchain.com/en/latest/modules/memory/types/buffer_window.html
676f68c202e4-2
Current conversation: Human: Hi, what's up? AI: Hi there! I'm doing great. I'm currently helping a customer with a technical issue. How about you? Human: What's their issues? AI: The customer is having trouble connecting to their Wi-Fi network. I'm helping them troubleshoot the issue and get them connected. Human: Is...
https://python.langchain.com/en/latest/modules/memory/types/buffer_window.html
76a752a386d8-0
.ipynb .pdf Entity Memory Contents Using in a chain Inspecting the memory store Entity Memory# This notebook shows how to work with a memory module that remembers things about specific entities. It extracts information on entities (using LLMs) and builds up its knowledge about that entity over time (also using LLMs)....
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-1
AIMessage(content=' That sounds like a great project! What kind of project are they working on?', additional_kwargs={})], 'entities': {'Sam': 'Sam is working on a hackathon project with Deven.'}} Using in a chain# Let’s now use it in a chain! from langchain.chains import ConversationChain from langchain.memory import ...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-2
Overall, you are a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether the human needs help with a specific question or just wants to have a conversation about a particular topic, you are here to assist. Context: {'Deven': 'Deven is wor...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-3
You are constantly learning and improving, and your capabilities are constantly evolving. You are able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. You have access to some personalized information provided by the ...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-4
You are an assistant to a human, powered by a large language model trained by OpenAI. You are designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, you are able to generate human-like t...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-5
AI: That sounds like a great project! What kind of project are they working on? Human: They are trying to add more complex memory structures to Langchain AI: That sounds like an interesting project! What kind of memory structures are they trying to add? Last line: Human: They are adding in a key-value store for entit...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-6
Context: {'Deven': 'Deven is working on a hackathon project with Sam, which they are entering into a hackathon. They are trying to add more complex memory structures to Langchain, including a key-value store for entities mentioned so far in the conversation.', 'Sam': 'Sam is working on a hackathon project with Deven, t...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-7
{'Daimon': 'Daimon is a company founded by Sam, a successful entrepreneur.', 'Deven': 'Deven is working on a hackathon project with Sam, which they are ' 'entering into a hackathon. They are trying to add more complex ' 'memory structures to Langchain, including a key-value store for ' 'e...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-8
You are an assistant to a human, powered by a large language model trained by OpenAI. You are designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, you are able to generate human-like t...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-9
Human: What do you know about Deven & Sam? AI: Deven and Sam are working on a hackathon project together, trying to add more complex memory structures to Langchain, including a key-value store for entities mentioned so far in the conversation. They seem to be working hard on this project and have a great idea for how ...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-10
'memory structures, including a key-value store for entities ' 'mentioned so far in the conversation.', 'Sam': 'Sam is working on a hackathon project with Deven, trying to add more ' 'complex memory structures to Langchain, including a key-value store ' 'for entities mentioned so far in t...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-11
Context: {'Deven': 'Deven is working on a hackathon project with Sam, which they are entering into a hackathon. They are trying to add more complex memory structures to Langchain, including a key-value store for entities mentioned so far in the conversation, and seem to be working hard on this project with a great idea...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
76a752a386d8-12
Last line: Human: What do you know about Sam? You: > Finished chain. ' Sam is the founder of a successful company called Daimon. He is also working on a hackathon project with Deven to add more complex memory structures to Langchain. They seem to have a great idea for how the key-value store can help.' previous Convers...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
0bc2dc36c0eb-0
.ipynb .pdf VectorStore-Backed Memory Contents Initialize your VectorStore Create your the VectorStoreRetrieverMemory Using in a chain VectorStore-Backed Memory# VectorStoreRetrieverMemory stores memories in a VectorDB and queries the top-K most “salient” docs every time it is called. This differs from most of the ot...
https://python.langchain.com/en/latest/modules/memory/types/vectorstore_retriever_memory.html
0bc2dc36c0eb-1
memory = VectorStoreRetrieverMemory(retriever=retriever) # When added to an agent, the memory object can save pertinent information from conversations or used tools memory.save_context({"input": "My favorite food is pizza"}, {"output": "thats good to know"}) memory.save_context({"input": "My favorite sport is soccer"},...
https://python.langchain.com/en/latest/modules/memory/types/vectorstore_retriever_memory.html
0bc2dc36c0eb-2
memory=memory, verbose=True ) conversation_with_summary.predict(input="Hi, my name is Perry, what's up?") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context....
https://python.langchain.com/en/latest/modules/memory/types/vectorstore_retriever_memory.html
0bc2dc36c0eb-3
conversation_with_summary.predict(input="Whats my favorite food") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a que...
https://python.langchain.com/en/latest/modules/memory/types/vectorstore_retriever_memory.html
0bc2dc36c0eb-4
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/modules/memory/types/vectorstore_retriever_memory.html
6d7eb4d66184-0
.ipynb .pdf ConversationSummaryBufferMemory Contents Using in a chain ConversationSummaryBufferMemory# ConversationSummaryBufferMemory combines the last two ideas. It keeps a buffer of recent interactions in memory, but rather than just completely flushing old interactions it compiles them into a summary and uses bot...
https://python.langchain.com/en/latest/modules/memory/types/summary_buffer.html
6d7eb4d66184-1
from langchain.chains import ConversationChain conversation_with_summary = ConversationChain( llm=llm, # We set a very low max_token_limit for the purposes of testing. memory=ConversationSummaryBufferMemory(llm=OpenAI(), max_token_limit=40), verbose=True ) conversation_with_summary.predict(input="Hi, w...
https://python.langchain.com/en/latest/modules/memory/types/summary_buffer.html
6d7eb4d66184-2
> Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: ...
https://python.langchain.com/en/latest/modules/memory/types/summary_buffer.html
6d7eb4d66184-3
AI: > Finished chain. ' Oh, okay. What is LangChain?' previous ConversationSummaryMemory next ConversationTokenBufferMemory Contents Using in a chain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/modules/memory/types/summary_buffer.html
c15f54da5a70-0
.ipynb .pdf Conversation Knowledge Graph Memory Contents Using in a chain Conversation Knowledge Graph Memory# This type of memory uses a knowledge graph to recreate memory. Let’s first walk through how to use the utilities from langchain.memory import ConversationKGMemory from langchain.llms import OpenAI llm = Open...
https://python.langchain.com/en/latest/modules/memory/types/kg.html
c15f54da5a70-1
Let’s now use this in a chain! llm = OpenAI(temperature=0) from langchain.prompts.prompt import PromptTemplate from langchain.chains import ConversationChain template = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If ...
https://python.langchain.com/en/latest/modules/memory/types/kg.html
c15f54da5a70-2
> Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. The AI ONLY uses info...
https://python.langchain.com/en/latest/modules/memory/types/kg.html
1261310d29a3-0
.ipynb .pdf ConversationSummaryMemory Contents Using in a chain ConversationSummaryMemory# Now let’s take a look at using a slightly more complex type of memory - ConversationSummaryMemory. This type of memory creates a summary of the conversation over time. This can be useful for condensing information from the conv...
https://python.langchain.com/en/latest/modules/memory/types/summary.html
1261310d29a3-1
conversation_with_summary = ConversationChain( llm=llm, memory=ConversationSummaryMemory(llm=OpenAI()), verbose=True ) conversation_with_summary.predict(input="Hi, what's up?") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an...
https://python.langchain.com/en/latest/modules/memory/types/summary.html
1261310d29a3-2
> Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. Current conversation: ...
https://python.langchain.com/en/latest/modules/memory/types/summary.html
3f56e318c0a4-0
.rst .pdf Tools Tools# Note Conceptual Guide Tools are ways that an agent can use to interact with the outside world. For an overview of what a tool is, how to use them, and a full list of examples, please see the getting started documentation Getting Started Next, we have some examples of customizing and generically w...
https://python.langchain.com/en/latest/modules/agents/tools.html
d15e9ad064ea-0
.rst .pdf Agents Agents# Note Conceptual Guide In this part of the documentation we cover the different types of agents, disregarding which specific tools they are used with. For a high level overview of the different types of agents, see the below documentation. Agent Types For documentation on how to create a custom ...
https://python.langchain.com/en/latest/modules/agents/agents.html
2f447c670609-0
.ipynb .pdf Getting Started Getting Started# Agents use an LLM to determine which actions to take and in what order. An action can either be using a tool and observing its output, or returning to the user. When used correctly agents can be extremely powerful. The purpose of this notebook is to show you how to easily us...
https://python.langchain.com/en/latest/modules/agents/getting_started.html
2f447c670609-1
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) Now let’s test it out! agent.run("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?") > Entering new AgentExecutor chain... I need to find out who Leo DiCaprio's girlfriend is and then calc...
https://python.langchain.com/en/latest/modules/agents/getting_started.html
5309d433b766-0
.rst .pdf Agent Executors Agent Executors# Note Conceptual Guide Agent executors take an agent and tools and use the agent to decide which tools to call and in what order. In this part of the documentation we cover other related functionality to agent executors How to combine agents and vectorstores How to use the asyn...
https://python.langchain.com/en/latest/modules/agents/agent_executors.html
315381446452-0
.rst .pdf Toolkits Toolkits# Note Conceptual Guide This section of documentation covers agents with toolkits - eg an agent applied to a particular use case. See below for a full list of agent toolkits CSV Agent Jira JSON Agent OpenAPI agents Natural Language APIs Pandas Dataframe Agent PowerBI Dataset Agent Python Agen...
https://python.langchain.com/en/latest/modules/agents/toolkits.html
41d049425914-0
.ipynb .pdf How to add SharedMemory to an Agent and its Tools How to add SharedMemory to an Agent and its Tools# This notebook goes over adding memory to both of an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them: Adding mem...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-1
Tool( name = "Summary", func=summry_chain.run, description="useful for when you summarize a conversation. The input to this tool should be a string, representing who will read this summary." ) ] prefix = """Have a conversation with a human, answering the following questions as best you can. ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-2
Action: Search Action Input: "ChatGPT" Observation: Nov 30, 2022 ... We've trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer ... ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-3
Thought: I now know the final answer. Final Answer: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is also capab...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-4
Action Input: Who developed ChatGPT Observation: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large ... Feb 15, 2023 ... Who owns Chat GPT? Chat GPT is owned and developed by AI research and deployment company, OpenAI. Th...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-5
Thought: I now know the final answer Final Answer: ChatGPT was developed by OpenAI. > Finished chain. 'ChatGPT was developed by OpenAI.' agent_chain.run(input="Thanks. Summarize the conversation, for my daughter 5 years old.") > Entering new AgentExecutor chain... Thought: I need to simplify the conversation for a 5 ye...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-6
print(agent_chain.memory.buffer) Human: What is ChatGPT? AI: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is a...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-7
Tool( name = "Summary", func=summry_chain.run, description="useful for when you summarize a conversation. The input to this tool should be a string, representing who will read this summary." ) ] prefix = """Have a conversation with a human, answering the following questions as best you can. ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-8
Action: Search Action Input: "ChatGPT" Observation: Nov 30, 2022 ... We've trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer ... ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-9
Thought: I now know the final answer. Final Answer: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is also capab...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-10
Action Input: Who developed ChatGPT Observation: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large ... Feb 15, 2023 ... Who owns Chat GPT? Chat GPT is owned and developed by AI research and deployment company, OpenAI. Th...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-11
Thought: I now know the final answer Final Answer: ChatGPT was developed by OpenAI. > Finished chain. 'ChatGPT was developed by OpenAI.' agent_chain.run(input="Thanks. Summarize the conversation, for my daughter 5 years old.") > Entering new AgentExecutor chain... Thought: I need to simplify the conversation for a 5 ye...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
41d049425914-12
print(agent_chain.memory.buffer) Human: What is ChatGPT? AI: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is a...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
4a045ba7e7b0-0
.ipynb .pdf How to use the async API for Agents Contents Serial vs. Concurrent Execution Using Tracing with Asynchronous Agents How to use the async API for Agents# LangChain provides async support for Agents by leveraging the asyncio library. Async methods are currently supported for the following Tools: SerpAPIWrap...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-1
] def generate_serially(): for q in questions: llm = OpenAI(temperature=0) tools = load_tools(["llm-math", "serpapi"], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) agent.run(q) s = time.perf_counter() g...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-2
Action Input: "Olivia Wilde boyfriend" Observation: Jason Sudeikis Thought: I need to find out Jason Sudeikis' age Action: Search Action Input: "Jason Sudeikis age" Observation: 47 years Thought: I need to calculate 47 raised to the 0.23 power Action: Calculator Action Input: 47^0.23 Observation: Answer: 2.424278485567...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-3
Action: Search Action Input: "US Open women's final 2019 winner" Observation: Bianca Andreescu defeated Serena Williams in the final, 6–3, 7–5 to win the women's singles tennis title at the 2019 US Open. It was her first major title, and she became the first Canadian, as well as the first player born in the 2000s, to w...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-4
Thought: I now know the final answer Final Answer: Jay-Z is Beyonce's husband and his age raised to the 0.19 power is 2.12624064206896. > Finished chain. Serial executed in 65.11 seconds. async def generate_concurrently(): agents = [] # To make async requests in Tools more efficient, you can pass in your own ai...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-5
> Entering new AgentExecutor chain... > Entering new AgentExecutor chain... I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power. Action: Search Action Input: "Olivia Wilde boyfriend" I need to find out who Beyonce's husband is and then calculate his age raised to the ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-6
Action: Search Action Input: "US Open men's final 2019 winner" Observation: Rafael Nadal defeated Daniil Medvedev in the final, 7–5, 6–3, 5–7, 4–6, 6–4 to win the men's singles tennis title at the 2019 US Open. It was his fourth US ... Thought: Observation: 47 years Thought: I need to find out Max Verstappen's age Acti...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-7
Action: Calculator Action Input: 36^0.334 Observation: Answer: 2.8603798598506933 Thought: I now know the final answer Final Answer: Jay-Z is Beyonce's husband and his age raised to the 0.19 power is 2.12624064206896. > Finished chain. I now know the final answer Final Answer: Max Verstappen, 25 years old, raised to t...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-8
# but you must manually close the client session at the end of your program/event loop aiosession = ClientSession() tracer = LangChainTracer() tracer.load_default_session() manager = CallbackManager([StdOutCallbackHandler(), tracer]) # Pass the manager into the llm if you want llm calls traced. llm = OpenAI(temperature...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4a045ba7e7b0-9
next How to create ChatGPT Clone Contents Serial vs. Concurrent Execution Using Tracing with Asynchronous Agents By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
0bec7429d652-0
.ipynb .pdf How to combine agents and vectorstores Contents Create the Vectorstore Create the Agent Use the Agent solely as a router Multi-Hop vectorstore reasoning How to combine agents and vectorstores# This notebook covers how to combine agents and vectorstores. The use case for this is that you’ve ingested your d...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
0bec7429d652-1
texts = text_splitter.split_documents(documents) embeddings = OpenAIEmbeddings() docsearch = Chroma.from_documents(texts, embeddings, collection_name="state-of-union") Running Chroma using direct local API. Using DuckDB in-memory for database. Data will be transient. state_of_union = RetrievalQA.from_chain_type(llm=llm...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
0bec7429d652-2
), ] # Construct the agent. We will use the default agent type here. # See documentation for a full list of options. agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What did biden say about ketanji brown jackson is the state of the union address?") > Entering n...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
0bec7429d652-3
Action Input: What are the advantages of using ruff over flake8? Observation: Ruff can be used as a drop-in replacement for Flake8 when used (1) without or with a small number of plugins, (2) alongside Black, and (3) on Python 3 code. It also re-implements some of the most popular Flake8 plugins and related code quali...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
0bec7429d652-4
Notice that in the above examples the agent did some extra work after querying the RetrievalQAChain. You can avoid that and just return the result directly. tools = [ Tool( name = "State of Union QA System", func=state_of_union.run, description="useful for when you need to answer questions a...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
0bec7429d652-5
Action Input: What are the advantages of using ruff over flake8? Observation: Ruff can be used as a drop-in replacement for Flake8 when used (1) without or with a small number of plugins, (2) alongside Black, and (3) on Python 3 code. It also re-implements some of the most popular Flake8 plugins and related code quali...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
0bec7429d652-6
Tool( name = "Ruff QA System", func=ruff.run, description="useful for when you need to answer questions about ruff (a python linter). Input should be a fully formed question, not referencing any obscure pronouns from the conversation before." ), ] # Construct the agent. We will use the defau...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
0bec7429d652-7
previous Agent Executors next How to use the async API for Agents Contents Create the Vectorstore Create the Agent Use the Agent solely as a router Multi-Hop vectorstore reasoning By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
e1d12edfd30c-0
.ipynb .pdf How to use a timeout for the agent How to use a timeout for the agent# This notebook walks through how to cap an agent executor after a certain amount of time. This can be useful for safeguarding against long running agent runs. from langchain.agents import load_tools from langchain.agents import initialize...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_time_limit.html
e1d12edfd30c-1
Final Answer: foo > Finished chain. 'foo' Now let’s try it again with the max_execution_time=1 keyword argument. It now stops nicely after 1 second (only one iteration usually) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True, max_execution_time=1) agent.run(adversarial_pro...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_time_limit.html
564b453d9e0d-0
.ipynb .pdf How to access intermediate steps How to access intermediate steps# In order to get more visibility into what an agent is doing, we can also return intermediate steps. This comes in the form of an extra key in the return value, which is a list of (action, observation) tuples. from langchain.agents import loa...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
564b453d9e0d-1
> Finished chain. # The actual return type is a NamedTuple for the agent action, and then an observation print(response["intermediate_steps"]) [(AgentAction(tool='Search', tool_input='Leo DiCaprio girlfriend', log=' I should look up who Leo DiCaprio is dating\nAction: Search\nAction Input: "Leo DiCaprio girlfriend"'), ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
564b453d9e0d-2
], "Answer: 3.991298452658078\n" ] ] previous How to create ChatGPT Clone next How to cap the max number of iterations By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
699ed3f3d42e-0
.ipynb .pdf How to cap the max number of iterations How to cap the max number of iterations# This notebook walks through how to cap an agent at taking a certain number of steps. This can be useful to ensure that they do not go haywire and take too many steps. from langchain.agents import load_tools from langchain.agent...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
699ed3f3d42e-1
Final Answer: foo > Finished chain. 'foo' Now let’s try it again with the max_iterations=2 keyword argument. It now stops nicely after a certain amount of iterations! agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True, max_iterations=2) agent.run(adversarial_prompt) > Enterin...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
699ed3f3d42e-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
4a295188908e-0
.ipynb .pdf How to create ChatGPT Clone How to create ChatGPT Clone# This chain replicates ChatGPT by combining (1) a specific prompt, and (2) the concept of memory. Shows off the example as in https://www.engraved.blog/building-a-virtual-machine-inside/ from langchain import OpenAI, ConversationChain, LLMChain, Prompt...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-1
llm=OpenAI(temperature=0), prompt=prompt, verbose=True, memory=ConversationBufferWindowMemory(k=2), ) output = chatgpt_chain.predict(human_input="I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal o...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-2
Human: I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do not write explanations. Do not type commands unless I instruct you to do so. When I need to tell ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-3
Human: I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do not write explanations. Do not type commands unless I instruct you to do so. When I need to tell ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-4
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Human: I want you to act as a ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-5
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-6
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-7
Assistant: > Finished LLMChain chain. ``` $ echo -e "x=lambda y:y*5+3;print('Result:' + str(x(6)))" > run.py $ python3 run.py Result: 33 ``` output = chatgpt_chain.predict(human_input="""echo -e "print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])" > run.py && python3 run.py""") print(output...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-8
AI: ``` $ touch jokes.txt $ echo "Why did the chicken cross the road? To get to the other side!" >> jokes.txt $ echo "What did the fish say when it hit the wall? Dam!" >> jokes.txt $ echo "Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!" >> jokes.txt ``` Human: echo -e "x=lambda y:y...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-9
print(output) > Entering new LLMChain chain... Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a languag...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-10
AI: ``` $ echo -e "print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])" > run.py $ python3 run.py [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] ``` Human: echo -e "echo 'Hello from Docker" > entrypoint.sh && echo -e "FROM ubuntu:20.04 COPY entrypoint.sh entrypoint.sh ENTRYPOINT ["/bin/sh","entrypoin...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-11
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-12
ENTRYPOINT ["/bin/sh","entrypoint.sh"]">Dockerfile $ docker build . -t my_docker_image $ docker run -t my_docker_image Hello from Docker ``` Human: nvidia-smi Assistant: > Finished LLMChain chain. ``` $ nvidia-smi Sat May 15 21:45:02 2021 +-------------------------------------------------------------------------...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-13
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-14
Hello from Docker ``` Human: nvidia-smi AI: ``` $ nvidia-smi Sat May 15 21:45:02 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 | |-------------------------------+----------------------+----------...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
4a295188908e-15
--- bbc.com ping statistics --- 3 packets transmitted, 3 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 14.945/14.945/14.945/0.000 ms ``` output = chatgpt_chain.predict(human_input="""curl -fsSL "https://api.github.com/repos/pytorch/pytorch/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html