id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
d2d9be274d33-90
(langchain.llms.Cohere class method) (langchain.llms.CTransformers class method) (langchain.llms.Databricks class method) (langchain.llms.DeepInfra class method) (langchain.llms.FakeListLLM class method) (langchain.llms.ForefrontAI class method) (langchain.llms.GooglePalm class method) (langchain.llms.GooseAI class met...
https://python.langchain.com/en/latest/genindex.html
d2d9be274d33-91
(langchain.llms.VertexAI class method) (langchain.llms.Writer class method) upsert_messages() (langchain.memory.CosmosDBChatMessageHistory method) url (langchain.document_loaders.MathpixPDFLoader property) (langchain.llms.Beam attribute) (langchain.retrievers.ChatGPTPluginRetriever attribute) (langchain.retrievers.Remo...
https://python.langchain.com/en/latest/genindex.html
d2d9be274d33-92
(langchain.chains.VectorDBQAWithSourcesChain attribute) (langchain.prompts.example_selector.SemanticSimilarityExampleSelector attribute) (langchain.retrievers.SelfQueryRetriever attribute) (langchain.retrievers.TimeWeightedVectorStoreRetriever attribute) vectorstore_info (langchain.agents.agent_toolkits.VectorStoreTool...
https://python.langchain.com/en/latest/genindex.html
d2d9be274d33-93
(langchain.llms.OpenAIChat attribute) (langchain.llms.OpenLM attribute) (langchain.llms.Petals attribute) (langchain.llms.PipelineAI attribute) (langchain.llms.PredictionGuard attribute) (langchain.llms.Replicate attribute) (langchain.llms.RWKV attribute) (langchain.llms.SagemakerEndpoint attribute) (langchain.llms.Sel...
https://python.langchain.com/en/latest/genindex.html
d2d9be274d33-94
Wikipedia (class in langchain.docstore) WikipediaLoader (class in langchain.document_loaders) wolfram_alpha_appid (langchain.utilities.WolframAlphaAPIWrapper attribute) writer_api_key (langchain.llms.Writer attribute) writer_org_id (langchain.llms.Writer attribute) Y YoutubeLoader (class in langchain.document_loaders) ...
https://python.langchain.com/en/latest/genindex.html
71977294a4af-0
Search Error Please activate JavaScript to enable the search functionality. Ctrl+K By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/search.html
b82e9ef85278-0
.rst .pdf API References API References# Full documentation on all methods, classes, and APIs in LangChain. Models Prompts Indexes Memory Chains Agents Utilities Experimental Modules previous Installation next Models By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference.html
ea1ee61d6e72-0
.rst .pdf Integrations Contents Integrations by Module All Integrations Integrations# LangChain integrates with many LLMs, systems, and products. Integrations by Module# Integrations grouped by the core LangChain module they map to: LLM Providers Chat Model Providers Text Embedding Model Providers Document Loader Int...
https://python.langchain.com/en/latest/integrations.html
ea1ee61d6e72-1
Writer Yeager.ai Zilliz previous Experimental Modules next AI21 Labs Contents Integrations by Module All Integrations By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/integrations.html
b3abbef79756-0
.rst .pdf Prompts Contents Getting Started Go Deeper Prompts# Note Conceptual Guide The new way of programming models is through prompts. A “prompt” refers to the input to the model. This input is rarely hard coded, but rather is often constructed from multiple components. A PromptTemplate is responsible for the cons...
https://python.langchain.com/en/latest/modules/prompts.html
ce4d451d4c11-0
.rst .pdf Models Contents Getting Started Go Deeper Models# Note Conceptual Guide This section of the documentation deals with different types of models that are used in LangChain. On this page we will go over the model types at a high level, but we have individual pages for each model type. The pages contain more de...
https://python.langchain.com/en/latest/modules/models.html
a3adb47bf4e2-0
.rst .pdf Memory Memory# Note Conceptual Guide By default, Chains and Agents are stateless, meaning that they treat each incoming query independently (as are the underlying LLMs and chat models). In some applications (chatbots being a GREAT example) it is highly important to remember previous interactions, both at a sh...
https://python.langchain.com/en/latest/modules/memory.html
6c6aff63f9c0-0
.rst .pdf Chains Chains# Note Conceptual Guide Using an LLM in isolation is fine for some simple applications, but many more complex ones require chaining LLMs - either with each other or with other experts. LangChain provides a standard interface for Chains, as well as some common implementations of chains for ease of...
https://python.langchain.com/en/latest/modules/chains.html
43d084bac0f9-0
.rst .pdf Agents Contents Action Agents Plan-and-Execute Agents Agents# Note Conceptual Guide Some applications will require not just a predetermined chain of calls to LLMs/other tools, but potentially an unknown chain that depends on the user’s input. In these types of chains, there is a “agent” which has access to ...
https://python.langchain.com/en/latest/modules/agents.html
43d084bac0f9-1
The different abstractions involved in agents are as follows: Agent: this is where the logic of the application lives. Agents expose an interface that takes in user input along with a list of previous steps the agent has taken, and returns either an AgentAction or AgentFinish AgentAction corresponds to the tool to use ...
https://python.langchain.com/en/latest/modules/agents.html
43d084bac0f9-2
Agents In this section we cover the different types of agents LangChain supports natively. We then cover how to modify and create your own agents. Toolkits In this section we go over the various toolkits that LangChain supports out of the box, and how to create an agent from them. Agent Executor In this section we go o...
https://python.langchain.com/en/latest/modules/agents.html
f671efad0206-0
.rst .pdf Indexes Contents Go Deeper Indexes# Note Conceptual Guide Indexes refer to ways to structure documents so that LLMs can best interact with them. This module contains utility functions for working with documents, different types of indexes, and then examples for using those indexes in chains. The most common...
https://python.langchain.com/en/latest/modules/indexes.html
f671efad0206-1
previous Zep Memory next Getting Started Contents Go Deeper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/indexes.html
b84b95f739a7-0
.ipynb .pdf Callbacks Contents Callbacks How to use callbacks When do you want to use each of these? Using an existing handler Creating a custom handler Async Callbacks Using multiple handlers, passing in handlers Tracing and Token Counting Tracing Token Counting Callbacks# LangChain provides a callbacks system that ...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-1
CallbackHandlers are objects that implement the CallbackHandler interface, which has a method for each event that can be subscribed to. The CallbackManager will call the appropriate method on each handler when the event is triggered. class BaseCallbackHandler: """Base callback handler that can be used to handle cal...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-2
def on_tool_end(self, output: str, **kwargs: Any) -> Any: """Run when tool ends running.""" def on_tool_error( self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any ) -> Any: """Run when tool errors.""" def on_text(self, text: str, **kwargs: Any) -> Any: """Run on a...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-3
The verbose argument is available on most objects throughout the API (Chains, Models, Tools, Agents, etc.) as a constructor argument, eg. LLMChain(verbose=True), and it is equivalent to passing a ConsoleCallbackHandler to the callbacks argument of that object and all child objects. This is useful for debugging, as it w...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-4
# First, let's explicitly set the StdOutCallbackHandler in `callbacks` chain = LLMChain(llm=llm, prompt=prompt, callbacks=[handler]) chain.run(number=2) # Then, let's use the `verbose` flag to achieve the same result chain = LLMChain(llm=llm, prompt=prompt, verbose=True) chain.run(number=2) # Finally, let's use the req...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-5
chat([HumanMessage(content="Tell me a joke")]) My custom handler, token: My custom handler, token: Why My custom handler, token: did My custom handler, token: the My custom handler, token: tomato My custom handler, token: turn My custom handler, token: red My custom handler, token: ? My custom handler, token: Be...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-6
self, serialized: Dict[str, Any], prompts: List[str], **kwargs: Any ) -> None: """Run when chain starts running.""" print("zzzz....") await asyncio.sleep(0.3) class_name = serialized["name"] print("Hi! I just woke up. Your llm is starting") async def on_llm_end(self, resp...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-7
Sync handler being called in a `thread_pool_executor`: token: they Sync handler being called in a `thread_pool_executor`: token: make Sync handler being called in a `thread_pool_executor`: token: up Sync handler being called in a `thread_pool_executor`: token: everything Sync handler being called in a `thread_pool_...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-8
from langchain.agents import AgentType, initialize_agent, load_tools from langchain.callbacks import tracing_enabled from langchain.llms import OpenAI # First, define custom callback handler implementations class MyCustomHandlerOne(BaseCallbackHandler): def on_llm_start( self, serialized: Dict[str, Any], pr...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-9
handler1 = MyCustomHandlerOne() handler2 = MyCustomHandlerTwo() # Setup the agent. Only the `llm` will issue callbacks for handler2 llm = OpenAI(temperature=0, streaming=True, callbacks=[handler2]) tools = load_tools(["llm-math"], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRI...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-10
on_chain_start LLMChain on_llm_start OpenAI on_llm_start (I'm the second handler!!) OpenAI on_new_token on_new_token ```text on_new_token on_new_token 2 on_new_token ** on_new_token 0 on_new_token . on_new_token 235 on_new_token on_new_token ``` on_new_token ... on_new_token num on_new_token expr on_new_token . on_n...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-11
Using a context manager with tracing_enabled() to trace a particular block of code. Note if the environment variable is set, all code will be traced, regardless of whether or not it’s within the context manager. import os from langchain.agents import AgentType, initialize_agent, load_tools from langchain.callbacks impo...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-12
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: I need to find out the age of the winner Action: Search Action Input: "Rafa...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-13
Action: Calculator Action Input: 29^0.23 Observation: Answer: 2.169459462491557 Thought: I now know the final answer. Final Answer: Harry Styles is Olivia Wilde's boyfriend and his current age raised to the 0.23 power is 2.169459462491557. > Finished chain. # Now, we unset the environment variable and use a context man...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-14
Thought: I now know the final answer Final Answer: Rafael Nadal, aged 36, won the US Open men's final in 2019 and his age raised to the 0.334 power is 3.3098250249682484. > Finished chain. > Entering new AgentExecutor chain... I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the ...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-15
task = asyncio.create_task(agent.arun(questions[0])) # this should not be traced with tracing_enabled() as session: assert session tasks = [agent.arun(q) for q in questions[1:3]] # these should be traced await asyncio.gather(*tasks) await task > Entering new AgentExecutor chain... > Entering new AgentExec...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-16
Action: Search Action Input: "Rafael Nadal age"36 years I need to find out Harry Styles' age. Action: Search Action Input: "Harry Styles age" I need to find out Lewis Hamilton's age Action: Search Action Input: "Lewis Hamilton Age"29 years I need to calculate the age raised to the 0.334 power Action: Calculator Action ...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
b84b95f739a7-17
with get_openai_callback() as cb: await asyncio.gather( *[llm.agenerate(["What is the square root of 4?"]) for _ in range(3)] ) assert cb.total_tokens == total_tokens * 3 # The context manager is concurrency safe task = asyncio.create_task(llm.agenerate(["What is the square root of 4?"])) with get_opena...
https://python.langchain.com/en/latest/modules/callbacks/getting_started.html
d503e05cc4f2-0
.ipynb .pdf Getting Started Contents ChatMessageHistory ConversationBufferMemory Using in a chain Saving Message History Getting Started# This notebook walks through how LangChain thinks about memory. Memory involves keeping a concept of state around throughout a user’s interactions with an language model. A user’s i...
https://python.langchain.com/en/latest/modules/memory/getting_started.html
d503e05cc4f2-1
history.messages [HumanMessage(content='hi!', additional_kwargs={}), AIMessage(content='whats up?', additional_kwargs={})] ConversationBufferMemory# We now show how to use this simple concept in a chain. We first showcase ConversationBufferMemory which is just a wrapper around ChatMessageHistory that extracts the mess...
https://python.langchain.com/en/latest/modules/memory/getting_started.html
d503e05cc4f2-2
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/getting_started.html
d503e05cc4f2-3
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." Saving ...
https://python.langchain.com/en/latest/modules/memory/getting_started.html
e85304beb2f7-0
.rst .pdf How-To Guides Contents Types Usage How-To Guides# Types# The first set of examples all highlight different types of memory. ConversationBufferMemory ConversationBufferWindowMemory Entity Memory Conversation Knowledge Graph Memory ConversationSummaryMemory ConversationSummaryBufferMemory ConversationTokenBuf...
https://python.langchain.com/en/latest/modules/memory/how_to_guides.html
ca8e9923a2a8-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
ca8e9923a2a8-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
ca8e9923a2a8-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
db06f765b064-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
db06f765b064-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
db06f765b064-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
04d311734441-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
04d311734441-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
04d311734441-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
6c4fe9bed78f-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
6c4fe9bed78f-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
6c4fe9bed78f-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
6c4fe9bed78f-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 May 28, 2023.
https://python.langchain.com/en/latest/modules/memory/types/summary_buffer.html
694a2210699e-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
694a2210699e-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
694a2210699e-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
694a2210699e-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
694a2210699e-4
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/modules/memory/types/vectorstore_retriever_memory.html
65bc0897d1d3-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
65bc0897d1d3-1
'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 ConversationEntityMemory from langchain.memory.prompt import ENTITY_MEMORY_CONVERSATION_TEMPLATE from pydantic import BaseM...
https://python.langchain.com/en/latest/modules/memory/types/entity_summary_memory.html
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
65bc0897d1d3-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
afd2c2b97e5a-0
.ipynb .pdf ConversationSummaryMemory Contents Initializing with messages 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 condensin...
https://python.langchain.com/en/latest/modules/memory/types/summary.html
afd2c2b97e5a-1
history.add_user_message("hi") history.add_ai_message("hi there!") memory = ConversationSummaryMemory.from_messages(llm=OpenAI(temperature=0), chat_memory=history, return_messages=True) memory.buffer '\nThe human greets the AI, to which the AI responds with a friendly greeting.' Using in a chain# Let’s walk through an ...
https://python.langchain.com/en/latest/modules/memory/types/summary.html
afd2c2b97e5a-2
Human: Tell me more about it! AI: > Finished chain. " Sure! The customer is having trouble with their computer not connecting to the internet. I'm helping them troubleshoot the issue and figure out what the problem is. So far, we've tried resetting the router and checking the network settings, but the issue still persi...
https://python.langchain.com/en/latest/modules/memory/types/summary.html
3ff1990f44d4-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
3ff1990f44d4-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
3ff1990f44d4-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
f4d1bbbad5cb-0
.ipynb .pdf Motörhead Memory Contents Setup Motörhead Memory# Motörhead is a memory server implemented in Rust. It automatically handles incremental summarization in the background and allows for stateless applications. Setup# See instructions at Motörhead for running the server locally. from langchain.memory.motorhe...
https://python.langchain.com/en/latest/modules/memory/examples/motorhead_memory.html
f4d1bbbad5cb-1
Human: whats my name? AI: > Finished chain. ' You said your name is Bob. Is that correct?' llm_chain.run("whats for dinner?") > Entering new LLMChain chain... Prompt after formatting: You are a chatbot having a conversation with a human. Human: hi im bob AI: Hi Bob, nice to meet you! How are you doing today? Human: wh...
https://python.langchain.com/en/latest/modules/memory/examples/motorhead_memory.html
2e5bf5efdbc6-0
.ipynb .pdf How to add memory to a Multi-Input Chain How to add memory to a Multi-Input Chain# Most memory objects assume a single input. In this notebook, we go over how to add memory to a chain that has multiple inputs. As an example of such a chain, we will add memory to a question/answering chain. This chain takes ...
https://python.langchain.com/en/latest/modules/memory/examples/adding_memory_chain_multiple_inputs.html
2e5bf5efdbc6-1
{context} {chat_history} Human: {human_input} Chatbot:""" prompt = PromptTemplate( input_variables=["chat_history", "human_input", "context"], template=template ) memory = ConversationBufferMemory(memory_key="chat_history", input_key="human_input") chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff...
https://python.langchain.com/en/latest/modules/memory/examples/adding_memory_chain_multiple_inputs.html
456f5439730d-0
.ipynb .pdf How to add Memory to an LLMChain How to add Memory to an LLMChain# This notebook goes over how to use the Memory class with an LLMChain. For the purposes of this walkthrough, we will add the ConversationBufferMemory class, although this can be any memory class. from langchain.memory import ConversationBuff...
https://python.langchain.com/en/latest/modules/memory/examples/adding_memory.html
456f5439730d-1
Human: Hi there my friend AI: Hi there, how are you doing today? Human: Not to bad - how are you? Chatbot: > Finished LLMChain chain. " I'm doing great, thank you for asking!" previous VectorStore-Backed Memory next How to add memory to a Multi-Input Chain By Harrison Chase © Copyright 2023, Harrison Chase....
https://python.langchain.com/en/latest/modules/memory/examples/adding_memory.html
bf929e9f2269-0
.ipynb .pdf Momento Momento# This notebook goes over how to use Momento Cache to store chat message history using the MomentoChatMessageHistory class. See the Momento docs for more detail on how to get set up with Momento. Note that, by default we will create a cache if one with the given name doesn’t already exist. Yo...
https://python.langchain.com/en/latest/modules/memory/examples/momento_chat_message_history.html
dc735e5359f6-0
.ipynb .pdf Adding Message Memory backed by a database to an Agent Adding Message Memory backed by a database to an Agent# This notebook goes over adding memory to an Agent where the memory uses an external message store. Before going through this notebook, please walkthrough the following notebooks, as this will build...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-1
{chat_history} Question: {input} {agent_scratchpad}""" prompt = ZeroShotAgent.create_prompt( tools, prefix=prefix, suffix=suffix, input_variables=["input", "chat_history", "agent_scratchpad"] ) Now we can create the ChatMessageHistory backed by the database. message_history = RedisChatMessageHistory(...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-2
Action: Search Action Input: Population of Canada Observation: The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data. · Canada ... Additional information related to Canadian population trends can be found on Statistics Canada...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-3
> Finished AgentExecutor chain. 'The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data.' To test the memory of this agent, we can ask a followup question that relies on information in the previous exchange to be answered corr...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-4
Action: Search Action Input: National Anthem of Canada Observation: Jun 7, 2010 ... https://twitter.com/CanadaImmigrantCanadian National Anthem O Canada in HQ - complete with lyrics, captions, vocals & music.LYRICS:O Canada! Nov 23, 2022 ... After 100 years of tradition, O Canada was proclaimed Canada's national anthem...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-5
Thought: I now know the final answer. Final Answer: The national anthem of Canada is called "O Canada". > Finished AgentExecutor chain. 'The national anthem of Canada is called "O Canada".' We can see that the agent remembered that the previous question was about Canada, and properly asked Google Search what the name o...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-6
Action: Search Action Input: Population of Canada Observation: The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data. · Canada ... Additional information related to Canadian population trends can be found on Statistics Canada...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-7
> Finished AgentExecutor chain. 'The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data.' agent_without_memory.run("what is their national anthem called?") > Entering new AgentExecutor chain... Thought: I should look up the an...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-8
Action: Search Action Input: national anthem of [country] Observation: Most nation states have an anthem, defined as "a song, as of praise, devotion, or patriotism"; most anthems are either marches or hymns in style. List of all countries around the world with its national anthem. ... Title and lyrics in the language o...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
dc735e5359f6-9
Thought: I now know the final answer Final Answer: The national anthem of [country] is [name of anthem]. > Finished AgentExecutor chain. 'The national anthem of [country] is [name of anthem].' previous How to add Memory to an Agent next Cassandra Chat Message History By Harrison Chase © Copyright 2023, Harri...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
1b8237072c06-0
.ipynb .pdf Zep Memory Contents REACT Agent Chat Message History Example Initialize the Zep Chat Message History Class and initialize the Agent Add some history data Run the agent Inspect the Zep memory Vector search over the Zep memory Zep Memory# REACT Agent Chat Message History Example# This notebook demonstrates ...
https://python.langchain.com/en/latest/modules/memory/examples/zep_memory.html
1b8237072c06-1
session_id = str(uuid4()) # This is a unique identifier for the user # Load your OpenAI key from a .env file from dotenv import load_dotenv load_dotenv() True Initialize the Zep Chat Message History Class and initialize the Agent# ddg = DuckDuckGoSearchRun() tools = [ddg] # Set up Zep Chat History zep_chat_history = Z...
https://python.langchain.com/en/latest/modules/memory/examples/zep_memory.html
1b8237072c06-2
"The most well-known adaptation of Octavia Butler's work is the FX series" " Kindred, based on her novel of the same name." ), }, {"role": "human", "content": "Who were her contemporaries?"}, { "role": "ai", "content": ( "Octavia Butler's contemporaries includ...
https://python.langchain.com/en/latest/modules/memory/examples/zep_memory.html
1b8237072c06-3
), }, ] for msg in test_history: zep_chat_history.append( HumanMessage(content=msg["content"]) if msg["role"] == "human" else AIMessage(content=msg["content"]) ) Run the agent# Doing so will automatically add the input and response to the Zep memory. agent_chain.run( input="WWhat...
https://python.langchain.com/en/latest/modules/memory/examples/zep_memory.html
1b8237072c06-4
Ursula K. Le Guin, Samuel R. Delany, and Joanna Russ. {'role': 'human', 'content': 'What awards did she win?', 'uuid': '9fa75c3c-edae-41e3-b9bc-9fcf16b523c9', 'created_at': '2023-05-25T15:09:41.91662Z', 'token_count': 8} {'role': 'ai', 'content': 'Octavia Butler won the Hugo Award, the Nebula Award, and the MacArthur F...
https://python.langchain.com/en/latest/modules/memory/examples/zep_memory.html