Skip to content

Commit 207e319

Browse files
authored
Add search_kwargs option for VectorDBQAWithSourcesChain (#657)
Allows for passing additional vectorstore params like namespace, etc. to VectorDBQAWithSourcesChain Example: `chain = VectorDBQAWithSourcesChain.from_llm(OpenAI(temperature=0), vectorstore=store, search_kwargs={"namespace": namespace})`
1 parent bfb23f4 commit 207e319

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

langchain/chains/qa_with_sources/vector_db.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ class VectorDBQAWithSourcesChain(BaseQAWithSourcesChain, BaseModel):
1414
vectorstore: VectorStore
1515
"""Vector Database to connect to."""
1616
k: int = 4
17+
"""Number of results to return from store"""
18+
search_kwargs: Dict[str, Any] = {}
19+
"""Extra search args"""
1720

1821
def _get_docs(self, inputs: Dict[str, Any]) -> List[Document]:
1922
question = inputs[self.question_key]
20-
return self.vectorstore.similarity_search(question, k=self.k)
23+
return self.vectorstore.similarity_search(
24+
question, k=self.k, **self.search_kwargs
25+
)

0 commit comments

Comments
 (0)