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.

Installation

Before using the Pinecone handshake, make sure to install the required dependencies:
pip install chonkie[pinecone]

Basic Usage

Initialization

from chonkie import PineconeHandshake

# Initialize with default settings (auto-generated index)
handshake = PineconeHandshake(api_key="YOUR_API_KEY")

# Or connect to an existing Pinecone client
import pinecone
client = pinecone.Pinecone(api_key="YOUR_API_KEY")
handshake = PineconeHandshake(client=client, index_name="my_index")

# Specify embedding model and dimension
handshake = PineconeHandshake(
    api_key="YOUR_API_KEY",
    index_name="my_index",
    embedding_model="minishlab/potion-retrieval-32M",
    dimension=384
)

Writing Chunks to Pinecone

from chonkie import PineconeHandshake, SemanticChunker    

# Initialize the handshake
handshake = PineconeHandshake(api_key="YOUR_API_KEY", index_name="my_documents")

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

# Write chunks to Pinecone
handshake.write(chunks)

Parameters

client
Optional[pinecone.Pinecone]
default:"None"
Pinecone client instance. If not provided, a new client will be created based on other parameters.
api_key
Optional[str]
default:"None"
Pinecone API key for authentication.
index_name
Union[str, Literal['random']]
default:"random"
Name of the index 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.
dimension
Optional[int]
default:"None"
Dimension of the embeddings. If not provided, will be inferred from the embedding model.
**kwargs
Dict[str, Any]
default:"{}"
Additional keyword arguments to pass to the Pinecone client or index creation.