The MilvusHandshake class provides seamless integration between Chonkie’s chunking system and Milvus, a powerful, open-source vector database.Embed and store your Chonkie chunks in a Milvus collection, with automatic schema and index creation, without ever leaving the Chonkie SDK.
from chonkie import MilvusHandshake# Connects to Milvus at http://localhost:19530 by defaulthandshake = MilvusHandshake()
from chonkie import MilvusHandshake# Recommended for connecting to remote or secured instanceshandshake = MilvusHandshake( uri=os.getenv("MILVUS_URI"), user=os.getenv("MILVUS_USER"), api_key=os.getenv("MILVUS_API_KEY"), collection_name="test_collection",)
from chonkie import MilvusHandshake, SentenceChunker# Initialize the handshake for your deploymenthandshake = MilvusHandshake( uri="http://localhost:19530", collection_name="my_documents",)# Create some chunkschunker = SentenceChunker()chunks = chunker.chunk("Milvus stores data in collections. Chonkie makes ingestion easy!")# Write chunks to the Milvus collectionhandshake.write(chunks)
You can retrieve the most similar chunks from your Milvus collection using the search method.
from chonkie import MilvusHandshake# Initialize the handshake to connect to your collectionhandshake = MilvusHandshake( uri="http://localhost:19530", collection_name="my_documents",)results = handshake.search(query="easy data ingestion", limit=2)
from chonkie import MilvusHandshake# Initialize the handshakehandshake = MilvusHandshake( uri="http://localhost:19530", collection_name="my_documents",)# Generate an embedding vector for your queryembedding = handshake.embedding_model.embed("easy data ingestion")results = handshake.search(embedding=embedding, limit=2)