First of all guys anyone facing init error :
Pinecone has recently updated there library due to which you wont be able to use the old deprecated methods.
to initialize your pinecone →
import pinecone
from pinecone import Pinecone,ServerlessSpec
use these import statements
then to initialize →
pc = Pinecone(api_key=PINECONE_API_KEY) //use this
index_name = "testing" //your index name
index = pc.Index(index_name) //using Index method to basically configure your (this part is necessary to avoid api key missing errors too)
(you can see this for more reference)
one more thing to keep in mind while facing missing api keys →
(note anyone facing the api key missing config error , you will have to set your api keys thru os(operating system) module in python , you can do this by
PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY','your_api_key')
PINECONE_API_ENV = os.environ.get('PINECONE_API_ENV','gcp-starter')
os.environ['PINECONE_API_ENV'] = PINECONE_API_ENV
os.environ['PINECONE_API_KEY'] = PINECONE_API_KEY )
For anyone who’s facing from_texts or from_docs method not available error :
from langchain.vectorstores import Pinecone
docsearch = Pinecone.from_texts([t.page_content for t in text_chunks], embedding, index_name=index_name)
// previously you used to use your methods like this importing Pinecone module from langchain.vectorstores and using this directly to store your data inside pinecode index in form of vector embeddings. Now you cant use this :
You will have to use PineconeVectorStore class provided by langchain_pinecone →
from langchain_pinecone import PineconeVectorStore
docsearch = PineconeVectorStore.from_texts(texts = your_text_string, embedding=embedding, index_name=index_name)
//same for from_docs
**NOW FOR ANYONE WHO IS STILL FACING ERRORS : **
use this to set up your environment , important to download the versions they have provided
restart your kernel and try again
now if you still face error
please do what i did and it worked for me. i created a new file with a new python kernel (3.8.19)
use this kernel and environment provided by them (this is imp) and your issue will be resolved. it worked for me.
feel free to comment down in case you receive any more errors