QueryTransformer#
- class langchain.chains.query_constructor.parser.QueryTransformer(
- *args: Any,
- allowed_comparators: Sequence[Comparator] | None = None,
- allowed_operators: Sequence[Operator] | None = None,
- allowed_attributes: Sequence[str] | None = None,
- **kwargs: Any,
Transform a query string into an intermediate representation.
Initialize the QueryTransformer.
- Parameters:
allowed_comparators (Sequence[Comparator] | None) – Optional sequence of allowed comparators.
allowed_operators (Sequence[Operator] | None) – Optional sequence of allowed operators.
allowed_attributes (Sequence[str] | None) – Optional sequence of allowed attributes for comparators.
**kwargs (Any) – Additional keyword arguments.
args (Any)
Methods
__init__
(*args[, allowed_comparators, ...])Initialize the QueryTransformer.
args
(*items)Transforms items into a tuple.
date
(item)Transforms an item into a ISO8601Date object.
datetime
(item)Transforms an item into a ISO8601DateTime object.
false
()Returns false.
float
(item)Transforms an item into a float.
func_call
(func_name, args)Transform a function name and args into a FilterDirective.
int
(item)Transforms an item into an int.
list
(item)Transforms an item into a list.
program
(*items)Transform the items into a tuple.
string
(item)Transforms an item into a string.
transform
(tree)Transform the given tree, and return the final result
true
()Returns true.
- __init__(
- *args: Any,
- allowed_comparators: Sequence[Comparator] | None = None,
- allowed_operators: Sequence[Operator] | None = None,
- allowed_attributes: Sequence[str] | None = None,
- **kwargs: Any,
Initialize the QueryTransformer.
- Parameters:
allowed_comparators (Sequence[Comparator] | None) – Optional sequence of allowed comparators.
allowed_operators (Sequence[Operator] | None) – Optional sequence of allowed operators.
allowed_attributes (Sequence[str] | None) – Optional sequence of allowed attributes for comparators.
**kwargs (Any) – Additional keyword arguments.
args (Any)
- args(*items: Any) tuple [source]#
Transforms items into a tuple.
- Parameters:
items (Any) – The items to transform.
- Return type:
tuple
- date(
- item: Any,
Transforms an item into a ISO8601Date object.
- Parameters:
item (Any) – The item to transform.
- Raises:
ValueError – If the item is not in ISO 8601 date format.
- Return type:
- datetime(
- item: Any,
Transforms an item into a ISO8601DateTime object.
- Parameters:
item (Any) – The item to transform.
- Raises:
ValueError – If the item is not in ISO 8601 datetime format.
- Return type:
- float(item: Any) float [source]#
Transforms an item into a float.
- Parameters:
item (Any) – The item to transform.
- Return type:
float
- func_call(
- func_name: Any,
- args: list,
Transform a function name and args into a FilterDirective.
- Parameters:
func_name (Any) – The name of the function.
args (list) – The arguments passed to the function.
- Returns:
The filter directive.
- Return type:
- Raises:
ValueError – If the function is a comparator and the first arg is not in the
allowed attributes. –
- int(item: Any) int [source]#
Transforms an item into an int.
- Parameters:
item (Any) – The item to transform.
- Return type:
int
- list(item: Any) list [source]#
Transforms an item into a list.
- Parameters:
item (Any) – The item to transform.
- Return type:
list
- program(*items: Any) tuple [source]#
Transform the items into a tuple.
- Parameters:
items (Any)
- Return type:
tuple
- string(item: Any) str [source]#
Transforms an item into a string.
Removes escaped quotes.
- Parameters:
item (Any) – The item to transform.
- Return type:
str
- transform(
- tree: Tree[_Leaf_T],
Transform the given tree, and return the final result
- Parameters:
tree (Tree[_Leaf_T])
- Return type:
_Return_T