vectorstore.py — langchain Source File
Architecture documentation for vectorstore.py, a python file in the langchain codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6a2e472d_918c_d305_4626_3bde9a897802["vectorstore.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 6a2e472d_918c_d305_4626_3bde9a897802 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 6a2e472d_918c_d305_4626_3bde9a897802 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 b19a8b7e_fbee_95b1_65b8_509a1ed3cad7["langchain_core._api"] 6a2e472d_918c_d305_4626_3bde9a897802 --> b19a8b7e_fbee_95b1_65b8_509a1ed3cad7 c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"] 6a2e472d_918c_d305_4626_3bde9a897802 --> c554676d_b731_47b2_a98f_c1c2d537c0aa d55af636_303c_0eb6_faee_20d89bd952d5["langchain_core.vectorstores"] 6a2e472d_918c_d305_4626_3bde9a897802 --> d55af636_303c_0eb6_faee_20d89bd952d5 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 6a2e472d_918c_d305_4626_3bde9a897802 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 6bcbe1b6_8195_eae9_29e5_8e80e91eca64["langchain_classic.base_memory"] 6a2e472d_918c_d305_4626_3bde9a897802 --> 6bcbe1b6_8195_eae9_29e5_8e80e91eca64 13daf103_59dd_f0b6_65de_e993fc70ad8a["langchain_classic.memory.utils"] 6a2e472d_918c_d305_4626_3bde9a897802 --> 13daf103_59dd_f0b6_65de_e993fc70ad8a style 6a2e472d_918c_d305_4626_3bde9a897802 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Class for a VectorStore-backed memory object."""
from collections.abc import Sequence
from typing import Any
from langchain_core._api import deprecated
from langchain_core.documents import Document
from langchain_core.vectorstores import VectorStoreRetriever
from pydantic import Field
from langchain_classic.base_memory import BaseMemory
from langchain_classic.memory.utils import get_prompt_input_key
@deprecated(
since="0.3.1",
removal="1.0.0",
message=(
"Please see the migration guide at: "
"https://python.langchain.com/docs/versions/migrating_memory/"
),
)
class VectorStoreRetrieverMemory(BaseMemory):
"""Vector Store Retriever Memory.
Store the conversation history in a vector store and retrieves the relevant
parts of past conversation based on the input.
"""
retriever: VectorStoreRetriever = Field(exclude=True)
"""VectorStoreRetriever object to connect to."""
memory_key: str = "history"
"""Key name to locate the memories in the result of load_memory_variables."""
input_key: str | None = None
"""Key name to index the inputs to load_memory_variables."""
return_docs: bool = False
"""Whether or not to return the result of querying the database directly."""
exclude_input_keys: Sequence[str] = Field(default_factory=tuple)
"""Input keys to exclude in addition to memory key when constructing the document"""
@property
def memory_variables(self) -> list[str]:
"""The list of keys emitted from the load_memory_variables method."""
return [self.memory_key]
def _get_prompt_input_key(self, inputs: dict[str, Any]) -> str:
"""Get the input key for the prompt."""
if self.input_key is None:
return get_prompt_input_key(inputs, self.memory_variables)
return self.input_key
def _documents_to_memory_variables(
self,
docs: list[Document],
) -> dict[str, list[Document] | str]:
result: list[Document] | str
// ... (63 more lines)
Domain
Subdomains
Classes
Dependencies
- collections.abc
- langchain_classic.base_memory
- langchain_classic.memory.utils
- langchain_core._api
- langchain_core.documents
- langchain_core.vectorstores
- pydantic
- typing
Source
Frequently Asked Questions
What does vectorstore.py do?
vectorstore.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What does vectorstore.py depend on?
vectorstore.py imports 8 module(s): collections.abc, langchain_classic.base_memory, langchain_classic.memory.utils, langchain_core._api, langchain_core.documents, langchain_core.vectorstores, pydantic, typing.
Where is vectorstore.py in the architecture?
vectorstore.py is located at libs/langchain/langchain_classic/memory/vectorstore.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/langchain/langchain_classic/memory).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free