Skip to content

Commit ef4f0c4

Browse files
authored
Readme changes for v5 release. (#371)
## Problem Need to update README with content about deletion protection and inference. ## Solution Update examples ## Type of Change - [x] Non-code change (docs, etc)
1 parent ddfa538 commit ef4f0c4

File tree

1 file changed

+75
-6
lines changed

1 file changed

+75
-6
lines changed

README.md

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@ For more information, see the docs at https://www.pinecone.io/docs/
77

88
## Documentation
99

10-
- If you are upgrading from a `2.2.x` version of the client, check out the [**v3 Migration Guide**](https://canyon-quilt-082.notion.site/Pinecone-Python-SDK-v3-0-0-Migration-Guide-056d3897d7634bf7be399676a4757c7b#a21aff70b403416ba352fd30e300bce3).
1110
- [**Reference Documentation**](https://sdk.pinecone.io/python/index.html)
1211

12+
### Upgrading your client
13+
14+
#### Upgrading from `4.x` to `5.x`
15+
16+
As part of an overall move to stop exposing generated code in the package's public interface, an obscure configuration property (`openapi_config`) was removed in favor of individual configuration options such as `proxy_url`, `proxy_headers`, and `ssl_ca_certs`. All of these properties were available in v3 and v4 releases of the SDK, with deprecation notices shown to affected users.
17+
18+
It is no longer necessary to install a separate plugin, `pinecone-plugin-inference`, to try out the [Inference API](https://docs.pinecone.io/guides/inference/understanding-inference); that plugin is now installed by default in the v5 SDK. See [usage instructions below](#inference-api).
19+
20+
#### Older releases
21+
22+
- **Upgrading to `4.x`** : For this upgrade you are unlikely to be impacted by breaking changes unless you are using the `grpc` extras (see install steps below). Read full details in these [v4 Release Notes](https://github.com/pinecone-io/pinecone-python-client/releases/tag/v4.0.0).
23+
24+
- **Upgrading to `3.x`**: Many things were changed in the v3 client to pave the way for Pinecone's new Serverless index offering. These changes are covered in detail in the [**v3 Migration Guide**](https://canyon-quilt-082.notion.site/Pinecone-Python-SDK-v3-0-0-Migration-Guide-056d3897d7634bf7be399676a4757c7b#a21aff70b403416ba352fd30e300bce3). Serverless indexes are only available in `3.x` release versions or greater.
25+
1326
### Example code
1427

1528
Many of the brief examples shown in this README are using very small vectors to keep the documentation concise, but most real world usage will involve much larger embedding vectors. To see some more realistic examples of how this client can be used, explore some of our many Jupyter notebooks in the [examples](https://github.com/pinecone-io/examples) repository.
@@ -34,10 +47,10 @@ pip3 install pinecone-client
3447
pip3 install "pinecone-client[grpc]"
3548

3649
# Install a specific version
37-
pip3 install pinecone-client==3.0.0
50+
pip3 install pinecone-client==5.0.0
3851

3952
# Install a specific version, with grpc extras
40-
pip3 install "pinecone-client[grpc]"==3.0.0
53+
pip3 install "pinecone-client[grpc]"==5.0.0
4154
```
4255

4356
### Installing with poetry
@@ -50,10 +63,10 @@ poetry add pinecone-client
5063
poetry add pinecone-client --extras grpc
5164

5265
# Install a specific version
53-
poetry add pinecone-client==3.0.0
66+
poetry add pinecone-client==5.0.0
5467

5568
# Install a specific version, with grpc extras
56-
poetry add pinecone-client==3.0.0 --extras grpc
69+
poetry add pinecone-client==5.0.0 --extras grpc
5770
```
5871

5972
## Usage
@@ -197,6 +210,7 @@ pc.create_index(
197210
name='my-index',
198211
dimension=1536,
199212
metric='euclidean',
213+
deletion_protection='enabled',
200214
spec=ServerlessSpec(
201215
cloud='aws',
202216
region='us-west-2'
@@ -217,6 +231,7 @@ pc.create_index(
217231
name="example-index",
218232
dimension=1536,
219233
metric="cosine",
234+
deletion_protection='enabled',
220235
spec=PodSpec(
221236
environment='us-west-2',
222237
pod_type='p1.x1'
@@ -275,7 +290,7 @@ index_description = pc.describe_index("example-index")
275290

276291
## Delete an index
277292

278-
The following example deletes the index named `example-index`.
293+
The following example deletes the index named `example-index`. Only indexes which are not protected by deletion protection may be deleted.
279294

280295
```python
281296
from pinecone import Pinecone
@@ -298,6 +313,26 @@ new_number_of_replicas = 4
298313
pc.configure_index("example-index", replicas=new_number_of_replicas)
299314
```
300315

316+
## Configuring deletion protection
317+
318+
If you would like to enable deletion protection, which prevents an index from being deleted, the `configure_index` method also handles that via an optional `deletion_protection` keyword argument.
319+
320+
```python
321+
from pinecone import Pinecone
322+
323+
pc = Pinecone(api_key='<<PINECONE_API_KEY>>')
324+
325+
# To enable deletion protection
326+
pc.configure_index("example-index", deletion_protection='enabled')
327+
328+
# Disable deletion protection
329+
pc.configure_index("example-index", deletion_protection='disabled')
330+
331+
# Call describe index to verify the configuration change has been applied
332+
desc = pc.describe_index("example-index")
333+
print(desc.deletion_protection)
334+
```
335+
301336
## Describe index statistics
302337

303338
The following example returns statistics about the index `example-index`.
@@ -514,6 +549,40 @@ pc = Pinecone(api_key='<<PINECONE_API_KEY>>')
514549
pc.delete_collection("example-collection")
515550
```
516551

552+
# Inference API
553+
554+
The Pinecone SDK now supports creating embeddings via the [Inference API](https://docs.pinecone.io/guides/inference/understanding-inference).
555+
556+
```python
557+
from pinecone import Pinecone
558+
559+
pc = Pinecone(api_key="YOUR_API_KEY")
560+
model = "multilingual-e5-large"
561+
562+
# Embed documents
563+
text = [
564+
"Turkey is a classic meat to eat at American Thanksgiving.",
565+
"Many people enjoy the beautiful mosques in Turkey.",
566+
]
567+
text_embeddings = pc.inference.embed(
568+
model=model,
569+
inputs=text,
570+
parameters={"input_type": "passage", "truncate": "END"},
571+
)
572+
573+
# Upsert documents into Pinecone index
574+
575+
# Embed a query
576+
query = ["How should I prepare my turkey?"]
577+
query_embeddings = pc.inference.embed(
578+
model=model,
579+
inputs=query,
580+
parameters={"input_type": "query", "truncate": "END"},
581+
)
582+
583+
# Send query to Pinecone index to retrieve similar documents
584+
```
585+
517586
# Contributing
518587

519588
If you'd like to make a contribution, or get setup locally to develop the Pinecone python client, please see our [contributing guide](https://github.com/pinecone-io/pinecone-python-client/blob/main/CONTRIBUTING.md)

0 commit comments

Comments
 (0)