[X] I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
My query code is below:
pinecone.init(
api_key=os.environ.get('PINECONE_API_KEY'), # app.pinecone.io
environment=os.environ.get('PINECONE_ENV') # next to API key in console
)
index = pinecone.Index(index_name)
embeddings = OpenAIEmbeddings(openai_api_key=os.environ.get('OPENAI_API_KEY'))
vectordb = Pinecone(
index=index,
embedding_function=embeddings.embed_query,
text_key="text",
)
llm=ChatOpenAI(
openai_api_key=os.environ.get('OPENAI_API_KEY'),
temperature=0,
model_name='gpt-3.5-turbo'
)
retriever = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=vectordb.as_retriever()
)
tools = [Tool(
func=retriever.run,
description=tool_desc,
name='Product DB'
)]
memory = ConversationBufferWindowMemory(
memory_key="chat_history", # important to align with agent prompt (below)
k=5,
return_messages=True
)
agent = initialize_agent(
agent='chat-conversational-react-description',
tools=tools,
llm=llm,
verbose=True,
max_iterations=3,
early_stopping_method="generate",
memory=memory,
)
If I run:
agent({'chat_history':[], 'input':'What is a product?'})
It throws:
File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain\vectorstores\pinecone.py", line 160, in similarity_search
text = metadata.pop(self._text_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'text'
This is the offending block in site-packages/pinecone.py:
for res in results["matches"]:
# print('metadata.pop(self._text_key) = ' + metadata.pop(self._text_key))
metadata = res["metadata"]
text = metadata.pop(self._text_key)
docs.append(Document(page_content=text, metadata=metadata))
If I remove my tool like the line below, everything executes (just not my tool):
tools = []
Can anyone help me fix this KeyError: 'text' issue? My versions of langchain and pinecone-client are, 0.0.147 and 2.2.1 respectively.
Expected Behavior
Retriever runs successfully and doesn't throw any KeyError errors.
Is this a new bug?
Current Behavior
My query code is below:
If I run:
agent({'chat_history':[], 'input':'What is a product?'})
It throws:
This is the offending block in site-packages/pinecone.py:
If I remove my tool like the line below, everything executes (just not my tool):
tools = []
Can anyone help me fix this KeyError: 'text' issue? My versions of langchain and pinecone-client are, 0.0.147 and 2.2.1 respectively.
Expected Behavior
Retriever runs successfully and doesn't throw any KeyError errors.
Steps To Reproduce
Relevant log output
No response
Environment
Additional Context
No response