Skip to content

Commit 03f79ee

Browse files
authored
Updated retriever tool kwargs so that parameters passed in will take precedence over instance values. (#172)
1 parent 0d7a8c6 commit 03f79ee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

integrations/langchain/src/databricks_langchain/vector_search_retriever_tool.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,18 @@ def _run(self, query: str, filters: Optional[List[FilterItem]] = None, **kwargs)
8080
# Since LLM can generate either a dict or FilterItem, convert to dict always
8181
filters_dict = {dict(item)["key"]: dict(item)["value"] for item in (filters or [])}
8282
combined_filters = {**filters_dict, **(self.filters or {})}
83+
84+
# Allow kwargs to override the default values upon invocation
85+
num_results = kwargs.pop("k", self.num_results)
86+
query_type = kwargs.pop("query_type", self.query_type)
87+
8388
# Ensure that we don't have duplicate keys
8489
kwargs.update(
8590
{
8691
"query": query,
87-
"k": self.num_results,
92+
"k": num_results,
8893
"filter": combined_filters,
89-
"query_type": self.query_type,
94+
"query_type": query_type,
9095
}
9196
)
9297
return self._vector_store.similarity_search(**kwargs)

0 commit comments

Comments
 (0)