From e288410e728fff4e9b3f574fbdfef800390658cf Mon Sep 17 00:00:00 2001 From: whying <291424708@qq.com> Date: Thu, 6 Jul 2023 02:04:18 +0800 Subject: [PATCH] fix: Chroma filter symbols not supporting LIKE and CONTAIN (#7169) Fixing issue with SelfQueryRetriever due to unsupported LIKE and CONTAIN comparators in Chroma's WHERE filter statements. This pull request introduces a redefined set of comparators in Chroma to address the problem and make it compatible with SelfQueryRetriever. For information on the comparators supported by Chroma's filter, please refer to https://docs.trychroma.com/usage-guide#using-where-filters. image --------- Co-authored-by: Harrison Chase --- langchain/retrievers/self_query/chroma.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/langchain/retrievers/self_query/chroma.py b/langchain/retrievers/self_query/chroma.py index 44be86650d..cbb707d1ac 100644 --- a/langchain/retrievers/self_query/chroma.py +++ b/langchain/retrievers/self_query/chroma.py @@ -16,6 +16,14 @@ class ChromaTranslator(Visitor): allowed_operators = [Operator.AND, Operator.OR] """Subset of allowed logical operators.""" + allowed_comparators = [ + Comparator.EQ, + Comparator.GT, + Comparator.GTE, + Comparator.LT, + Comparator.LTE, + ] + """Subset of allowed logical comparators.""" def _format_func(self, func: Union[Operator, Comparator]) -> str: self._validate_func(func)