Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Initialization Issue #1

Open
VEDANTBISHT opened this issue Mar 4, 2024 · 7 comments
Open

API Initialization Issue #1

VEDANTBISHT opened this issue Mar 4, 2024 · 7 comments

Comments

@VEDANTBISHT
Copy link

After running the code from store_index.py file

pinecone.init(api_key=PINECONE_API_KEY,
environment=PINECONE_API_ENV)

It shows the given error:-

Traceback (most recent call last):
File "C:\Users\vedan\Downloads\kuch bhi\End-to-end-Medical-Chatbot-using-Llama2\store_index.py", line 21, in
pinecone.init(api_key=PINECONE_API_KEY,
File "C:\Users\vedan\AppData\Roaming\Python\Python312\site-packages\pinecone\deprecation_warnings.py", line 38, in init
raise AttributeError(msg)
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'
        )
    )

Can you pls help me find the error as init is no longer supported by Pinecone.

@smriti217
Copy link

Is it working now?

@dkk3675
Copy link

dkk3675 commented Mar 10, 2024

@VEDANTBISHT I was facing the same issue. After debugging for much time, got to know that pinecone-client version <=2.2.4 only supports init package and is deprecated in furthur releases. [Ref. : Pinecone-Migration-Guide]

@TenzinNsut
Copy link

TenzinNsut commented Mar 29, 2024

Uninstall the current version of pinecone

pip uninstall pinecone-client

Now install pinecone version: 2.2.4

pip install pinecone-client==2.2.4

@nortln
Copy link

nortln commented Apr 14, 2024

I reduced to a lower version but after that there was no more environment variable on the pinecone website and when I tried using chromadb it didn't work, especially with the hugging face embeddings I have been trying to solve this but to no avail. Does anyone have a fix

@d-pamneja
Copy link

I encountered the same issue, this can be tackled as follows.

Since __init__ is no longer a top-level attribute of the pinecone package, we will have to create an instance of pinecone via the pinecone library itself as follows.

from pinecone import Pinecone

# Creating a Pinecone instance
pc = Pinecone(api_key = os.environ["PINECONE_API_KEY"], environment = os.environ["PINECONE_API_ENV"])


index_name = "XYZ"

Now, when you would try to add the text chunks to the given index, it would again throw an error saying list_indexes() are no longer a top-level attribute of the pinecone package, as the from_texts() method would try to use this functionality and throw an error. To work around that, we will have to import Pinecone again, but this time using the langchain_pinecone library. The same can be seen as shown below:

Screenshot 2024-04-16 at 7 35 08 AM

@bhaveshk22
Copy link

Just follow the Quickstart guide, everything is there. Methods used to access Pinecone has changed overtime so you need to adapt the code accordingly.

@Shashank1202
Copy link

Hey, Can you solve this error with the currect version itself.

Follow this steps :

  1. Get your API_KEY from pinecone.
  2. Create a new index ad initialize through the following code
index_name= "give_any_index_name_of_your_wish"

pc=Pinecone(api_key=PINECONE_API_KEY)

#creating index

if index_name not in pc.list_indexes().names():
    pc.create_index(
        name= index_name,
        dimension= 384,
        metric= 'cosine',
        spec= ServerlessSpec(cloud= 'aws', region="us-east-1")
    )
index= pc.Index(index_name)
index

Since init method is no longer available, we can't create index in pinecone and initialize this in our python scripts.

So you need to create index Through your python script and intialize this. The above code creates index and intialize through the script itself.

Hope it helped you!!!!

Still facing Issue?? Go through this

https://github.com/Shashank1202/AI-Driven-Customer-Chatbot/blob/main/research/trails.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants