Skip to content

StringContextCondition

autogen.agentchat.group.context_condition.StringContextCondition #

Bases: ContextCondition

Simple string-based context condition.

This condition checks if a named context variable exists and is truthy.

variable_name instance-attribute #

variable_name

evaluate #

evaluate(context_variables)

Check if the named context variable is truthy.

PARAMETER DESCRIPTION
context_variables

The context variables to check against

TYPE: ContextVariables

RETURNS DESCRIPTION
bool

True if the variable exists and is truthy, False otherwise

Source code in autogen/agentchat/group/context_condition.py
def evaluate(self, context_variables: ContextVariables) -> bool:
    """Check if the named context variable is truthy.

    Args:
        context_variables: The context variables to check against

    Returns:
        True if the variable exists and is truthy, False otherwise
    """
    return bool(context_variables.get(self.variable_name, False))