Source code for langchain.vectorstores.redis.filters
from enum import Enum
from functools import wraps
from numbers import Number
from typing import Any, Callable, Dict, List, Optional, Union
from langchain.utilities.redis import TokenEscaper
# disable mypy error for dunder method overrides
# mypy: disable-error-code="override"
[docs]class RedisFilterOperator(Enum):
    EQ = 1
    NE = 2
    LT = 3
    GT = 4
    LE = 5
    GE = 6
    OR = 7
    AND = 8
    LIKE = 9
    IN = 10
[docs]class RedisFilter:
[docs]    @staticmethod
    def text(field: str) -> "RedisText":
        return RedisText(field)
[docs]    @staticmethod
    def num(field: str) -> "RedisNum":
        return RedisNum(field)
[docs]    @staticmethod
    def tag(field: str) -> "RedisTag":
        return RedisTag(field)
[docs]class RedisFilterField:
    escaper: "TokenEscaper" = TokenEscaper()
    OPERATORS: Dict[RedisFilterOperator, str] = {}
[docs]    def __init__(self, field: str):
        self._field = field
        self._value: Any = None
        self._operator: RedisFilterOperator = RedisFilterOperator.EQ
[docs]    def equals(self, other: "RedisFilterField") -> bool:
        if not isinstance(other, type(self)):
            return False
        return self._field == other._field and self._value == other._value
    def _set_value(
        self, val: Any, val_type: type, operator: RedisFilterOperator
    ) -> None: