windlass.providers.vectordb.pinecone¶
pinecone
¶
Pinecone vector store.
Pinecone is the managed option: no index to host, scales past what a single machine holds, and supports namespaces for multi-tenant isolation. The trade-off is network latency on every query and eventual consistency on writes — a chunk you just upserted may not appear in the very next search.
Install with::
pip install "windlass[pinecone]"
Example
from windlass import Windlass # doctest: +SKIP store = Windlass.vectordb("pinecone", collection="docs", # doctest: +SKIP ... dimensions=1536) # doctest: +SKIP
PineconeVectorStore
¶
PineconeVectorStore(
*,
collection: str = "windlass",
dimensions: int | None = None,
metric: str = "cosine",
api_key: str | None = None,
namespace: str = "",
cloud: str = "aws",
region: str = "us-east-1",
create_if_missing: bool = True,
**config: Any
)
Bases: VectorStore
Vector store backed by a Pinecone serverless index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
str
|
Pinecone index name. |
'windlass'
|
dimensions
|
int | None
|
Vector length. Required when the index must be created. |
None
|
metric
|
str
|
|
'cosine'
|
api_key
|
str | None
|
Credential. Falls back to |
None
|
namespace
|
str
|
Namespace within the index — the clean way to isolate tenants while sharing one index. |
''
|
cloud
|
str
|
Serverless cloud provider for index creation. |
'aws'
|
region
|
str
|
Serverless region for index creation. |
'us-east-1'
|
create_if_missing
|
bool
|
Create the index when it does not exist. Creation is not instant; the first write may wait for it to become ready. |
True
|
**config
|
Any
|
Forwarded to :class: |
{}
|
Raises:
| Type | Description |
|---|---|
MissingDependencyError
|
When |
ConfigurationError
|
When the API key or dimensions are missing. |
ProviderError
|
When the index cannot be reached or created. |
Source code in src\windlass\providers\vectordb\pinecone.py
native
¶
aadd
async
¶
Upsert chunks in batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
Sequence[Chunk]
|
Chunks with embeddings set. |
required |
Returns:
| Type | Description |
|---|---|
int
|
How many chunks were sent. |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If a chunk has no embedding. |
ProviderError
|
When the API rejects a batch. |
Note
Pinecone is eventually consistent. A chunk written here may take a
moment to become visible to :meth:asearch.
Source code in src\windlass\providers\vectordb\pinecone.py
adelete
async
¶
Delete by id or metadata filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
Sequence[str] | None
|
Chunk ids to remove. |
None
|
filters
|
MetadataFilter | None
|
Metadata constraints, translated to Pinecone's filter syntax. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The number of ids requested. Pinecone does not report how many rows |
int
|
a filtered delete actually matched, so filtered deletes return 0. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When neither argument is supplied. |
Source code in src\windlass\providers\vectordb\pinecone.py
aclear
async
¶
Delete every vector in the namespace.
Clearing a namespace that does not exist yet succeeds. Pinecone creates namespaces lazily on first write and returns 404 for a delete-all against one that has never been written to, but "make this empty" is already satisfied in that case — raising would make teardown code fail precisely when there is nothing to tear down.
Raises:
| Type | Description |
|---|---|
ProviderError
|
For any failure other than an absent namespace. |
Source code in src\windlass\providers\vectordb\pinecone.py
asearch
async
¶
asearch(
vector: Sequence[float],
k: int = 5,
*,
filters: MetadataFilter | None = None,
**kwargs: Any
) -> list[ScoredChunk]
Query the index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Sequence[float]
|
The query embedding. |
required |
k
|
int
|
How many results to return. |
5
|
filters
|
MetadataFilter | None
|
Metadata constraints, pushed down to Pinecone. |
None
|
**kwargs
|
Any
|
Extra keyword arguments for |
{}
|
Returns:
| Type | Description |
|---|---|
list[ScoredChunk]
|
Ranked hits. |
Source code in src\windlass\providers\vectordb\pinecone.py
aget
async
¶
Fetch chunks by id.
Source code in src\windlass\providers\vectordb\pinecone.py
acount
async
¶
Return the namespace's vector count.
Note
Pinecone's statistics lag writes by a few seconds.