Skip to content

Commit

Permalink
fix chatvectordbchain to use pinecone namespace (#1139)
Browse files Browse the repository at this point in the history
In the similarity search, the pinecone namespace is not used, which
makes the bot return _I don't know_ where the embeddings are stored in
the pinecone namespace. Now we can query by passing the namespace
optionally.
```result = qa({"question": query, "chat_history": chat_history, "namespace":"01gshyhjcfgkq1q5wxjtm17gjh"})```
  • Loading branch information
kekayan authored Feb 18, 2023
1 parent fb3c73d commit 9111f4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions langchain/chains/chat_vector_db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ def from_llm(
def _call(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
question = inputs["question"]
chat_history_str = _get_chat_history(inputs["chat_history"])
vectordbkwargs = inputs.get("vectordbkwargs", {})
if chat_history_str:
new_question = self.question_generator.run(
question=question, chat_history=chat_history_str
)
else:
new_question = question
docs = self.vectorstore.similarity_search(new_question, k=4)
docs = self.vectorstore.similarity_search(new_question, k=4, **vectordbkwargs)
new_inputs = inputs.copy()
new_inputs["question"] = new_question
new_inputs["chat_history"] = chat_history_str
Expand All @@ -100,14 +101,15 @@ def _call(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
async def _acall(self, inputs: Dict[str, Any]) -> Dict[str, str]:
question = inputs["question"]
chat_history_str = _get_chat_history(inputs["chat_history"])
vectordbkwargs = inputs.get("vectordbkwargs", {})
if chat_history_str:
new_question = await self.question_generator.arun(
question=question, chat_history=chat_history_str
)
else:
new_question = question
# TODO: This blocks the event loop, but it's not clear how to avoid it.
docs = self.vectorstore.similarity_search(new_question, k=4)
docs = self.vectorstore.similarity_search(new_question, k=4, **vectordbkwargs)
new_inputs = inputs.copy()
new_inputs["question"] = new_question
new_inputs["chat_history"] = chat_history_str
Expand Down

0 comments on commit 9111f4c

Please sign in to comment.