> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# QueryCondition

> A group of filter rules combined with AND logic or with OR logic.

`rules` can hold other `QueryCondition` objects, so conditions nest to
express mixed logic such as *A and (B or C)*. Pass a `QueryCondition` as
the `filter` argument of `get_span_fields()` on
[`Application`](/sdk-api/evals/application), which allows at
most 3 levels of nesting and 10 rules.

## Example

```python theme={null}
from fiddler_evals import (
    OperatorType,
    QueryCondition,
    QueryConditionType,
    QueryRule,
)

# LLM spans that either used many tokens or ran on a GPT-4 model
span_filter = QueryCondition(
    rules=[
        QueryRule(
            field="Span::span_type",
            operator=OperatorType.EQUAL,
            value="llm",
        ),
        QueryCondition(
            condition=QueryConditionType.OR,
            rules=[
                QueryRule(
                    field="SpanAttribute::gen_ai.usage.total_tokens",
                    operator=OperatorType.GREATER,
                    value=4000,
                ),
                QueryRule(
                    field="SpanAttribute::gen_ai.request.model",
                    operator=OperatorType.BEGINS_WITH,
                    value="gpt-4",
                ),
            ],
        ),
    ]
)
```

## Attributes

<ResponseField name="condition" type="QueryConditionType">
  How `rules` are combined; defaults to `AND`.
</ResponseField>

<ResponseField name="rules" type="List[QueryRule | QueryCondition]">
  Rules and nested conditions to combine.
</ResponseField>

## add\_rule()

Add a filter rule.

### Parameters

<ParamField path="rule" type="QueryRule | QueryCondition" required={true}>
  Rule or nested condition to append to `rules`.
</ParamField>

## add\_rules()

Add multiple filter rules.

### Parameters

<ParamField path="rules" type="List[QueryRule | QueryCondition]" required={true}>
  Rules or nested conditions to append to `rules`, in order.
</ParamField>
