#Initializing the Pinecone
from pinecone import Pinecone
from langchain.vectorstores import Pinecone as PC
pc = PC(api_key=PINECONE_API_KEY)
index_name="medical-chatbot"
#Creating Embeddings for Each of The Text Chunks & storing
pinecone_index = pc.from_texts(text_chunks, embeddings, index_name=index_name)
Cell In[82], [line 5]
(vscode-notebook-cell:?execution_count=82&line=5)
[2](vscode-notebook-cell:?execution_count=82&line=2) from pinecone import Pinecone
[3](vscode-notebook-cell:?execution_count=82&line=3) from langchain.vectorstores import Pinecone as PC
----> [5](vscode-notebook-cell:?execution_count=82&line=5) pc=PC(api_key=PINECONE_API_KEY)
[8](vscode-notebook-cell:?execution_count=82&line=8) index_name="medical-chatbot"
[10](vscode-notebook-cell:?execution_count=82&line=10) #Creating Embeddings for Each of The Text Chunks & storing
TypeError: __init__() got an unexpected keyword argument 'api_key'
Hi @fakhrud33 ,
Welcome to the Pinecone forum and thanks for your question!
It looks like you’re passing the api_key
argument to the LangChain Pinecone VectorStore class, which doesn’t expect that argument, which is why you’re getting the error:
unexpected keyword argument `api_key`
Here is the correct code snippet:
import os
from langchain_pinecone import PineconeVectorStore
from langchain_openai import OpenAIEmbeddings
os.environ['OPENAI_API_KEY'] = '<YOUR_OPENAI_API_KEY>'
os.environ['PINECONE_API_KEY'] = '<YOUR_PINECONE_API_KEY>'
index_name = "medical-chatbot"
embeddings = OpenAIEmbeddings()
vectorstore_from_texts = PineconeVectorStore.from_texts(
text_chunks,
index_name=index_name,
embedding=embeddings
)
Did you have a look at this guide for how to work with Pinecone and LangChain?
Hope this helps!