Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryChat MessagesMemory typesConversation BufferConversation Buffer WindowEntityConversation Knowledge GraphConversation SummaryConversation Summary BufferConversation Token BufferBacked by a Vector StoreMemory in LLMChainMemory in the Multi-Input ChainMemory in AgentMessage Memory in Agent backed by a databaseCustomizing Conversational MemoryCustom MemoryMultiple Memory classesAgentsCallbacksModulesSecurityGuidesMoreModulesMemoryMemory typesBacked by a Vector StoreOn this pageBacked by a Vector StoreVectorStoreRetrieverMemory stores memories in a vector store and queries the top-K most "salient" docs every time it is called.This differs from most of the other Memory classes in that it doesn't explicitly track the order of interactions.In this case, the "docs" are previous conversation snippets. This can be useful to refer to relevant pieces of information that the AI was told earlier in the conversation.from datetime import datetimefrom langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.llms import OpenAIfrom langchain.memory import VectorStoreRetrieverMemoryfrom langchain.chains import ConversationChainfrom langchain.prompts import PromptTemplateInitialize your vector store‚ÄãDepending on the store you choose, this step may look different. Consult the relevant vector store documentation for more details.import faissfrom langchain.docstore import InMemoryDocstorefrom langchain.vectorstores import FAISSembedding_size = 1536 # Dimensions of the OpenAIEmbeddingsindex = faiss.IndexFlatL2(embedding_size)embedding_fn = OpenAIEmbeddings().embed_queryvectorstore = FAISS(embedding_fn, index, InMemoryDocstore({}), {})Create your VectorStoreRetrieverMemory‚ÄãThe
VectorStoreRetrieverMemory stores memories in a vector store and queries the top-K most "salient" docs every time it is called.
VectorStoreRetrieverMemory stores memories in a vector store and queries the top-K most "salient" docs every time it is called. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryChat MessagesMemory typesConversation BufferConversation Buffer WindowEntityConversation Knowledge GraphConversation SummaryConversation Summary BufferConversation Token BufferBacked by a Vector StoreMemory in LLMChainMemory in the Multi-Input ChainMemory in AgentMessage Memory in Agent backed by a databaseCustomizing Conversational MemoryCustom MemoryMultiple Memory classesAgentsCallbacksModulesSecurityGuidesMoreModulesMemoryMemory typesBacked by a Vector StoreOn this pageBacked by a Vector StoreVectorStoreRetrieverMemory stores memories in a vector store and queries the top-K most "salient" docs every time it is called.This differs from most of the other Memory classes in that it doesn't explicitly track the order of interactions.In this case, the "docs" are previous conversation snippets. This can be useful to refer to relevant pieces of information that the AI was told earlier in the conversation.from datetime import datetimefrom langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.llms import OpenAIfrom langchain.memory import VectorStoreRetrieverMemoryfrom langchain.chains import ConversationChainfrom langchain.prompts import PromptTemplateInitialize your vector store‚ÄãDepending on the store you choose, this step may look different. Consult the relevant vector store documentation for more details.import faissfrom langchain.docstore import InMemoryDocstorefrom langchain.vectorstores import FAISSembedding_size = 1536 # Dimensions of the OpenAIEmbeddingsindex = faiss.IndexFlatL2(embedding_size)embedding_fn = OpenAIEmbeddings().embed_queryvectorstore = FAISS(embedding_fn, index, InMemoryDocstore({}), {})Create your VectorStoreRetrieverMemory‚ÄãThe