-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
langchain_community.vectorstores: PGVector filtering - top level AND and OR operator #17064 #17067
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
filter_by_metadata = None | ||
|
||
return filter_by_metadata | ||
def _create_filter_clause(self, filters): # type: ignore[no-untyped-def] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a type for the filters?
"between": lambda f, v: f.between(str(v[0]), str(v[1])), | ||
} | ||
|
||
def parse_condition(field, condition): # type: ignore[no-untyped-def] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add type annotations here to make it easier to follow what's going on?
from langchain.chains.query_constructor.ir import Comparator, Operator | ||
|
||
COMPARISONS = { | ||
Comparator.EQ: lambda f, v: f == str(v), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if value was an integer and the field is of an integer type?
Comparator.IN: lambda f, v: f.in_(v), | ||
Comparator.NIN: lambda f, v: f.not_in(v), | ||
Comparator.CONTAIN: lambda f, v: f.contains(v), | ||
"contains": lambda f, v: f.contains(v), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @baskaryan looks like we've got some operations not covered by the existing enums?
Awesome! I'm wondering are there any existing unit tests that help cover the internal refactor? Could you confirm you ran the unit tests? The code looks good from a high level, but hard for me to determine whether it works without digging in. |
similar to #12977 |
Comandeering |
closing in favor of: #18992 |
Solution for #17064
Description:
filter = {"or": [{"rating": {"gte": 8.5}}, {"genre": "animated"}]}
libs/langchain/chains/query_constructor/ir.py