View module source on GitHub

QueryBuilder

class QueryBuilder()

This class represents a query builder. Users can use this class to build a query rule for fetching prompts, agents or workflow from Maxim server.

and_

def and_() -> 'QueryBuilder'

Sets the operator for combining query rules to ‘AND’.

Returns:

NameDescription
[QueryBuilder](/sdk/python/references/models/query_builder)The current QueryBuilder instance for method chaining.

or_

def or_() -> 'QueryBuilder'

Sets the operator for combining query rules to ‘OR’.

Returns:

NameDescription
[QueryBuilder](/sdk/python/references/models/query_builder)The current QueryBuilder instance for method chaining.

folder

def folder(folderId: str) -> 'QueryBuilder'

Sets the folder scope for the query.

Arguments:

NameTypeDescription
folderIdstrThe ID of the folder to set as the scope.

Returns:

NameDescription
[QueryBuilder](/sdk/python/references/models/query_builder)The current QueryBuilder instance for method chaining.

exact_match

def exact_match() -> 'QueryBuilder'

Sets the exact match flag to True.

Returns:

NameDescription
[QueryBuilder](/sdk/python/references/models/query_builder)The current QueryBuilder instance for method chaining.

deployment_var

def deployment_var(key: str,
                   value: Union[str, int, bool],
                   enforce: bool = True) -> 'QueryBuilder'

Adds a deployment variable rule to the query.

Arguments:

NameTypeDescription
keystrThe key of the deployment variable.
valueUnion[str, int, bool]The value of the deployment variable.
enforcebool, optionalWhether to enforce the deployment variable. Defaults to True.

Returns:

NameDescription
[QueryBuilder](/sdk/python/references/models/query_builder)The current QueryBuilder instance for method chaining.

tag

def tag(key: str,
        value: Union[str, int, bool],
        enforce: bool = False) -> 'QueryBuilder'

Adds a tag rule to the query.

Arguments:

NameTypeDescription
keystrThe key of the tag.
valueUnion[str, int, bool]The value of the tag.
enforcebool, optionalWhether to enforce the tag. Defaults to False.

Returns:

NameDescription
[QueryBuilder](/sdk/python/references/models/query_builder)The current QueryBuilder instance for method chaining.

build

def build() -> QueryRule

Builds the final query rule.

Raises:

  • ValueError - If the query is empty after trimming.

Returns:

NameDescription
QueryRuleA QueryRule instance with the built query.