Camel.storages.vectordb storages.qdrant
QdrantStorage
An implementation of the BaseVectorStorage
for interacting with
Qdrant, a vector search engine.
The detailed information about Qdrant is available at:
Qdrant <https://qdrant.tech/>
_
Parameters:
- vector_dim (int): The dimension of storing vectors.
- collection_name (Optional[str], optional): Name for the collection in the Qdrant. If not provided, set it to the current time with iso format. (default: :obj:
None
) - url_and_api_key (Optional[Tuple[str, str]], optional): Tuple containing the URL and API key for connecting to a remote Qdrant instance. (default: :obj:
None
) - path (Optional[str], optional): Path to a directory for initializing a local Qdrant client. (default: :obj:
None
) - distance (VectorDistance, optional): The distance metric for vector comparison (default: :obj:
VectorDistance.COSINE
) - delete_collection_on_del (bool, optional): Flag to determine if the collection should be deleted upon object destruction. (default: :obj:
False
) **kwargs (Any): Additional keyword arguments for initializingQdrantClient
. - Notes: - If
url_and_api_key
is provided, it takes priority and the client will attempt to connect to the remote Qdrant instance using the URL endpoint. - Ifurl_and_api_key
is not provided andpath
is given, the client will use the local path to initialize Qdrant. - If neitherurl_and_api_key
norpath
is provided, the client will be initialized with an in-memory storage (":memory:"
).
init
del
Deletes the collection if :obj:del_collection
is set to
:obj:True
.
_create_client
_check_and_create_collection
_create_collection
Creates a new collection in the database.
Parameters:
- collection_name (str): Name of the collection to be created.
- size (int): Dimensionality of vectors to be stored in this collection.
- distance (VectorDistance, optional): The distance metric to be used for vector similarity. (default: :obj:
VectorDistance.COSINE
) **kwargs (Any): Additional keyword arguments.
_delete_collection
Deletes an existing collection from the database.
Parameters:
- collection (str): Name of the collection to be deleted. **kwargs (Any): Additional keyword arguments.
_collection_exists
Returns whether the collection exists in the database
_generate_collection_name
Generates a collection name if user doesn’t provide
_get_collection_info
Retrieves details of an existing collection.
Parameters:
- collection_name (str): Name of the collection to be checked.
Returns:
Dict[str, Any]: A dictionary containing details about the collection.
close_client
Closes the client connection to the Qdrant storage.
add
Adds a list of vectors to the specified collection.
Parameters:
- vectors (List[VectorRecord]): List of vectors to be added. **kwargs (Any): Additional keyword arguments.
update_payload
Updates the payload of the vectors identified by their IDs.
Parameters:
- ids (List[str]): List of unique identifiers for the vectors to be updated.
- payload (Dict[str, Any]): List of payloads to be updated. **kwargs (Any): Additional keyword arguments.
delete_collection
Deletes the entire collection in the Qdrant storage.
delete
Deletes points from the collection based on either IDs or payload filters.
Parameters:
- ids (Optional[List[str]], optional): List of unique identifiers for the vectors to be deleted.
- payload_filter (Optional[Dict[str, Any]], optional): A filter for the payload to delete points matching specific conditions. If
ids
is provided,payload_filter
will be ignored unless both are combined explicitly. **kwargs (Any): Additional keyword arguments pass toQdrantClient. delete
.
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.
- filter_conditions (Optional[Dict[str, Any]], optional): A dictionary specifying conditions to filter the query results. **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.