
    qi8                        d Z ddlmZmZmZmZmZ ddlmZ ddl	m
Z
 dZdZed   Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Z G d' d(e      Z G d) d*e      Z G d+ d,e      Z  G d- d.e      Z! G d/ d0e      Z" G d1 d2e      Z# G d3 d4e      Z$ G d5 d6e      Z% G d7 d8e      Z& G d9 d:e      Z' G d; d<e      Z( G d= d>e      Z) G d? d@e      Z* G dA dBe      Z+ G dC dDe      Z, G dE dFe,      Z- G dG dHe      Z. G dI dJe      Z/ G dK dLe      Z0 G dM dNe      Z1 G dO dPe      Z2 G dQ dRe      Z3 G dS dTe      Z4 G dU dVe      Z5 G dW dXe      Z6 G dY dZe      Z7 G d[ d\e      Z8 G d] d^e      Z9 G d_ d`e      Z: G da dbe      Z; G dc dde      Z< G de dfe      Z= G dg dhe      Z> G di dje      Z? G dk dle      Z@ G dm dne      ZA G do dpe      ZByq)raC  RTVI protocol v1 message models.

Contains all RTVI protocol v1 message definitions and data structures.
Import this module under the ``RTVI`` alias to use as a namespace::

    import pipecat.processors.frameworks.rtvi.models as RTVI

    msg = RTVI.BotReady(id="1", data=RTVI.BotReadyData(version=RTVI.PROTOCOL_VERSION))
    )AnyDictLiteralMappingOptional)	BaseModel)AggregationTypez1.2.0zrtvi-aic                   R    e Zd ZU dZeZeed<   eed<   eed<   dZ	e
eeef      ed<   y)MessagezaBase RTVI message structure.

    Represents the standard format for RTVI protocol messages.
    labeltypeidNdata)__name__
__module____qualname____doc__MESSAGE_LABELr   MessageLiteral__annotations__strr   r   r   r        [/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/processors/frameworks/rtvi/models.pyr   r   (   s4    
 *E>)
IG%)D(4S>
")r   r   c                   0    e Zd ZU dZeed<   dZee   ed<   y)RawClientMessageDatazEData structure expected from client messages sent to the RTVI server.tNd	r   r   r   r   r   r   r   r   r   r   r   r   r   r   7   s    O
FAx}r   r   c                   :    e Zd ZU dZeed<   eed<   dZee   ed<   y)ClientMessagez9Cleansed data structure for client messages for handling.msg_idr   Nr   )	r   r   r   r   r   r   r   r   r   r   r   r   r!   r!   >   s    CK
ID(3-r   r!   c                   0    e Zd ZU dZeed<   dZee   ed<   y)RawServerResponseDataz7Data structure for server responses to client messages.r   Nr   r   r   r   r   r$   r$   F   s    A
FAx}r   r$   c                   H    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   eed<   y)ServerResponsezThe RTVI-formatted message response from the server to the client.

    This message is used to respond to custom messages sent by the client.
    r   zserver-responser   r   r   N)r   r   r   r   r   r   r   r   r   r   r   r$   r   r   r   r&   r&   M   s.    
 *E>)'8D'#
$8G
r   r&   c                   l    e Zd ZU dZeed<   dZee   ed<   dZee   ed<   dZ	ee   ed<   dZ
ee   ed<   y)AboutClientDatazData about the RTVI client.

    Contains information about the client, including which RTVI library it
    is using, what platform it is on and any additional details, if available.
    libraryNlibrary_versionplatformplatform_versionplatform_details)r   r   r   r   r   r   r*   r   r+   r,   r-   r   r   r   r   r(   r(   Y   sH     L%)OXc])"Hhsm"&*hsm*&*hsm*r   r(   c                   &    e Zd ZU dZeed<   eed<   y)ClientReadyDatazjData format of client ready messages.

    Contains the RTVI protocol version and client information.
    versionaboutN)r   r   r   r   r   r   r(   r   r   r   r/   r/   g   s    
 Lr   r/   c                       e Zd ZU dZeed<   y)ErrorResponseDatazaData for an RTVI error response.

    Contains the error message to send back to the client.
    errorNr   r   r   r   r   r   r   r   r   r3   r3   t   s    
 Jr   r3   c                   H    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   eed<   y)ErrorResponsezqRTVI error response message.

    RTVI formatted error response message for relaying failed client requests.
    r   zerror-responser   r   r   N)r   r   r   r   r   r   r   r   r   r   r   r3   r   r   r   r7   r7   }   s.    
 *E>)&6D'"
#6G
r   r7   c                   &    e Zd ZU dZeed<   eed<   y)	ErrorDataz`Data for an RTVI error event.

    Contains error information including whether it's fatal.
    r4   fatalNr   r   r   r   r   r   boolr   r   r   r9   r9      s    
 JKr   r9   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)ErrorzeRTVI error event message.

    RTVI formatted error message for relaying errors in the pipeline.
    r   r4   r   r   N)r   r   r   r   r   r   r   r   r   r   r9   r   r   r   r>   r>      s'    
 *E>)$D''
$
Or   r>   c                   :    e Zd ZU dZeed<   dZeeee	f      ed<   y)BotReadyDataz_Data for bot ready notification.

    Contains protocol version and initial configuration.
    r0   Nr1   )
r   r   r   r   r   r   r1   r   r   r   r   r   r   r@   r@      s&    
 L)-E8GCH%&-r   r@   c                   H    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   eed<   y)BotReadyzeMessage indicating bot is ready for interaction.

    Sent after bot initialization is complete.
    r   z	bot-readyr   r   r   N)r   r   r   r   r   r   r   r   r   r   r   r@   r   r   r   rB   rB      s-    
 *E>)!,D'+
,G
r   rB   c                   :    e Zd ZU dZeed<   eed<   eeef   ed<   y)LLMFunctionCallMessageDatazData for LLM function call notification.

    Contains function call details including name, ID, and arguments.

    .. deprecated:: 0.0.102
        Use ``LLMFunctionCallInProgressMessageData`` instead.
    function_nametool_call_idargsN)r   r   r   r   r   r   r   r   r   r   r   rD   rD      s$     
#s(
r   rD   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)LLMFunctionCallMessagezMessage notifying of an LLM function call.

    Sent when the LLM makes a function call.

    .. deprecated:: 0.0.102
        Use ``LLMFunctionCallInProgressMessage`` with the
        ``llm-function-call-in-progress`` event type instead.
    r   zllm-function-callr   r   N)r   r   r   r   r   r   r   r   r   r   rD   r   r   r   rI   rI      s)     *E>))<D'%
&<
$$r   rI   c                   .    e Zd ZU dZdZeed<   dZeed<   y)SendTextOptionszyOptions for sending text input to the LLM.

    Contains options for how the pipeline should process the text input.
    Trun_immediatelyaudio_responseN)r   r   r   r   rL   r<   r   rM   r   r   r   rK   rK      s    
 !OT NDr   rK   c                   0    e Zd ZU dZeed<   dZee   ed<   y)SendTextDatazData format for sending text input to the LLM.

    Contains the text content to send and any options for how the pipeline should process it.
    contentNoptions)	r   r   r   r   r   r   rQ   r   rK   r   r   r   rO   rO      s    
 L)-GXo&-r   rO   c                   @    e Zd ZU dZed   ez  ed<   eed<   dZe	ed<   y)AppendToContextDataa&  Data format for appending messages to the context.

    Contains the role, content, and whether to run the message immediately.

    .. deprecated:: 0.0.85
        The RTVI message, append-to-context, has been deprecated. Use send-text
        or custom client and server messages instead.
    )user	assistantrolerP   FrL   N)
r   r   r   r   r   r   r   r   rL   r<   r   r   r   rS   rS      s)     %
&
,,L!OT!r   rS   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)AppendToContextzRTVI message format to append content to the LLM context.

    .. deprecated:: 0.0.85
        The RTVI message, append-to-context, has been deprecated. Use send-text
        or custom client and server messages instead.
    r   zappend-to-contextr   r   N)r   r   r   r   r   r   r   r   r   r   rS   r   r   r   rX   rX      s)     *E>))<D'%
&<
r   rX   c                   &    e Zd ZU dZdZee   ed<   y)LLMFunctionCallStartMessageDatazData for LLM function call start notification.

    Contains the function name being called. Fields may be omitted based on
    the configured function_call_report_level for security.
    NrE   )r   r   r   r   rE   r   r   r   r   r   r   rZ   rZ     s     $(M8C='r   rZ   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)LLMFunctionCallStartMessagezlMessage notifying that an LLM function call has started.

    Sent when the LLM begins a function call.
    r   zllm-function-call-startedr   r   N)r   r   r   r   r   r   r   r   r   r   rZ   r   r   r   r\   r\     s)    
 *E>)1LD'-
.L
))r   r\   c                   @    e Zd ZU dZeed<   eed<   eed<   eez  ed<   y)LLMFunctionCallResultDatazWData for LLM function call result.

    Contains function call details and result.
    rE   rF   	argumentsresultN)r   r   r   r   r   r   dictr   r   r   r^   r^     s$    
 O3Jr   r^   c                   N    e Zd ZU dZeed<   dZee   ed<   dZee	ee
f      ed<   y)$LLMFunctionCallInProgressMessageDatazData for LLM function call in-progress notification.

    Contains function call details including name, ID, and arguments.
    Fields may be omitted based on the configured function_call_report_level for security.
    rF   NrE   r_   )r   r   r   r   r   r   rE   r   r_   r   r   r   r   r   rc   rc   %  s5     #'M8C='-1IxS)*1r   rc   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y) LLMFunctionCallInProgressMessagezwMessage notifying that an LLM function call is in progress.

    Sent when the LLM function call execution begins.
    r   zllm-function-call-in-progressr   r   N)r   r   r   r   r   r   r   r   r   r   rc   r   r   r   re   re   1  s)    
 *E>)5TD'1
2T
..r   re   c                   N    e Zd ZU dZeed<   eed<   dZee   ed<   dZ	ee
   ed<   y)!LLMFunctionCallStoppedMessageDataa  Data for LLM function call stopped notification.

    Contains details about the function call that stopped, including
    whether it was cancelled or completed with a result.
    Fields may be omitted based on the configured function_call_report_level for security.
    rF   	cancelledNrE   r`   )r   r   r   r   r   r   r<   rE   r   r`   r   r   r   r   rg   rg   <  s0     O#'M8C=' FHSM r   rg   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)LLMFunctionCallStoppedMessagezMessage notifying that an LLM function call has stopped.

    Sent when a function call completes (with result) or is cancelled.
    r   zllm-function-call-stoppedr   r   N)r   r   r   r   r   r   r   r   r   r   rg   r   r   r   rj   rj   J  s)    
 *E>)1LD'-
.L
++r   rj   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)BotLLMStartedMessagez2Message indicating bot LLM processing has started.r   zbot-llm-startedr   N
r   r   r   r   r   r   r   r   r   r   r   r   r   rl   rl   U      <)E>)'8D'#
$8r   rl   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)BotLLMStoppedMessagez2Message indicating bot LLM processing has stopped.r   zbot-llm-stoppedr   Nrm   r   r   r   rp   rp   \  rn   r   rp   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)BotTTSStartedMessagez2Message indicating bot TTS processing has started.r   zbot-tts-startedr   Nrm   r   r   r   rr   rr   c  rn   r   rr   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)BotTTSStoppedMessagez2Message indicating bot TTS processing has stopped.r   zbot-tts-stoppedr   Nrm   r   r   r   rt   rt   j  rn   r   rt   c                       e Zd ZU dZeed<   y)TextMessageDatazCData for text-based RTVI messages.

    Contains text content.
    textNr5   r   r   r   rv   rv   q  s    
 Ir   rv   c                   0    e Zd ZU dZdZeed<   eez  ed<   y)BotOutputMessageDatazjData for bot output RTVI messages.

    Extends TextMessageData to include metadata about the output.
    Fspokenaggregated_byN)	r   r   r   r   rz   r<   r   r	   r   r   r   r   ry   ry   z  s    
 FD"S((r   ry   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)BotOutputMessagezMessage containing bot output text.

    An event meant to holistically represent what the bot is outputting,
    along with metadata about the output and if it has been spoken.
    r   z
bot-outputr   r   N)r   r   r   r   r   r   r   r   r   r   ry   r   r   r   r}   r}     s(     *E>)".D',
.
r   r}   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)BotTranscriptionMessagez_Message containing bot transcription text.

    Sent when the bot's speech is transcribed.
    r   zbot-transcriptionr   r   Nr   r   r   r   r   r   r   r   r   r   rv   r   r   r   r   r     s)    
 *E>))<D'%
&<
r   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)BotLLMTextMessagezYMessage containing bot LLM text output.

    Sent when the bot's LLM generates text.
    r   zbot-llm-textr   r   Nr   r   r   r   r   r     (    
 *E>)$2D'.
!2
r   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)BotTTSTextMessagez[Message containing bot TTS text output.

    Sent when text is being processed by TTS.
    r   zbot-tts-textr   r   Nr   r   r   r   r   r     r   r   r   c                   0    e Zd ZU dZeed<   eed<   eed<   y)AudioMessageDatazOData for audio-based RTVI messages.

    Contains audio data and metadata.
    audiosample_ratenum_channelsN)r   r   r   r   r   r   intr   r   r   r   r     s    
 Jr   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)BotTTSAudioMessagez[Message containing bot TTS audio output.

    Sent when the bot's TTS generates audio.
    r   zbot-tts-audior   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s(    
 *E>)%4D'/
"4
r   r   c                   :    e Zd ZU dZeed<   eed<   eed<   eed<   y)UserTranscriptionMessageDatazYData for user transcription messages.

    Contains transcription text and metadata.
    rw   user_id	timestampfinalNr;   r   r   r   r   r     s    
 ILNKr   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)UserTranscriptionMessagezVMessage containing user transcription.

    Sent when user speech is transcribed.
    r   zuser-transcriptionr   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s)    
 *E>)*>D'&
'>
&&r   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)UserLLMTextMessagezbMessage containing user text input for LLM.

    Sent when user text is processed by the LLM.
    r   zuser-llm-textr   r   Nr   r   r   r   r   r     s(    
 *E>)%4D'/
"4
r   r   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)UserStartedSpeakingMessagez-Message indicating user has started speaking.r   zuser-started-speakingr   Nrm   r   r   r   r   r         7)E>)-DD')
*Dr   r   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)UserStoppedSpeakingMessagez-Message indicating user has stopped speaking.r   zuser-stopped-speakingr   Nrm   r   r   r   r   r     r   r   r   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)UserMuteStartedMessagez'Message indicating user has been muted.r   zuser-mute-startedr   Nrm   r   r   r   r   r     s    1)E>))<D'%
&<r   r   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)UserMuteStoppedMessagez)Message indicating user has been unmuted.r   zuser-mute-stoppedr   Nrm   r   r   r   r   r     s    3)E>))<D'%
&<r   r   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)BotStartedSpeakingMessagez,Message indicating bot has started speaking.r   zbot-started-speakingr   Nrm   r   r   r   r   r         6)E>),BD'(
)Br   r   c                   4    e Zd ZU dZeZeed<   dZe	d   ed<   y)BotStoppedSpeakingMessagez,Message indicating bot has stopped speaking.r   zbot-stopped-speakingr   Nrm   r   r   r   r   r     r   r   r   c                   H    e Zd ZU dZeZeed<   dZe	d   ed<   e
eef   ed<   y)MetricsMessagez`Message containing performance metrics.

    Sent to provide performance and usage metrics.
    r   metricsr   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s1    
 *E>)(D')
(
#s(
r   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)ServerMessagezLGeneric server message.

    Used for custom server-to-client messages.
    r   zserver-messager   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s(    
 *E>)&6D'"
#6
Ir   r   c                       e Zd ZU dZeed<   y)AudioLevelMessageDataz%Data format for sending audio levels.valueN)r   r   r   r   floatr   r   r   r   r   r   *  s
    /Lr   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)UserAudioLevelMessagez$Message indicating user audio level.r   zuser-audio-levelr   r   Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   0  s%    .)E>)(:D'$
%:
r   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)BotAudioLevelMessagez#Message indicating bot audio level.r   zbot-audio-levelr   r   Nr   r   r   r   r   r   8  s%    -)E>)'8D'#
$8
r   r   c                   >    e Zd ZU dZeZeed<   dZe	d   ed<   e
ed<   y)SystemLogMessagezMessage including a system log.r   z
system-logr   r   Nr   r   r   r   r   r   @  s$    ))E>)".D',
.
r   r   N)Cr   typingr   r   r   r   r   pydanticr   pipecat.frames.framesr	   PROTOCOL_VERSIONr   r   r   r   r!   r$   r&   r(   r/   r3   r7   r9   r>   r@   rB   rD   rI   rK   rO   rS   rX   rZ   r\   r^   rc   re   rg   rj   rl   rp   rr   rt   rv   ry   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s    
  #
	*i 	*9 I I 	 Y 	 +i +i 	 	I 		 I .9 .	y 	 %Y % i  .9 .") "
i 
(i (*) *		 		29 	2/y /!	 !,I ,99 999 999 999 9i )? )	y 	i 	 	 y  	9 	'y ' E EE E=Y ==Y =C	 CC	 CY I I  I   9  y r   