Release v3.1.0
Listing vector ids by prefix in a namespace (for serverless indexes)
We've implemented SDK support for a new data plane endpoint used to list ids by prefix in a given namespace. If the prefix empty string is passed, this can be used to list all ids in a namespace.
The index client now has list
and list_paginated
. With clever assignment of vector ids, this can be used to help model hierarchical relationships between different vectors such as when you have embeddings for multiple chunks or fragments related to the same document.
The list
method returns a generator that handles pagination on your behalf.
from pinecone import Pinecone
pc = Pinecone(api_key='xxx')
index = pc.Index(host='hosturl')
# To iterate over all result pages using a generator function
for ids in index.list(prefix='pref', limit=3, namespace=namespace):
print(ids) # ['pref1', 'pref2', 'pref3']
# Now you can pass this id array to other methods, such as fetch or delete.
vectors = index.fetch(ids=ids, namespace=namespace)
There is also an option to fetch each page of results yourself with list_paginated
.
from pinecone import Pinecone
pc = Pinecone(api_key='xxx')
index = pc.Index(host='hosturl')
namespace = 'foo-namespace'
# For manual control over pagination
results = index.list_paginated(
prefix='pref',
limit=3,
namespace='foo',
pagination_token='eyJza2lwX3Bhc3QiOiI5IiwicHJlZml4IjpudWxsfQ=='
)
print(results.namespace) # 'foo'
print([v.id for v in results.vectors]) # ['pref1', 'pref2', 'pref3']
print(results.pagination.next) # 'eyJza2lwX3Bhc3QiOiI5IiwicHJlZml4IjpudWxsfQ=='
print(results.usage) # { 'read_units': 1 }
Python 3.11 and 3.12 support
We made an adjustment to our declared python version support (from python >=3.8,<3.13
to ^3.8
) to make it easier for tools with more expansive statements on what python versions they support to include the pinecone sdk as a dependency. Alongside this change, we expanded our test matrix to include more robust testing with python versions 3.11 and 3.12. Python 3.13 is still in alpha and is not yet part of our test matrix.
- Adjust supported python versions to ^3.8 by @jhamon in #312
- Update pytest-timeout to support python >= 3.12 by @mjvankampen in #314
Chores
- Sync models from pinecone-protos by @fsxfreak in #315
- Fix minor README docs issues in client reference by @austin-denoble in #316
New Contributors
- @mjvankampen made their first contribution in #314
Full Changelog: v3.0.3...v3.1.0