langchain.memory.vectorstore.VectorStoreRetrieverMemory

class langchain.memory.vectorstore.VectorStoreRetrieverMemory(*, retriever: VectorStoreRetriever, memory_key: str = 'history', input_key: Optional[str] = None, return_docs: bool = False, exclude_input_keys: Sequence[str] = None)[source]

Bases: BaseMemory

VectorStoreRetriever-backed memory.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param exclude_input_keys: Sequence[str] [Optional]

Input keys to exclude in addition to memory key when constructing the document

param input_key: Optional[str] = None

Key name to index the inputs to load_memory_variables.

param memory_key: str = 'history'

Key name to locate the memories in the result of load_memory_variables.

param retriever: langchain.vectorstores.base.VectorStoreRetriever [Required]

VectorStoreRetriever object to connect to.

param return_docs: bool = False

Whether or not to return the result of querying the database directly.

clear() None[source]

Nothing to clear.

load_memory_variables(inputs: Dict[str, Any]) Dict[str, Union[List[Document], str]][source]

Return history buffer.

save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) None[source]

Save context from this conversation to buffer.

to_json() Union[SerializedConstructor, SerializedNotImplemented]
to_json_not_implemented() SerializedNotImplemented
property lc_attributes: Dict

Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor.

property lc_namespace: List[str]

Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”]

property lc_secrets: Dict[str, str]

Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”}

property lc_serializable: bool

Return whether or not the class is serializable.

property memory_variables: List[str]

The list of keys emitted from the load_memory_variables method.

model Config

Bases: object

Configuration for this pydantic object.

arbitrary_types_allowed = True