o
    ig                     @   s   d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
mZmZ ddlmZ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dS )zGoogle RTVI processor and observer implementation.

This module provides integration with Google's services through the RTVI framework,
including models for search responses and an observer for handling Google-specific
frame types.
    )ListLiteralOptional)	BaseModel)FramePushed)RTVIObserverRTVIObserverParamsRTVIProcessor)LLMSearchOriginLLMSearchResponseFramec                   @   s6   e Zd ZU dZee ed< ee ed< ee ed< dS )RTVISearchResponseMessageDataa  Data payload for search response messages in RTVI protocol.

    Parameters:
        search_result: The search result text, if available.
        rendered_content: The rendered content from the search, if available.
        origins: List of search result origins with metadata.
    search_resultrendered_contentoriginsN)	__name__
__module____qualname____doc__r   str__annotations__r   r
    r   r   P/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/services/google/rtvi.pyr      s
   
 r   c                   @   s:   e Zd ZU dZdZed ed< dZed ed< eed< dS )RTVIBotLLMSearchResponseMessagezRTVI message for bot LLM search responses.

    Parameters:
        label: Always "rtvi-ai" for RTVI protocol messages.
        type: Always "bot-llm-search-response" for this message type.
        data: The search response data payload.
    zrtvi-ailabelzbot-llm-search-responsetypedataN)	r   r   r   r   r   r   r   r   r   r   r   r   r   r   %   s
   
 r   c                       sF   e Zd ZdZdef fddZdef fddZdefd	d
Z	  Z
S )GoogleRTVIObserverzRTVI observer for Google service integration.

    Extends the base RTVIObserver to handle Google-specific frame types,
    particularly LLM search response frames from Google services.
    rtvic                    s   t  | dS )z{Initialize the Google RTVI observer.

        Args:
            rtvi: The RTVI processor to send messages through.
        N)super__init__)selfr   	__class__r   r   r   :   s   zGoogleRTVIObserver.__init__r   c                    s<   t  |I dH  |j}t|tr| |I dH  dS dS )zProcess frames being pushed through the pipeline.

        Handles Google-specific frames in addition to the base RTVI frame types.

        Args:
            data: Frame push event data containing frame and metadata.
        N)r   on_push_frameframe
isinstancer   !_handle_llm_search_response_frame)r    r   r$   r!   r   r   r#   B   s   
z GoogleRTVIObserver.on_push_framer$   c                    s0   t t|j|j|jdd}| |I d H  d S )N)r   r   r   )r   )r   r   r   r   r   send_rtvi_message)r    r$   messager   r   r   r&   Q   s   z4GoogleRTVIObserver._handle_llm_search_response_frame)r   r   r   r   r	   r   r   r#   r   r&   __classcell__r   r   r!   r   r   3   s
    r   c                   @   s(   e Zd ZdZdddee fddZdS )GoogleRTVIProcessorzaRTVI processor for Google service integration.

    Creates a specific Google RTVI Observer.
    N)paramsr+   c                K   s   t | S )zCreates a new RTVI Observer.

        Args:
            params: Settings to enable/disable specific messages.
            **kwargs: Additional arguments passed to the observer.

        Returns:
            A new RTVI observer.
        )r   )r    r+   kwargsr   r   r   create_rtvi_observerb   s   
z(GoogleRTVIProcessor.create_rtvi_observer)r   r   r   r   r   r   r-   r   r   r   r   r*   \   s    r*   N)r   typingr   r   r   pydanticr   pipecat.observers.base_observerr   "pipecat.processors.frameworks.rtvir   r   r	   pipecat.services.google.framesr
   r   r   r   r   r*   r   r   r   r   <module>   s   )