> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.storages.vectordb storages.qdrant

<a id="camel.storages.vectordb_storages.qdrant" />

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage" />

## QdrantStorage

```python theme={"system"}
class QdrantStorage(BaseVectorStorage):
```

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 initializing `QdrantClient`.

**Note:**

* 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.
* If `url_and_api_key` is not provided and `path` is given, the client
  will use the local path to initialize Qdrant.
* If neither `url_and_api_key` nor `path` is provided, the client will
  be initialized with an in-memory storage (`":memory:"`).

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    vector_dim: int,
    collection_name: Optional[str] = None,
    url_and_api_key: Optional[Tuple[str, str]] = None,
    path: Optional[str] = None,
    distance: VectorDistance = VectorDistance.COSINE,
    delete_collection_on_del: bool = False,
    **kwargs: Any
):
```

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.__del__" />

### **del**

```python theme={"system"}
def __del__(self):
```

Deletes the collection if :obj:`del_collection` is set to
:obj:`True`.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage._create_client" />

### \_create\_client

```python theme={"system"}
def _create_client(
    self,
    url_and_api_key: Optional[Tuple[str, str]],
    path: Optional[str],
    **kwargs: Any
):
```

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage._check_and_create_collection" />

### \_check\_and\_create\_collection

```python theme={"system"}
def _check_and_create_collection(self):
```

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage._create_collection" />

### \_create\_collection

```python theme={"system"}
def _create_collection(
    self,
    collection_name: str,
    size: int,
    distance: VectorDistance = VectorDistance.COSINE,
    **kwargs: Any
):
```

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.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage._delete_collection" />

### \_delete\_collection

```python theme={"system"}
def _delete_collection(self, collection_name: str, **kwargs: Any):
```

Deletes an existing collection from the database.

**Parameters:**

* **collection** (str): Name of the collection to be deleted. \*\*kwargs (Any): Additional keyword arguments.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage._collection_exists" />

### \_collection\_exists

```python theme={"system"}
def _collection_exists(self, collection_name: str):
```

Returns whether the collection exists in the database

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage._generate_collection_name" />

### \_generate\_collection\_name

```python theme={"system"}
def _generate_collection_name(self):
```

Generates a collection name if user doesn't provide

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage._get_collection_info" />

### \_get\_collection\_info

```python theme={"system"}
def _get_collection_info(self, collection_name: str):
```

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.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.close_client" />

### close\_client

```python theme={"system"}
def close_client(self, **kwargs):
```

Closes the client connection to the Qdrant storage.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.add" />

### add

```python theme={"system"}
def add(self, records: List[VectorRecord], **kwargs):
```

Adds a list of vectors to the specified collection.

**Parameters:**

* **vectors** (List\[VectorRecord]): List of vectors to be added. \*\*kwargs (Any): Additional keyword arguments.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.update_payload" />

### update\_payload

```python theme={"system"}
def update_payload(
    self,
    ids: List[str],
    payload: Dict[str, Any],
    **kwargs: Any
):
```

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.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.delete_collection" />

### delete\_collection

```python theme={"system"}
def delete_collection(self):
```

Deletes the entire collection in the Qdrant storage.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.delete" />

### delete

```python theme={"system"}
def delete(
    self,
    ids: Optional[List[str]] = None,
    payload_filter: Optional[Dict[str, Any]] = None,
    **kwargs: Any
):
```

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 to `QdrantClient. delete`.

**Note:**

* If `ids` is provided, the points with these IDs will be deleted
  directly, and the `payload_filter` will be ignored.
* If `ids` is not provided but `payload_filter` is, then points
  matching the `payload_filter` will be deleted.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.status" />

### status

```python theme={"system"}
def status(self):
```

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.query" />

### query

```python theme={"system"}
def query(
    self,
    query: VectorDBQuery,
    filter_conditions: Optional[Dict[str, Any]] = None,
    **kwargs: Any
):
```

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.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.clear" />

### clear

```python theme={"system"}
def clear(self):
```

Remove all vectors from the storage.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.load" />

### load

```python theme={"system"}
def load(self):
```

Load the collection hosted on cloud service.

<a id="camel.storages.vectordb_storages.qdrant.QdrantStorage.client" />

### client

```python theme={"system"}
def client(self):
```

Provides access to the underlying vector database client.
