langchain_community: updated query constructor for Databricks Vector Search due to LangChainDeprecationWarning: filters was deprecated since langchain-community 0.2.11 and will be removed in 0.3. Please use filter instead. (#27974)

- **Description:** Updated the kwargs for the structured query from
filters to filter due to deprecation of 'filters' for Databricks Vector
Search. Also changed the error messages as the allowed operators and
comparators are different which can cause issues with functions such as
get_query_constructor_prompt()

- **Issue:** Fixes the Key Error for filters due to deprecation in favor
for 'filter':

LangChainDeprecationWarning: DatabricksVectorSearch received a key
`filters` in search_kwargs. `filters` was deprecated since
langchain-community 0.2.11 and will be removed in 0.3. Please use
`filter` instead.

- **Dependencies:** N/A
- **Twitter handle:** N/A

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
William Smith 2024-12-03 19:03:53 -05:00 committed by GitHub
parent 6e607bb237
commit 15e7353168
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -90,5 +90,5 @@ class DatabricksVectorSearchTranslator(Visitor):
if structured_query.filter is None:
kwargs = {}
else:
kwargs = {"filters": structured_query.filter.accept(self)}
kwargs = {"filter": structured_query.filter.accept(self)}
return structured_query.query, kwargs

View File

@ -109,7 +109,7 @@ def test_visit_structured_query_with_one_arg_filter() -> None:
filter=comp,
)
expected = (query, {"filters": {"country": "France"}})
expected = (query, {"filter": {"country": "France"}})
actual = DEFAULT_TRANSLATOR.visit_structured_query(structured_query)
assert expected == actual
@ -134,7 +134,7 @@ def test_visit_structured_query_with_multiple_arg_filter_and_operator() -> None:
expected = (
query,
{"filters": {"country": "France", "year >=": 1888, "year <=": 1900}},
{"filter": {"country": "France", "year >=": 1888, "year <=": 1900}},
)
actual = DEFAULT_TRANSLATOR.visit_structured_query(structured_query)