Pinecone error
uiaiek32 opened this issue · comments
I get this error when I try to connect the pinecone vector:
Error building node Pinecone(ID:Pinecone-eKDBR): 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' ) )
Steps to reproduce the behavior:
I click run and I get this error
To fix the error you're encountering with Pinecone, you need to adjust your code to match the updated Pinecone SDK's initialization process. The error message indicates that init
is no longer used directly. Instead, you should create an instance of the Pinecone class. Here's how you can do it:
import os
from pinecone import Pinecone, ServerlessSpec
pc = Pinecone(api_key=os.environ.get("PINECONE_API_KEY"))
# Example usage
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')
)
Make sure to replace the outdated pinecone.init
method with the creation of a Pinecone
instance as shown above. This change aligns with the latest Pinecone SDK guidelines. For the most accurate and up-to-date information, consult the Pinecone SDK documentation directly. This will ensure you're using the correct class and method names for initializing the Pinecone client with your API key and environment settings.
Details
Sources
- src/backend/base/langflow/components/vectorstores/Pinecone.py
- pyproject.toml
- src/backend/base/langflow/interface/initialize/vector_store.py
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
I get this error: Error building node Pinecone(ID:Pinecone-0mjWP): 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' ) )
Hey @uiaiek32
It seems this component is outdated.
We'll get to it soon.
Feel free to update it if you got the know-how and thanks for the heads up!
#1854 fixes it in the dev branch.