mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
fix chatvectordbchain to use pinecone namespace (#1139)
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"})```
This commit is contained in:
parent
fb3c73d194
commit
9111f4ca8a
@ -81,13 +81,14 @@ class ChatVectorDBChain(Chain, BaseModel):
|
|||||||
def _call(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
|
def _call(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
question = inputs["question"]
|
question = inputs["question"]
|
||||||
chat_history_str = _get_chat_history(inputs["chat_history"])
|
chat_history_str = _get_chat_history(inputs["chat_history"])
|
||||||
|
vectordbkwargs = inputs.get("vectordbkwargs", {})
|
||||||
if chat_history_str:
|
if chat_history_str:
|
||||||
new_question = self.question_generator.run(
|
new_question = self.question_generator.run(
|
||||||
question=question, chat_history=chat_history_str
|
question=question, chat_history=chat_history_str
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
new_question = question
|
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 = inputs.copy()
|
||||||
new_inputs["question"] = new_question
|
new_inputs["question"] = new_question
|
||||||
new_inputs["chat_history"] = chat_history_str
|
new_inputs["chat_history"] = chat_history_str
|
||||||
@ -100,6 +101,7 @@ class ChatVectorDBChain(Chain, BaseModel):
|
|||||||
async def _acall(self, inputs: Dict[str, Any]) -> Dict[str, str]:
|
async def _acall(self, inputs: Dict[str, Any]) -> Dict[str, str]:
|
||||||
question = inputs["question"]
|
question = inputs["question"]
|
||||||
chat_history_str = _get_chat_history(inputs["chat_history"])
|
chat_history_str = _get_chat_history(inputs["chat_history"])
|
||||||
|
vectordbkwargs = inputs.get("vectordbkwargs", {})
|
||||||
if chat_history_str:
|
if chat_history_str:
|
||||||
new_question = await self.question_generator.arun(
|
new_question = await self.question_generator.arun(
|
||||||
question=question, chat_history=chat_history_str
|
question=question, chat_history=chat_history_str
|
||||||
@ -107,7 +109,7 @@ class ChatVectorDBChain(Chain, BaseModel):
|
|||||||
else:
|
else:
|
||||||
new_question = question
|
new_question = question
|
||||||
# TODO: This blocks the event loop, but it's not clear how to avoid it.
|
# 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 = inputs.copy()
|
||||||
new_inputs["question"] = new_question
|
new_inputs["question"] = new_question
|
||||||
new_inputs["chat_history"] = chat_history_str
|
new_inputs["chat_history"] = chat_history_str
|
||||||
|
Loading…
Reference in New Issue
Block a user