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

# autogen.agentchat.contrib.vectordb.qdrant.QdrantVectorDB

<h2 id="autogen.agentchat.contrib.vectordb.qdrant.QdrantVectorDB" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">QdrantVectorDB</span>
</h2>

```python theme={null}
QdrantVectorDB(
    *,
    client=None,
    embedding_function: EmbeddingFunction = None,
    content_payload_key: str = '_content',
    metadata_payload_key: str = '_metadata',
    collection_options: dict = {},
    **kwargs: Any
)
```

A vector database implementation that uses Qdrant as the backend.<br />Initialize the vector database.<br />

<b>Parameters:</b>

| Name                   | Description                                                                                                                                 |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `client=None`          |                                                                                                                                             |
| `embedding_function`   | **Type:** [EmbeddingFunction](/docs/api-reference/autogen/agentchat/contrib/vectordb/qdrant/EmbeddingFunction)<br /><br />**Default:** None |
| `content_payload_key`  | **Type:** str<br /><br />**Default:** '\_content'                                                                                           |
| `metadata_payload_key` | **Type:** str<br /><br />**Default:** '\_metadata'                                                                                          |
| `collection_options`   | **Type:** dict<br /><br />**Default:** \{}                                                                                                  |
| `**kwargs`             | **Type:** Any                                                                                                                               |

### Class Attributes

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### active\_collection

<br />

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### embedding\_function

<br />

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### type

<br />

<br />

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### create\_collection

```python theme={null}
create_collection(
    self,
    collection_name: str,
    overwrite: bool = False,
    get_or_create: bool = True
) -> None
```

Create a collection in the vector database.<br />Case 1. if the collection does not exist, create the collection.<br />Case 2. the collection exists, if overwrite is True, it will overwrite the collection.<br />Case 3. the collection exists and overwrite is False, if get\_or\_create is True, it will get the collection,
otherwise it raise a ValueError.<br />

<b>Parameters:</b>

| Name              | Description |                                                                                                                                        |
| ----------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `collection_name` | str         | The name of the collection.<br /><br />**Type:** str                                                                                   |
| `overwrite`       | bool        | Whether to overwrite the collection if it exists.<br /><br />Default is False.<br /><br />**Type:** bool<br /><br />**Default:** False |
| `get_or_create`   | bool        | Whether to get the collection if it exists.<br /><br />Default is True.<br /><br />**Type:** bool<br /><br />**Default:** True         |

<b>Returns:</b>

| Type | Description                   |
| ---- | ----------------------------- |
| None | Any \| The collection object. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### delete\_collection

```python theme={null}
delete_collection(self, collection_name: str) -> None
```

Delete the collection from the vector database.<br />

<b>Parameters:</b>

| Name              | Description |                                                      |
| ----------------- | ----------- | ---------------------------------------------------- |
| `collection_name` | str         | The name of the collection.<br /><br />**Type:** str |

<b>Returns:</b>

| Type | Description |
| ---- | ----------- |
| None | Any         |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### delete\_docs

```python theme={null}
delete_docs(
    self,
    ids: list[str | int],
    collection_name: str = None,
    **kwargs
) -> None
```

Delete documents from the collection of the vector database.<br />

<b>Parameters:</b>

| Name              | Description   |                                                                                                               |
| ----------------- | ------------- | ------------------------------------------------------------------------------------------------------------- |
| `ids`             | List\[ItemID] | A list of document ids.<br /><br />Each id is a typed `ItemID`.<br /><br />**Type:** list\[str \| int]        |
| `collection_name` | str           | The name of the collection.<br /><br />Default is None.<br /><br />**Type:** str<br /><br />**Default:** None |
| `**kwargs`        |               |                                                                                                               |

<b>Returns:</b>

| Type | Description |
| ---- | ----------- |
| None | None        |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_collection

```python theme={null}
get_collection(self, collection_name: str = None) -> 
```

Get the collection from the vector database.<br />

<b>Parameters:</b>

| Name              | Description |                                                                                   |
| ----------------- | ----------- | --------------------------------------------------------------------------------- |
| `collection_name` | str         | The name of the collection.<br /><br />**Type:** str<br /><br />**Default:** None |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_docs\_by\_ids

```python theme={null}
get_docs_by_ids(
    self,
    ids: list[str | int] = None,
    collection_name: str = None,
    include=True,
    **kwargs
) -> list[Document]
```

Retrieve documents from the collection of the vector database based on the ids.<br />

<b>Parameters:</b>

| Name              | Description   |                                                                                                                                                                            |
| ----------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ids`             | List\[ItemID] | A list of document ids.<br /><br />If None, will return all the documents.<br /><br />Default is None.<br /><br />**Type:** list\[str \| int]<br /><br />**Default:** None |
| `collection_name` | str           | The name of the collection.<br /><br />Default is None.<br /><br />**Type:** str<br /><br />**Default:** None                                                              |
| `include=True`    |               |                                                                                                                                                                            |
| `**kwargs`        |               |                                                                                                                                                                            |

<b>Returns:</b>

| Type                                                                                    | Description                     |
| --------------------------------------------------------------------------------------- | ------------------------------- |
| list\[[Document](/docs/api-reference/autogen/agentchat/contrib/vectordb/base/Document)] | List\[Document] \| The results. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### insert\_docs

```python theme={null}
insert_docs(
    self,
    docs: list[Document],
    collection_name: str = None,
    upsert: bool = False
) -> None
```

Insert documents into the collection of the vector database.<br />

<b>Parameters:</b>

| Name              | Description     |                                                                                                                                                                                       |
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `docs`            | List\[Document] | A list of documents.<br /><br />Each document is a TypedDict `Document`.<br /><br />**Type:** list\[[Document](/docs/api-reference/autogen/agentchat/contrib/vectordb/base/Document)] |
| `collection_name` | str             | The name of the collection.<br /><br />Default is None.<br /><br />**Type:** str<br /><br />**Default:** None                                                                         |
| `upsert`          | bool            | Whether to update the document if it exists.<br /><br />Default is False.<br /><br />**Type:** bool<br /><br />**Default:** False                                                     |

<b>Returns:</b>

| Type | Description |
| ---- | ----------- |
| None | None        |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### retrieve\_docs

```python theme={null}
retrieve_docs(
    self,
    queries: list[str],
    collection_name: str = None,
    n_results: int = 10,
    distance_threshold: float = 0,
    **kwargs: Any
) -> list[list[tuple[Document, float]]]
```

Retrieve documents from the collection of the vector database based on the queries.<br />

<b>Parameters:</b>

| Name                 | Description   |                                                                                                                                                                                                              |
| -------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `queries`            | List\[str]    | A list of queries.<br /><br />Each query is a string.<br /><br />**Type:** list\[str]                                                                                                                        |
| `collection_name`    | str           | The name of the collection.<br /><br />Default is None.<br /><br />**Type:** str<br /><br />**Default:** None                                                                                                |
| `n_results`          | int           | The number of relevant documents to return.<br /><br />Default is 10.<br /><br />**Type:** int<br /><br />**Default:** 10                                                                                    |
| `distance_threshold` | float         | The threshold for the distance score, only distance smaller than it will be returned.<br /><br />Don't filter with it if ` 0`.<br /><br />Default is 0.<br /><br />**Type:** float<br /><br />**Default:** 0 |
| `**kwargs`           | **Type:** Any |                                                                                                                                                                                                              |

<b>Returns:</b>

| Type                                                                                                          | Description                                                                                                                |
| ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| list\[list\[tuple\[[Document](/docs/api-reference/autogen/agentchat/contrib/vectordb/base/Document), float]]] | QueryResults \| The query results. Each query result is a list of list of tuples containing the document and the distance. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### update\_docs

```python theme={null}
update_docs(
    self,
    docs: list[Document],
    collection_name: str = None
) -> None
```

Update documents in the collection of the vector database.<br />

<b>Parameters:</b>

| Name              | Description     |                                                                                                                                   |
| ----------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `docs`            | List\[Document] | A list of documents.<br /><br />**Type:** list\[[Document](/docs/api-reference/autogen/agentchat/contrib/vectordb/base/Document)] |
| `collection_name` | str             | The name of the collection.<br /><br />Default is None.<br /><br />**Type:** str<br /><br />**Default:** None                     |

<b>Returns:</b>

| Type | Description |
| ---- | ----------- |
| None | None        |

<br />
