Skip to content

ExpressionContextCondition

autogen.agentchat.group.context_condition.ExpressionContextCondition #

ExpressionContextCondition(expression, **data)

Bases: ContextCondition

Complex expression-based context condition.

This condition evaluates a ContextExpression against the context variables.

Initialize with an expression as a positional parameter.

PARAMETER DESCRIPTION
expression

The context expression to evaluate

TYPE: ContextExpression

data

Additional data for the parent class

TYPE: Any DEFAULT: {}

Source code in autogen/agentchat/group/context_condition.py
def __init__(self, expression: ContextExpression, **data: Any) -> None:
    """Initialize with an expression as a positional parameter.

    Args:
        expression: The context expression to evaluate
        data: Additional data for the parent class
    """
    super().__init__(expression=expression, **data)

expression instance-attribute #

expression

evaluate #

evaluate(context_variables)

Evaluate the expression against the context variables.

PARAMETER DESCRIPTION
context_variables

The context variables to evaluate against

TYPE: ContextVariables

RETURNS DESCRIPTION
bool

Boolean result of the expression evaluation

Source code in autogen/agentchat/group/context_condition.py
def evaluate(self, context_variables: ContextVariables) -> bool:
    """Evaluate the expression against the context variables.

    Args:
        context_variables: The context variables to evaluate against

    Returns:
        Boolean result of the expression evaluation
    """
    return self.expression.evaluate(context_variables)