The QdrantHandshake class provides seamless integration between Chonkie’s chunking system and Qdrant, a high-performance vector database.

Embed and store your Chonkie chunks in Qdrant without ever leaving the Chonkie SDK.

Installation

Before using the Qdrant handshake, make sure to install the required dependencies:

pip install chonkie[qdrant]

Basic Usage

Initialization

from chonkie import QdrantHandshake

# Initialize with default settings (in-memory Qdrant)
handshake = QdrantHandshake()

# Or connect to a Qdrant server
handshake = QdrantHandshake(url="http://localhost:6333")

# Or use an existing Qdrant client
from qdrant_client import QdrantClient
client = QdrantClient(":memory:")
handshake = QdrantHandshake(client=client, collection_name="my_collection")

# For Qdrant Cloud
handshake = QdrantHandshake(
    url="YOUR_CLOUD_URL",
    api_key="YOUR_API_KEY"
)

Writing Chunks to Qdrant

from chonkie import QdrantHandshake, SemanticChunker    

# Initialize the handshake
handshake = QdrantHandshake(collection_name="my_documents")

# Create some chunks
chunker = SemanticChunker()
chunks = chunker.chunk("Chonkie loves to chonk your texts!")

# Write chunks to Qdrant
handshake.write(chunks)

Parameters

client
Optional[qdrant_client.QdrantClient]
default:"None"

Qdrant client instance. If not provided, a new client will be created based on other parameters.

collection_name
Union[str, Literal['random']]
default:"random"

Name of the collection to use. If “random”, a unique name will be generated.

embedding_model
Union[str, BaseEmbeddings]
default:"minishlab/potion-retrieval-32M"

Embedding model to use. Can be a model name or a BaseEmbeddings instance.

url
Optional[str]
default:"None"

URL of the Qdrant server. If provided, will connect to this server.

path
Optional[str]
default:"None"

If provided, creates a persistent Qdrant client at the specified path.

api_key
Optional[str]
default:"None"

API key for Qdrant Cloud authentication.