Skip to main content

VectorRecord

Encapsulates information about a vector’s unique identifier and its payload, which is primarily used as a data transfer object when saving to vector storage. Parameters:
  • vector (List[float]): The numerical representation of the vector.
  • id (str, optional): A unique identifier for the vector. If not provided, an random uuid will be assigned.
  • payload (Optional[Dict[str, Any]], optional): Any additional metadata or information related to the vector. (default: :obj:None)

VectorDBQuery

Represents a query to a vector database. Parameters:
  • query_vector (List[float]): The numerical representation of the query vector.
  • top_k (int, optional): The number of top similar vectors to retrieve from the database. (default: :obj:1)

init

Pass in query_vector and tok_k as positional arg. Parameters:
  • query_vector (List[float]): The numerical representation of the query vector.
  • top_k (int, optional): The number of top similar vectors to retrieve from the database. (default: :obj:1)

VectorDBQueryResult

Encapsulates the result of a query against a vector database. Parameters:
  • record (VectorRecord): The target vector record.
  • similarity (float): The similarity score between the query vector and the record.

create

A class method to construct a VectorDBQueryResult instance.

VectorDBStatus

Vector database status. Parameters:
  • vector_dim (int): The dimension of stored vectors.
  • vector_count (int): The number of stored vectors.

BaseVectorStorage

An abstract base class for vector storage systems.

add

Saves a list of vector records to the storage. Parameters:
  • records (List[VectorRecord]): List of vector records to be saved. **kwargs (Any): Additional keyword arguments.

delete

Deletes a list of vectors identified by their IDs from the storage. Parameters:
  • ids (List[str]): List of unique identifiers for the vectors to be deleted. **kwargs (Any): Additional keyword arguments.

status

Returns: VectorDBStatus: The vector database status.

query

Searches for similar vectors in the storage based on the provided query. Parameters:
  • query (VectorDBQuery): The query object containing the search vector and the number of top similar vectors to retrieve. **kwargs (Any): Additional keyword arguments.
Returns: List[VectorDBQueryResult]: A list of vectors retrieved from the storage based on similarity to the query vector.

clear

Remove all vectors from the storage.

load

Load the collection hosted on cloud service.

client

Provides access to the underlying vector database client.

get_payloads_by_vector

Returns payloads of top k vector records that closest to the given vector. This function is a wrapper of BaseVectorStorage.query. Parameters:
  • vector (List[float]): The search vector.
  • top_k (int): The number of top similar vectors.
Returns: List[List[Dict[str, Any]]]: A list of vector payloads retrieved from the storage based on similarity to the query vector.