Vectorstore Pinecone Backend

The Pinecone backend: a managed service.

See https://www.pinecone.io/. A vectorstore is one serverless Pinecone index. Its API key is the Secret of the vectorstore’s ApiConnection. The backend embeds the chunks itself and calls the Pinecone index directly. The chunks’ text is in the metadata’s text, where LangChain’s PineconeVectorStore stores it, so indexes that it wrote stay searchable. Dumps are Pinecone backups, which Pinecone keeps, and which require a paid Pinecone plan.

class smarter.apps.vectorstore.backends.pinecone.PineconeBackend(vectorstore, embeddings=None, client=None)[source]

Bases: SmarterVectorstoreBackend

The Pinecone backend.

Parameters:

client (Pinecone | None) – A Pinecone client, e.g. a mock in tests. By default it is created with the API key of the vectorstore’s ApiConnection.

__init__(vectorstore, embeddings=None, client=None)[source]
property client: Pinecone
create()[source]

Create the index or collection.

Return type:

None

create_snapshot(name)[source]

Take a snapshot, or backup.

Return type:

SnapshotInfo

delete(ids)[source]

Delete chunks.

Ids that do not exist are ignored.

Return type:

None

delete_snapshot(name)[source]

Delete a snapshot, or backup.

Return type:

None

drop()[source]

Delete the index or collection, and its data.

Return type:

None

exists()[source]

Whether the index or collection exists.

Return type:

bool

property index
infrastructure_ready()[source]

Whether the index is ready.

Pinecone takes a little while to initialize a new one.

Return type:

tuple[bool, str]

restore_snapshot(name)[source]

Replace the index with a new one from the backup.

Pinecone requires that the index is deleted first.

Return type:

None

search(query, k=4, search_type='similarity', score_threshold=None, fetch_k=None, lambda_mult=None, metadata_filter=None)[source]

Search the index with the query’s embedding.

Scores are Pinecone’s raw scores for the index’s metric. MMR re-ranks fetch_k matches for diversity, and its results have no score.

Return type:

list[SearchResult]

stats()[source]

The database’s statistics.

It includes vector_count.

Return type:

dict[str, Any]

upsert(ids, texts, metadatas, batch_size=64)[source]

Embed the texts, and upsert them in batches, with each text in its metadata’s text.

Return type:

None