I am using langchain and previously it working correctly with Pinecone however after latest update of both langchain and Pinecone, code is not working. I got the following snippet from pinecone.init is no longer a top-level attribute of the pinecone package · Issue #16513 · langchain-ai/langchain · GitHub . This fixes the error where init attritbute is no longer supported but now I am getting list_indexes is no longer top level attribute.
Please note that I have an existing index and I want to save the vectorstore object.
Please advise
import pinecone
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Pinecone
from langchain.schema import Document
class PineconeConnected():
def init(self, index_name: str, pinecone_api_key: str, pinecone_env: str, openai_key: str):
embeddings = OpenAIEmbeddings(openai_api_key=openai_key)
self.pinecone = pinecone.Pinecone(api_key=pinecone_api_key)
self.vector_db = Pinecone.from_existing_index(index_name, embeddings) # VectorStore object with the reference + Pinecone index loaded