I am attempting to connect to an existing index in Pinecone. The connection appears to work when storing the documents like so:
from langchain_community.vectorstores import Pinecone as LangchainPinecone
index_name = os.environ.get('PINECONE_RECIPE_INDEX')
docsearch = LangchainPinecone.from_documents(my_documents, embeddings, index_name=index_name)
retriever = docsearch.as_retriever(search_type="mmr")
However, when I attempt to connect to this index again, I get an Invalid API Key error (401). I have double checked that my API key is correct.
Here is the code that is giving me the error:
pc = Pinecone(api_key=os.environ.get('PINECONE_API_ENV'))
index_name = os.environ.get('PINECONE_INDEX')
# the line below is where the error occurs
index = pc.Index(index_name)
retriever = index.as_retriever(search_type="mmr")
Any advice would be helpful. Thanks.