o
    Ã¿i7  ã                   @   s°   d Z ddlmZ ddlmZ G dd„ deƒZG dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZ	G dd„ deƒZ
G dd„ deƒZG dd„ deƒZG dd„ deƒZdS )zÏMetrics data models for Pipecat framework.

This module defines Pydantic models for various types of metrics data
collected throughout the pipeline, including timing, token usage, and
processing statistics.
é    )ÚOptional)Ú	BaseModelc                   @   s*   e Zd ZU dZeed< dZee ed< dS )ÚMetricsDataz·Base class for all metrics data.

    Parameters:
        processor: Name of the processor generating the metrics.
        model: Optional model name associated with the metrics.
    Ú	processorNÚmodel)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r   r   © r   r   úK/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/metrics/metrics.pyr      s   
 r   c                   @   ó   e Zd ZU dZeed< dS )ÚTTFBMetricsDataziTime To First Byte (TTFB) metrics data.

    Parameters:
        value: TTFB measurement in seconds.
    ÚvalueN©r   r   r	   r
   Úfloatr   r   r   r   r   r      ó   
 r   c                   @   r   )ÚProcessingMetricsDatazrGeneral processing time metrics data.

    Parameters:
        value: Processing time measurement in seconds.
    r   Nr   r   r   r   r   r   )   r   r   c                   @   sZ   e Zd ZU dZeed< eed< eed< dZee ed< dZee ed< dZ	ee ed< dS )	ÚLLMTokenUsageaÄ  Token usage statistics for LLM operations.

    Parameters:
        prompt_tokens: Number of tokens in the input prompt.
        completion_tokens: Number of tokens in the generated completion.
        total_tokens: Total number of tokens used (prompt + completion).
        cache_read_input_tokens: Number of tokens read from cache, if applicable.
        cache_creation_input_tokens: Number of tokens used to create cache entries, if applicable.
    Úprompt_tokensÚcompletion_tokensÚtotal_tokensNÚcache_read_input_tokensÚcache_creation_input_tokensÚreasoning_tokens)
r   r   r	   r
   Úintr   r   r   r   r   r   r   r   r   r   3   s   
 
r   c                   @   r   )ÚLLMUsageMetricsDatazpLLM token usage metrics data.

    Parameters:
        value: Token usage statistics for the LLM operation.
    r   N)r   r   r	   r
   r   r   r   r   r   r   r   F   r   r   c                   @   r   )ÚTTSUsageMetricsDataznText-to-Speech usage metrics data.

    Parameters:
        value: Number of characters processed by TTS.
    r   N)r   r   r	   r
   r   r   r   r   r   r   r   P   r   r   c                   @   r   )ÚTextAggregationMetricsDataa  Text aggregation time metrics data.

    Measures the time from the first LLM token to the first complete sentence,
    representing the latency cost of sentence aggregation in the TTS pipeline.

    Parameters:
        value: Aggregation time in seconds.
    r   Nr   r   r   r   r   r    Z   s   
 	r    c                   @   s*   e Zd ZU dZeed< eed< eed< dS )ÚTurnMetricsDataao  Metrics data for turn detection predictions.

    Parameters:
        is_complete: Whether the turn is predicted to be complete.
        probability: Confidence probability of the turn completion prediction.
        e2e_processing_time_ms: End-to-end processing time in milliseconds,
            measured from VAD speech-to-silence transition to turn completion.
    Úis_completeÚprobabilityÚe2e_processing_time_msN)r   r   r	   r
   Úboolr   r   r   r   r   r   r!   g   s
   
 	r!   c                   @   s*   e Zd ZU dZdZeed< dZeed< dS )ÚSmartTurnMetricsDataaJ  Metrics data for smart turn predictions.

    .. deprecated:: 0.0.104
        Use :class:`TurnMetricsData` instead. This class will be removed in a future version.

    Parameters:
        inference_time_ms: Time taken for inference in milliseconds.
        server_total_time_ms: Total server processing time in milliseconds.
    g        Úinference_time_msÚserver_total_time_msN)r   r   r	   r
   r'   r   r   r(   r   r   r   r   r&   v   s   
 
r&   N)r
   Útypingr   Úpydanticr   r   r   r   r   r   r   r    r!   r&   r   r   r   r   Ú<module>   s   



