Skip to content

Commit

Permalink
langchain_community: updated query constructor for Databricks Vector …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
willsmithDB and efriis authored Dec 4, 2024
1 parent 6e607bb commit 15e7353
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ def visit_structured_query(
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 15e7353

Please sign in to comment.