mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-19 17:45:25 +00:00
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})`
This commit is contained in:
parent
bfb23f4608
commit
207e319a70
@ -14,7 +14,12 @@ class VectorDBQAWithSourcesChain(BaseQAWithSourcesChain, BaseModel):
|
|||||||
vectorstore: VectorStore
|
vectorstore: VectorStore
|
||||||
"""Vector Database to connect to."""
|
"""Vector Database to connect to."""
|
||||||
k: int = 4
|
k: int = 4
|
||||||
|
"""Number of results to return from store"""
|
||||||
|
search_kwargs: Dict[str, Any] = {}
|
||||||
|
"""Extra search args"""
|
||||||
|
|
||||||
def _get_docs(self, inputs: Dict[str, Any]) -> List[Document]:
|
def _get_docs(self, inputs: Dict[str, Any]) -> List[Document]:
|
||||||
question = inputs[self.question_key]
|
question = inputs[self.question_key]
|
||||||
return self.vectorstore.similarity_search(question, k=self.k)
|
return self.vectorstore.similarity_search(
|
||||||
|
question, k=self.k, **self.search_kwargs
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user