Skip to main content

VectorDBBlock

An implementation of the :obj:MemoryBlock abstract base class for maintaining and retrieving information using vector embeddings within a vector database. Parameters:
  • storage (Optional[BaseVectorStorage], optional): The storage mechanism for the vector database. Defaults to in-memory :obj:Qdrant if not provided. (default: :obj:None)
  • embedding (Optional[BaseEmbedding], optional): Embedding mechanism to convert chat messages into vector representations. Defaults to :obj:OpenAiEmbedding if not provided. (default: :obj:None)

init

retrieve

Retrieves similar records from the vector database based on the content of the keyword. Parameters:
  • keyword (str): This string will be converted into a vector representation to query the database.
  • limit (int, optional): The maximum number of similar messages to retrieve. (default: :obj:3).
Returns: List[ContextRecord]: A list of memory records retrieved from the vector database based on similarity to :obj:current_state.

write_records

Converts the provided chat messages into vector representations and writes them to the vector database. Parameters:
  • records (List[MemoryRecord]): Memory records to be added to the memory.

clear

Removes all records from the vector database memory.