Ë
    uPêjw  ã                   ó@   — d Z ddlZddlmZ ddlmZmZ  G d„ d«      Zy)zy
Condition Evaluator - Evaluates policy conditions.

Supports model-based conditions with exact match or regex patterns.
é    N)Úverbose_proxy_logger)ÚPolicyConditionÚPolicyMatchContextc                   ó‚   — e Zd ZdZededz  dedefd„«       Zede	e
e	   z  de	dz  defd„«       Zed	e	d
e	defd„«       Zy)ÚConditionEvaluatorzÓ
    Evaluates policy conditions against request context.

    Supports model conditions with:
    - Exact string match: "gpt-4"
    - Regex pattern: "gpt-4.*"
    - List of values: ["gpt-4", "gpt-4-turbo"]
    Ú	conditionNÚcontextÚreturnc                 óÐ   — | €y| j                   �Wt        j                  | j                   |j                   ¬«      s,t        j                  d|j                   | j                   «       yy)a(  
        Evaluate a policy condition against a request context.

        Args:
            condition: The condition to evaluate (None = always matches)
            context: The request context with team, key, model

        Returns:
            True if condition matches, False otherwise
        T©r   Úmodelz+Condition failed: model=%s did not match %sF)r   r   Ú_evaluate_model_conditionr   Údebug)r   r	   s     út/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/policy_engine/condition_evaluator.pyÚevaluatezConditionEvaluator.evaluate   se   € ð  ÐØð �?‰?Ð&Ü%×?Ñ?Ø#Ÿ/™/Ø—m‘mð @ô ô %×*Ñ*ØAÀ7Ç=Á=ÐR[×RaÑRaôð àó    r   c                 ó~   ‡— ‰€yt        | t        «      rt        ˆfd„| D «       «      S t        j	                  | ‰«      S )zø
        Evaluate a model condition.

        Args:
            condition: String (exact or regex) or list of strings
            model: The model name to check

        Returns:
            True if model matches condition, False otherwise
        Fc              3   óJ   •K  — | ]  }t         j                  |‰«      –— Œ y ­w)N)r   Ú_matches_pattern)Ú.0Úpatternr   s     €r   ú	<genexpr>z?ConditionEvaluator._evaluate_model_condition.<locals>.<genexpr>N   s   øè ø€ ÒdÈwÔ)×:Ñ:¸7ÀE×JÑdùs   ƒ #)Ú
isinstanceÚlistÚanyr   r   r   s    `r   r   z,ConditionEvaluator._evaluate_model_condition:   s@   ø€ ð ˆ=Øô �i¤Ô&ÜÓdÐZcÔdÓdÐdô "×2Ñ2°9¸eÓDÐDr   r   Úvaluec                 ót   — | |k(  ry	 t        j                  | |«      ry	 y# t         j                  $ r Y yw xY w)zö
        Check if value matches pattern (exact match or regex).

        Args:
            pattern: Pattern to match (exact string or regex)
            value: Value to check

        Returns:
            True if matches, False otherwise
        TF)ÚreÚ	fullmatchÚerror)r   r   s     r   r   z#ConditionEvaluator._matches_patternS   sJ   € ð �eÒØð	Ü�|‰|˜G UÔ+Øð ,ð øô	 �x‰xò 	ààð		ús   ˆ! ¡7¶7)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr   r   Úboolr   Ústrr   r   r   © r   r   r   r      s¢   „ ñð ðØ" TÑ)ðà#ðð 
òó ðð> ðEØ˜˜c™‘?ðEà�T‰zðEð 
òEó ðEð0 ð #ð ¨cð °dò ó ñr   r   )r$   r   Úlitellm._loggingr   Ú!litellm.types.proxy.policy_enginer   r   r   r(   r   r   ú<module>r+      s#   ðñó 
å 1÷÷[ò [r   