Export Chonkie’s Chunks into a Weaviate collection.
The WeaviateHandshake class provides seamless integration between Chonkie’s chunking system and Weaviate, a powerful vector database.Embed and store your Chonkie chunks in Weaviate without ever leaving the Chonkie SDK.
from chonkie import WeaviateHandshake# Initialize with default settings (local Weaviate)handshake = WeaviateHandshake()# Or connect to a Weaviate serverhandshake = WeaviateHandshake(url="http://localhost:8080", api_key= "YOUR_API_KEY")
from chonkie import WeaviateHandshake, SemanticChunker # Initialize the handshakehandshake = WeaviateHandshake( url="YOUR_CLOUD_URL", api_key="YOUR_API_KEY", collection_name="my_documents")# Create some chunkschunker = SemanticChunker()chunks = chunker.chunk("Chonkie loves to chonk your texts!")# Write chunks to Weaviatehandshake.write(chunks)
You can retrieve the most similar chunks from your Weaviate collection using the search method:
Copy
Ask AI
from chonkie import WeaviateHandshake# Initialize the handshakehandshake = WeaviateHandshake( url="YOUR_CLOUD_URL", api_key="YOUR_API_KEY", collection_name="my_documents")results = handshake.search(query="chonk your texts", limit=2)for result in results: print(result["score"], result["text"])