#Here is the code:
from pinecone import pinecone
Connect to pinecone environment
pinecone.init(
api_key=“API inserted”,
environment=“us-west-2” # find next to API key in console
)
Pick a name for the new index
index_name = “deduplication”
Check if the deduplication index exists
if index_name not in pinecone.list_indexes().names():
# Create the index if it does not exist
pinecone.create_index(
index_name,
dimension=300,
metadata_config={“indexed”: [“processed_abstract”]}
)
Connect to deduplication index we created
index = pinecone.Index(index_name)
#here is the error:
AttributeError Traceback (most recent call last)
in <cell line: 4>()
2
3 # Connect to pinecone environment
----> 4 pinecone.init(
5 api_key=“9fa3e17b-e98d-47fd-b87a-13a800975608”,
6 environment=“us-west-2” # find next to API key in console
/usr/local/lib/python3.10/dist-packages/pinecone/deprecation_warnings.py in init(*args, **kwargs)
36 {example}
37 “”"
—> 38 raise AttributeError(msg)
39
40 def list_indexes(*args, **kwargs):
AttributeError: init is no longer a top-level attribute of the pinecone package.
Please create an instance of the Pinecone class instead.
Example:
import os
from pinecone import Pinecone, ServerlessSpec
pc = Pinecone(
api_key=os.environ.get("PINECONE_API_KEY")
)
Now do stuff
if 'my_index' not in pc.list_indexes().names():
pc.create_index(
name='my_index',
dimension=1536,
metric='euclidean',
spec=ServerlessSpec(
cloud='aws',
region='us-west-2'
)
)