Ë
    uPêjr  ã                   óF   — d Z ddlmZmZmZ erddlmZ neZ G d„ d«      Zy)z£
Cost calculator for A2A (Agent-to-Agent) calls.

Supports dynamic cost parameters that allow platform owners
to define custom costs per agent query or per token.
é    )ÚTYPE_CHECKINGÚAnyÚFinal)ÚLoggingc            	       óZ   — e Zd Zededz  defd„«       Zedededz  dedz  defd„«       Zy)	ÚA2ACostCalculatorÚlitellm_logging_objNÚreturnc                 óF  — | €y| j                   }|j                  dd«      }|�t        |«      S |j                  di «      xs i }|j                  d«      �t        |d   «      S |j                  d«      }|j                  d«      }|€|�t        j	                  |||¬«      S y)	a�  
        Calculate the cost of an A2A send_message call.

        Supports multiple cost parameters for platform owners:
        - cost_per_query: Fixed cost per query
        - input_cost_per_token + output_cost_per_token: Token-based pricing

        Priority order:
        1. response_cost - if set directly (backward compatibility)
        2. cost_per_query - fixed cost per query
        3. input_cost_per_token + output_cost_per_token - token-based cost
        4. Default to 0.0

        Args:
            litellm_logging_obj: The LiteLLM logging object containing call details

        Returns:
            float: The cost of the A2A call
        Nç        Úresponse_costÚlitellm_paramsÚcost_per_queryÚinput_cost_per_tokenÚoutput_cost_per_token)Úmodel_call_detailsr   r   )r   ÚgetÚfloatr   Ú_calculate_token_based_cost)r	   r   r   r   r   r   s         úi/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/a2a_protocol/cost_calculator.pyÚcalculate_a2a_costz$A2ACostCalculator.calculate_a2a_cost   s×   € ð. Ð&Øà$7×$JÑ$JÐð  2×5Ñ5°oÀtÓLˆØÐ$Ü˜Ó'Ð'ð !3× 6Ñ 6Ð7GÈÓ LÒ RÐPRˆð ×ÑÐ.Ó/Ð;Ü˜Ð(8Ñ9Ó:Ð:ð '5×&8Ñ&8Ð9OÓ&PÐØ'5×'9Ñ'9Ð:QÓ'RÐàÐ+Ð/DÐ/PÜ$×@Ñ@Ø#5Ø%9Ø&;ð Aó ð ð ó    r   r   r   c                 óÀ   — | j                  d«      }|€yt        |dd«      xs d}t        |dd«      xs d}||rt        |«      ndz  }||rt        |«      ndz  }||z   S )a†  
        Calculate cost based on token usage and per-token pricing.

        Args:
            model_call_details: The model call details containing usage
            input_cost_per_token: Cost per input token (can be None, defaults to 0)
            output_cost_per_token: Cost per output token (can be None, defaults to 0)

        Returns:
            float: The calculated cost
        Úusager   Úprompt_tokensr   Úcompletion_tokens)r   Úgetattrr   )r   r   r   r   r   r   Ú
input_costÚoutput_costs           r   r   z-A2ACostCalculator._calculate_token_based_costI   s   € ð$ *×-Ñ-¨gÓ6ˆØˆ=Øô  ' u¨o¸qÓAÒFÀQˆÜ#*¨5Ð2EÀqÓ#IÒ#NÈQÐð *ÑL`¬UÐ3GÔ-HÐfiÑjˆ
Ø.ÑRg´%Ð8MÔ2NÐmpÑqˆà˜KÑ'Ð'r   )	Ú__name__Ú
__module__Ú__qualname__ÚstaticmethodÚLitellmLoggingObjectr   r   Údictr   © r   r   r   r      sj   „ Øð3Ø1°DÑ8ð3à	ò3ó ð3ðj ð(Ø ð(à# d™lð(ð  % t™|ð(ð 
ò	(ó ñ(r   r   N)	Ú__doc__Útypingr   r   r   Ú*litellm.litellm_core_utils.litellm_loggingr   r$   r   r&   r   r   ú<module>r*      s.   ðñ÷ -Ñ ,áöð Ð÷U(ò U(r   