The PineconeHandshake class provides seamless integration between Chonkie’s chunking system and Pinecone, a managed vector database.Embed and store your Chonkie chunks in Pinecone directly from the Chonkie SDK.
from chonkie import PineconeHandshake, SemanticChunker # Initialize the handshakehandshake = PineconeHandshake(api_key="YOUR_API_KEY", index_name="my_documents")# Create some chunkschunker = SemanticChunker()chunks = chunker.chunk("Chonkie loves to chonk your texts!")# Write chunks to Pineconehandshake.write(chunks)
You can retrieve the most similar chunks from your Pinecone index using the search method:
from chonkie import PineconeHandshake# Initialize the handshakehandshake = PineconeHandshake(api_key="YOUR_API_KEY", index_name="my_documents")results = handshake.search(query="chonk your texts", limit=2)for result in results: print(result["score"], result["text"])
from chonkie import PineconeHandshake# Initialize the handshakehandshake = PineconeHandshake(api_key="YOUR_API_KEY", index_name="my_documents")embedding = handshake.embedding_model.embed("chonk your texts").tolist()results = handshake.search(embedding=embedding, limit=2)for result in results: print(result["score"], result["text"])
from chonkie import PineconeHandshake, SemanticChunker# Initialize the handshakehandshake = PineconeHandshake(api_key="YOUR_API_KEY", index_name="my_documents")# Create some chunkschunker = SemanticChunker(embedding_model=handshake.embedding_model)chunks = chunker.chunk("Chonkie loves to chonk your texts!")# Search the handshakeresults = handshake.search( embedding=chunks[0].sentences[0].embedding, limit=2,)for result in results: print(result["score"], result["text"])