o
    ùT·j›õ  ã                   @  sî  U d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZmZmZmZmZmZ d dlmZ d dlZd dlmZ ddlmZ d	d
lmZmZ ddlmZmZmZmZm Z m!Z!m"Z" ddl#m$Z$m%Z%m&Z&m'Z' d	dl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. d	dl/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> ddl?m@Z@mAZA ddlBmCZC ddlDmEZEmFZF ddlGmHZH ddlImJZJ ddlKmLZL ddlMmNZN ddlOmPZPmQZQmRZR ddlSmTZT ddlUmVZV ddlWmXZX ddlYmZZZ dd l[m\Z\ dd!l]m^Z^ dd"l_m`Z` e	�r"d d#lambZc d d#ldmbZe dd$lfmgZgmhZh d%d&gZie jek¡Zld'emd(< G d)d%„ d%e8ƒZnG d*d&„ d&e9ƒZoG d+d,„ d,ƒZpG d-d.„ d.ƒZqG d/d0„ d0ƒZrG d1d2„ d2ƒZsG d3d4„ d4ƒZtG d5d6„ d6ƒZuG d7d8„ d8ƒZvG d9d:„ d:ƒZwG d;d<„ d<ƒZxG d=d>„ d>exƒZyG d?d@„ d@exƒZzG dAdB„ dBexƒZ{G dCdD„ dDexƒZ|G dEdF„ dFexƒZ}G dGdH„ dHexƒZ~G dIdJ„ dJexƒZG dKdL„ dLƒZ€G dMdN„ dNe€ƒZ�G dOdP„ dPe€ƒZ‚G dQdR„ dRe€ƒZƒG dSdT„ dTe€ƒZ„G dUdV„ dVe€ƒZ…G dWdX„ dXe€ƒZ†G dYdZ„ dZe€ƒZ‡dS )[é    )ÚannotationsN)ÚTracebackType)ÚTYPE_CHECKINGÚAnyÚUnionÚCallableÚIteratorÚOptionalÚ	AwaitableÚcast)ÚAsyncIterator)Ú	BaseModelé   )Ú_legacy_responseé   )ÚForksÚ
AsyncForks)ÚBodyÚOmitÚQueryÚHeadersÚNotGivenÚomitÚ	not_given)Úis_givenÚmaybe_transformÚstrip_not_givenÚasync_maybe_transform)ÚSessionsÚAsyncSessionsÚSessionsWithRawResponseÚAsyncSessionsWithRawResponseÚSessionsWithStreamingResponseÚ"AsyncSessionsWithStreamingResponse)ÚSidebandÚAsyncSideband)Úcached_property)ÚFinalRequestOptionsÚconstruct_type_unchecked)ÚSyncAPIResourceÚAsyncAPIResource)Úto_streamed_response_wrapperÚ"async_to_streamed_response_wrapper)Úlive_create_params)ÚOpenAIErrorÚWebSocketConnectionClosedError)Ú	SendQueue)Ú_merge_mappingsÚmake_request_options)ÚEventHandlerRegistry)Ú
ErrorEvent)ÚClientEvent)ÚServerEvent)ÚReconnectingEventÚReconnectingOverridesÚis_recoverable_close)ÚClientEventParam)ÚLiveCreateResponse)ÚSessionConfigParam)ÚWebSocketConnectionOptions)ÚMediaSessionConfigParam)ÚSessionUpdateConfigParam)ÚResponseInputItemParam)ÚClientConnection)ÚOpenAIÚAsyncOpenAIÚLiveÚ	AsyncLivezlogging.LoggerÚlogc                   @  ó„   e Zd Zed5dd„ƒZed6dd„ƒZed7d	d
„ƒZed8dd„ƒZed9dd„ƒZddde	dœd:d d!„Z
i i i dd"d#d$d%fd;d3d4„ZdS )<rD   Úreturnr$   c                 C  ó
   t | jƒS ©N)r$   Ú_client©Úself© rN   ú]/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/openai/resources/live/live.pyÚsideband>   ó   
zLive.sidebandr   c                 C  rI   rJ   )r   rK   rL   rN   rN   rO   ÚforksB   rQ   z
Live.forksr   c                 C  rI   rJ   )r   rK   rL   rN   rN   rO   ÚsessionsF   rQ   zLive.sessionsÚLiveWithRawResponsec                 C  ó   t | ƒS ©a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )rT   rL   rN   rN   rO   Úwith_raw_responseJ   ó   zLive.with_raw_responseÚLiveWithStreamingResponsec                 C  rU   ©zÌ
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )rY   rL   rN   rN   rO   Úwith_streaming_responseT   ó   zLive.with_streaming_responseN©Úextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚsessionr>   Ú	transportúlive_create_params.Transportr^   úHeaders | Noner_   úQuery | Noner`   úBody | Nonera   ú(float | httpx2.Timeout | None | NotGivenr;   c             
   C  s2   | j dt||dœtjƒt||||ddid�td�S )áC  Create a Live WebRTC session.

        Start with the
        [Live prompting guide](https://developers.openai.com/api/docs/guides/live-prompting).

        Args:
          session: Startup configuration for the Live session.

          transport: WebRTC transport with the browser's SDP offer.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        ú/live/sessions©rb   rc   Úbearer_authT©r^   r_   r`   ra   Úsecurity©ÚbodyÚoptionsÚcast_to)Ú_postr   r-   ÚLiveCreateParamsr2   r;   ©rM   rb   rc   r^   r_   r`   ra   rN   rN   rO   Úcreate]   s"   þûûðzLive.createé   ç      à?ç       @é   r   r   Úwebsocket_connection_optionsr=   Úon_reconnectingúBCallable[[ReconnectingEvent], ReconnectingOverrides | None] | NoneÚmax_retriesÚintÚinitial_delayÚfloatÚ	max_delayÚmax_queue_sizeÚLiveConnectionManagerc	           	      C  ó   t | j||||||||d�	S ©a  Connect to Live without query parameters.

        Send session.start with model and session configuration, then wait for session.started. Follow the [Live prompting guide](https://developers.openai.com/api/docs/guides/live-prompting) before writing instructions.
        )	Úclientr_   r^   r{   r|   r~   r€   r‚   rƒ   )r„   rK   ©	rM   r_   r^   r{   r|   r~   r€   r‚   rƒ   rN   rN   rO   ÚconnectŽ   ó   ÷zLive.connect)rH   r$   )rH   r   )rH   r   )rH   rT   )rH   rY   ©rb   r>   rc   rd   r^   re   r_   rf   r`   rg   ra   rh   rH   r;   )r_   r   r^   r   r{   r=   r|   r}   r~   r   r€   r�   r‚   r�   rƒ   r   rH   r„   ©Ú__name__Ú
__module__Ú__qualname__r&   rP   rR   rS   rW   r[   r   rv   r‰   rN   rN   rN   rO   rD   =   ó2    	ö3÷c                   @  rG   )<rE   rH   r%   c                 C  rI   rJ   )r%   rK   rL   rN   rN   rO   rP   «   rQ   zAsyncLive.sidebandr   c                 C  rI   rJ   )r   rK   rL   rN   rN   rO   rR   ¯   rQ   zAsyncLive.forksr   c                 C  rI   rJ   )r   rK   rL   rN   rN   rO   rS   ³   rQ   zAsyncLive.sessionsÚAsyncLiveWithRawResponsec                 C  rU   rV   )r‘   rL   rN   rN   rO   rW   ·   rX   zAsyncLive.with_raw_responseÚAsyncLiveWithStreamingResponsec                 C  rU   rZ   )r’   rL   rN   rN   rO   r[   Á   r\   z!AsyncLive.with_streaming_responseNr]   rb   r>   rc   rd   r^   re   r_   rf   r`   rg   ra   rh   r;   c             
   Ã  s@   �| j dt||dœtjƒI dH t||||ddid�td�I dH S )ri   rj   rk   Nrl   Trm   ro   )rs   r   r-   rt   r2   r;   ru   rN   rN   rO   rv   Ê   s$   €þûûðzAsyncLive.createrw   rx   ry   rz   r   r   r{   r=   r|   r}   r~   r   r€   r�   r‚   rƒ   ÚAsyncLiveConnectionManagerc	           	      C  r…   r†   )r“   rK   rˆ   rN   rN   rO   r‰   û   rŠ   zAsyncLive.connect)rH   r%   )rH   r   )rH   r   )rH   r‘   )rH   r’   r‹   )r_   r   r^   r   r{   r=   r|   r}   r~   r   r€   r�   r‚   r�   rƒ   r   rH   r“   rŒ   rN   rN   rN   rO   rE   ª   r�   c                   @  ó$   e Zd Zddd„Zeddd	„ƒZd
S )rT   ÚliverD   rH   ÚNonec                 C  ó   || _ t |j¡| _d S rJ   )Ú_liver   Úto_raw_response_wrapperrv   ©rM   r•   rN   rN   rO   Ú__init__  ó   
ÿzLiveWithRawResponse.__init__r    c                 C  ó   t | jjƒS rJ   )r    r˜   rS   rL   rN   rN   rO   rS     ó   zLiveWithRawResponse.sessionsN©r•   rD   rH   r–   )rH   r    ©r�   rŽ   r�   r›   r&   rS   rN   rN   rN   rO   rT     ó    
rT   c                   @  r”   )r‘   r•   rE   rH   r–   c                 C  r—   rJ   )r˜   r   Úasync_to_raw_response_wrapperrv   rš   rN   rN   rO   r›   %  rœ   z!AsyncLiveWithRawResponse.__init__r!   c                 C  r�   rJ   )r!   r˜   rS   rL   rN   rN   rO   rS   ,  rž   z!AsyncLiveWithRawResponse.sessionsN©r•   rE   rH   r–   )rH   r!   r    rN   rN   rN   rO   r‘   $  r¡   r‘   c                   @  r”   )rY   r•   rD   rH   r–   c                 C  ó   || _ t|jƒ| _d S rJ   )r˜   r+   rv   rš   rN   rN   rO   r›   2  ó   
ÿz"LiveWithStreamingResponse.__init__r"   c                 C  r�   rJ   )r"   r˜   rS   rL   rN   rN   rO   rS   9  rž   z"LiveWithStreamingResponse.sessionsNrŸ   )rH   r"   r    rN   rN   rN   rO   rY   1  r¡   rY   c                   @  r”   )r’   r•   rE   rH   r–   c                 C  r¤   rJ   )r˜   r,   rv   rš   rN   rN   rO   r›   ?  r¥   z'AsyncLiveWithStreamingResponse.__init__r#   c                 C  r�   rJ   )r#   r˜   rS   rL   rN   rN   rO   rS   F  rž   z'AsyncLiveWithStreamingResponse.sessionsNr£   )rH   r#   r    rN   rN   rN   rO   r’   >  r¡   r’   c                	   @  óÚ   e Zd ZU dZded< ded< ded< ddd	d
di i ddœdQdd „ZdRd"d#„ZdSd%d&„ZdTd(d)„ZdUd,d-„Z	dVd0d1„Z
d2d3d4œdWd8d9„ZdXd;d<„ZdYd@dA„ZdZdBdC„Z	d[d\dHdI„Zd]dKdL„Z	d[d\dMdN„ZdZdOdP„ZdS )^ÚAsyncLiveConnectionú6Represents a live WebSocket connection to the Live APIÚAsyncLiveSessionResourcerb   ÚAsyncLiveResponseResourceÚresponseÚAsyncWebSocketConnectionÚ_connectionNrw   rx   ry   ©Úmake_wsr|   r~   r€   r‚   r_   r^   Ú
send_queueÚ
connectionr¯   úFCallable[[Query, Headers], Awaitable[AsyncWebSocketConnection]] | Noner|   r}   r~   r   r€   r�   r‚   r_   r   r^   r   r°   úSendQueue | NonerH   r–   c          
      C  sr   || _ || _|| _|| _d| _|| _|| _|| _|| _d| _	d| _
|	p%tƒ | _tdd�| _t| ƒ| _t| ƒ| _d S )Nr   F©Úuse_lock)r­   Ú_make_wsÚ_on_reconnectingÚ_max_retriesÚ_reconnect_attemptÚ_initial_delayÚ
_max_delayÚ_extra_queryÚ_extra_headersÚ_intentionally_closedÚ_is_reconnectingr0   Ú_send_queuer3   Ú_event_handler_registryr©   rb   rª   r«   ©
rM   r±   r¯   r|   r~   r€   r‚   r_   r^   r°   rN   rN   rO   r›   S  ó   
zAsyncLiveConnection.__init__úAsyncIterator[ServerEvent]c              
   C s�   �ddl m}m} 	 z
|  ¡ I dH V  W n2 |y   Y dS  |yF } z|  |¡I dH s<| j ¡ }|r;td|d�|‚‚ W Y d}~nd}~ww q
©zq
        An infinite-iterator that will continue to yield events until
        the connection is closed.
        r   )ÚConnectionClosedOKÚConnectionClosedErrorTNz0WebSocket connection closed with unsent messages)Úunsent_messages©Úwebsockets.exceptionsrÆ   rÇ   ÚrecvÚ
_reconnectrÀ   Údrainr/   ©rM   rÆ   rÇ   ÚexcÚunsentrN   rN   rO   Ú	__aiter__q  s,   €
þýù€ÿûzAsyncLiveConnection.__aiter__r6   c                 Ã  sb   �|   |  ¡ I dH ¡}ttt|ƒtƒrtd|ƒ d¡nt|ddƒ}t|tƒr/|r/|dkr/d| _	|S )ú±
        Receive the next message from the connection and parses it into a `ServerEvent` object.

        Canceling this method is safe. There's no risk of losing data.
        Núdict[str, object]ÚtypeÚerrorr   ©
Úparse_eventÚ
recv_bytesÚ
isinstancer   ÚobjectÚdictÚgetÚgetattrÚstrr¹   ©rM   ÚeventÚ
event_typerN   rN   rO   rË   ‡  s   €ÿ
ýzAsyncLiveConnection.recvÚbytesc              	   Ã  s”   �| j jdd�I dH }t dt|ƒ¡ | jrHzt |¡}W n tt	fy*   | Y S w t
|tƒr8td|ƒ d¡nd}t
|tƒrH|rH|dkrHd| _|S )	á  Receive the next message from the connection as raw bytes.

        Canceling this method is safe. There's no risk of losing data.

        If you want to parse the message into a `ServerEvent` object like `.recv()` does,
        then you can call `.parse_event(data)`.
        F©ÚdecodeNú$Received WebSocket message: %i bytesrÓ   rÔ   rÕ   r   ©r­   rË   rF   ÚdebugÚlenr¹   ÚjsonÚloadsÚ
ValueErrorÚRecursionErrorrÙ   rÛ   r   rÜ   rÞ   ©rM   ÚmessageÚ
event_datará   rN   rN   rO   rØ   ™  s   €ÿzAsyncLiveConnection.recv_bytesrà   úClientEvent | ClientEventParamc                 Ã  s~   �t |tƒr|jdddd�n
t t|tƒI d H ¡}| jr$| j 	|¡ d S z| j
 |¡I d H  W d S  ty>   | j 	|¡ ‚ w ©NT©Úuse_api_namesÚexclude_defaultsÚexclude_unset)rÙ   r   Úto_jsonrê   Údumpsr   r:   r¿   rÀ   Úenqueuer­   ÚsendÚ	Exception©rM   rà   ÚdatarN   rN   rO   rú   ®  s   €ÿýþzAsyncLiveConnection.sendrý   úbytes | strc                 Ã  sF   �| j rt|tƒr|n| d¡}| j |¡ d S | j |¡I d H  d S ©Nzutf-8©r¿   rÙ   rÞ   rå   rÀ   rù   r­   rú   ©rM   rý   ÚrawrN   rN   rO   Úsend_raw½  s   €zAsyncLiveConnection.send_rawéè  Ú ©ÚcodeÚreasonr  r  rÞ   c                Ã  s"   �d| _ | jj||d�I d H  d S ©NTr  ©r¾   r­   Úclose©rM   r  r  rN   rN   rO   r  Ä  s   €zAsyncLiveConnection.closeústr | bytesc                 C  ó   t ttt |¡t ttƒd�ƒS ©z�
        Converts a raw `str` or `bytes` message into a `ServerEvent` object.

        This is helpful if you're using `.recv_bytes()`.
        )ÚvalueÚtype_©r   r6   r(   rê   rë   r   ©rM   rý   rN   rN   rO   r×   È  ó   zAsyncLiveConnection.parse_eventrÏ   rû   Úboolc              	   Ã  sÒ  �ddl }| jdu s| jdu rdS ddlm} d}t||ƒr'|jdur'|jj}t|ƒs-dS d| _	t
| jd | jd ƒD ]¨}|| _t| jd|d   | jƒ}d	t ¡ d
  }|| }t|| j||| j| jd�}	z|  |	¡}
W n ty{   d| _	Y  dS w |
dur‹|
 d¡r‹d| _	 dS |
dur¡d|
v r˜|
d | _d|
v r¡|
d | _t d|| j|¡ | |¡I dH  | jr»d| _	 dS z|  | j| j¡I dH | _t d¡ d| _	|  ¡ I dH  W  dS  tyã   Y q;w d| _	dS )úÀAttempt to reconnect after a connection failure.

        Returns ``True`` if a new connection was established, ``False`` if the
        caller should re-raise the original exception.
        r   NF©rÇ   éî  Tr   é   ç      è?ç      Ð?©ÚattemptÚmax_attemptsÚdelayÚ
close_coder_   r^   Úabortr_   r^   ú?Reconnecting to WebSocket API (attempt %d/%d) after %.1fs delayúReconnected to WebSocket API)Úasyncior·   r¶   rÊ   rÇ   rÙ   Úrcvdr  r9   r¿   Úranger¹   r¸   Úminrº   r»   Úrandomr7   r¼   r½   rû   rÜ   rF   ÚinfoÚsleepr¾   r­   Ú_flush_send_queue)rM   rÏ   r$  rÇ   r   r  Ú
base_delayÚjitterr  rà   ÚresultrN   rN   rO   rÌ   Ð  sv   €ú	þ

ü
ÿzAsyncLiveConnection._reconnectc                 ƒ  sH   �d	‡ fdd„}zˆ j  |¡I dH  W dS  ty#   t d¡ Y dS w )
ú5Send all queued messages over the current connection.rý   rÞ   rH   r–   c                 “  s   �ˆ j  | ¡I d H  d S rJ   ©r­   rú   ©rý   rL   rN   rO   Ú_send   s   €z4AsyncLiveConnection._flush_send_queue.<locals>._sendNú*Failed to flush send queue after reconnect)rý   rÞ   rH   r–   )rÀ   Úflush_asyncrû   rF   Úwarning)rM   r2  rN   rL   rO   r+    s   €ÿz%AsyncLiveConnection._flush_send_queuerá   ÚhandlerúCallable[..., Any] | NoneúNUnion[AsyncLiveConnection, Callable[[Callable[..., Any]], Callable[..., Any]]]c                   ó.   |durˆj  ˆ |¡ ˆS d‡ ‡fdd„}|S )a-  Adds the handler to the end of the handlers list for the given event type.

        No checks are made to see if the handler has already been added. Multiple calls
        passing the same combination of event type and handler will result in the handler
        being added, and called, multiple times.

        Can be used as a method (returns ``self`` for chaining)::

            connection.on("session.started", my_handler)

        Or as a decorator::

            @connection.on("session.started")
            async def my_handler(event): ...
        NÚfnúCallable[..., Any]rH   c                   ó   ˆj  ˆ | ¡ | S rJ   ©rÁ   Úadd©r:  ©rá   rM   rN   rO   Ú	decorator>  ó   z)AsyncLiveConnection.on.<locals>.decorator©r:  r;  rH   r;  r=  ©rM   rá   r6  rA  rN   r@  rO   Úon(  ó
   zAsyncLiveConnection.onr;  c                 C  ó   | j  ||¡ | S ©z-Remove a previously registered event handler.©rÁ   Úremove©rM   rá   r6  rN   rN   rO   ÚoffD  ó   zAsyncLiveConnection.offc                   ó2   |durˆj jˆ |dd� ˆS d	‡ ‡fdd„}|S )
úbRegister a one-time event handler.

        Automatically removed after first invocation.
        NT©Úoncer:  r;  rH   c                   ó   ˆj jˆ | dd� | S ©NTrP  r=  r?  r@  rN   rO   rA  T  ó   z+AsyncLiveConnection.once.<locals>.decoratorrC  r=  rD  rN   r@  rO   rQ  I  ó
   zAsyncLiveConnection.oncec                 Ã  s´   �ddl }| 2 zO3 dH W }|j}| j |¡}| j d¡}|dkr0|s0|s0t|tƒr0td|› �ƒ‚|D ]}||ƒ}| |¡rB|I dH  q2|D ]}||ƒ}| |¡rU|I dH  qEq6 dS )al  Run the event loop, dispatching received events to registered handlers.

        Blocks until the connection is closed. This is the push-based
        alternative to iterating with ``async for event in connection``.

        If an ``"error"`` event arrives and no handler is registered for
        ``"error"`` or ``"event"``, an ``OpenAIError`` is raised.
        r   Nrà   rÕ   úWebSocket error: )r$  rÔ   rÁ   Úget_handlersrÙ   r4   r.   Úiscoroutine)rM   r$  rà   rá   ÚspecificÚgenericr6  r.  rN   rN   rO   Údispatch_eventsZ  s*   €	


€

€ýòz#AsyncLiveConnection.dispatch_events)r±   r¬   r¯   r²   r|   r}   r~   r   r€   r�   r‚   r�   r_   r   r^   r   r°   r³   rH   r–   )rH   rÄ   ©rH   r6   ©rH   râ   ©rà   rñ   rH   r–   ©rý   rþ   rH   r–   ©r  r   r  rÞ   rH   r–   ©rý   r  rH   r6   ©rÏ   rû   rH   r  ©rH   r–   rJ   )rá   rÞ   r6  r7  rH   r8  )rá   rÞ   r6  r;  rH   r§   )r�   rŽ   r�   Ú__doc__Ú__annotations__r›   rÑ   rË   rØ   rú   r  r  r×   rÌ   r+  rE  rL  rQ  r[  rN   rN   rN   rO   r§   K  s:   
 õ







Mÿ
ÿr§   c                   @  ó„   e Zd ZdZddddddœd=dd„Zd>dd„Z	d?d@d%d&„ZdAd(d)„Z	d?d@d*d+„ZdBd-d.„Z	e	Z
dCd0d1„ZdDd3d4„ZdEd;d<„ZdS )Fr“   a  
    Context manager over a `AsyncLiveConnection` that is returned by `live.connect()`

    This context manager ensures that the connection will be closed when it exits.

    ---

    Note that if your application doesn't work well with the context manager approach then you
    can call the `.enter()` method directly to initiate a connection.

    **Warning**: You must remember to close the connection with `.close()`.

    ```py
    connection = await client.live.connect(...).enter()
    # ...
    await connection.close()
    ```
    Nrw   rx   ry   rz   ©r|   r~   r€   r‚   rƒ   r‡   rC   r_   r   r^   r   r{   r=   r|   r}   r~   r   r€   r�   r‚   rƒ   rH   r–   c       	   
      C  óR   || _ d | _|| _|| _|| _|| _|| _|| _|| _t	|	d�| _
tdd�| _d S )N©Ú	max_bytesFr´   )Ú#_AsyncLiveConnectionManager__clientÚ'_AsyncLiveConnectionManager__connectionÚ(_AsyncLiveConnectionManager__extra_queryÚ*_AsyncLiveConnectionManager__extra_headersÚ9_AsyncLiveConnectionManager__websocket_connection_optionsÚ,_AsyncLiveConnectionManager__on_reconnectingÚ(_AsyncLiveConnectionManager__max_retriesÚ*_AsyncLiveConnectionManager__initial_delayÚ&_AsyncLiveConnectionManager__max_delayr0   Ú'_AsyncLiveConnectionManager__send_queuer3   Ú3_AsyncLiveConnectionManager__event_handler_registry©
rM   r‡   r_   r^   r{   r|   r~   r€   r‚   rƒ   rN   rN   rO   r›   �  ó   z#AsyncLiveConnectionManager.__init__rà   rñ   c                 C  ó:   t |tƒr|jdddd�nt t|tƒ¡}| j |¡ dS ©zÜQueue a message to be sent when the connection is established.

        This can be called before entering the context manager. Queued messages
        are automatically sent once the WebSocket connection opens.
        Tró   N)	rÙ   r   r÷   rê   rø   r   r:   rt  rù   rü   rN   rN   rO   rú   ¦  ó
   ÿýzAsyncLiveConnectionManager.sendrá   rÞ   r6  r7  úUUnion[AsyncLiveConnectionManager, Callable[[Callable[..., Any]], Callable[..., Any]]]c                   r9  )zÚRegister an event handler before the connection is established.

        Handlers are transferred to the connection on enter. Supports the
        same method and decorator forms as ``AsyncLiveConnection.on``.
        Nr:  r;  rH   c                   r<  rJ   ©ru  r>  r?  r@  rN   rO   rA  ¿  rB  z0AsyncLiveConnectionManager.on.<locals>.decoratorrC  r|  rD  rN   r@  rO   rE  ³  ó
   zAsyncLiveConnectionManager.onr;  c                 C  rG  rH  )ru  rJ  rK  rN   rN   rO   rL  Å  rM  zAsyncLiveConnectionManager.offc                   rN  )
úGRegister a one-time event handler before the connection is established.NTrP  r:  r;  rH   c                   rR  rS  r|  r?  r@  rN   rO   rA  Ò  rT  z2AsyncLiveConnectionManager.once.<locals>.decoratorrC  r|  rD  rN   r@  rO   rQ  Ê  ó
   zAsyncLiveConnectionManager.oncer§   c                 Ã  sx   �|   | j| j¡I dH }t|| jdur| j nd| j| j| j| j| j| j| jd�	| _	| j
 | j	j¡ | j	 ¡ I dH  | j	S )ay  
        If your application doesn't work well with the context manager approach then you
        can call this method directly to initiate a connection.

        **Warning**: You must remember to close the connection with `.close()`.

        ```py
        connection = await client.live.connect(...).enter()
        # ...
        await connection.close()
        ```
        Nr®   )Ú_connect_wsrm  rn  r§   rp  rq  rr  rs  rt  rl  ru  Ú
merge_intorÁ   r+  ©rM   ÚwsrN   rN   rO   Ú
__aenter__Ø  s    €÷z%AsyncLiveConnectionManager.__aenter__r¬   c              
   Ã  sZ  �zddl m} W n ty } ztdƒ|‚d }~ww |  ¡ ji | jjj¥|¥d�}|jdddœ 	|j
|j
¡d�}| j tjd	t|ƒt|ƒd
did�¡I d H }| j |j¡ | jj tt|jƒ¡¡}|jdddœ 	|j
|j
¡d�}dd„ | jji | jjt|jƒrƒ|jni fD ƒ}t d¡ | jr•t d¡ |t|ƒfd tt| ¡ ƒi ƒdœ| j¤ŽI d H S )Nr   )Ú_WebSocketConnectú9You need to install `openai[realtime]` to use this method©Úparamsrƒ  Úwss©ÚhttpÚhttps©ÚschemerÜ   rl   T©ÚmethodÚurlÚheadersrn   c                 S  ó,   i | ]}|  ¡ D ]\}}| ¡ ||f“qqS rN   ©ÚitemsÚlower©Ú.0Ú
header_setÚkeyr  rN   rN   rO   Ú
<dictcomp>  ó    øùÿz:AsyncLiveConnectionManager._connect_ws.<locals>.<dictcomp>úConnecting to WebSocket APIú,Custom WebSocket connection options provided©Úuser_agent_headerÚadditional_headers)Úlib._websocketr…  ÚImportErrorr.   Ú_prepare_urlÚ	copy_withrk  Úbase_urlrˆ  rÜ   rŽ  Ú_prepare_optionsr'   Ú	constructrÞ   rÛ   r‘  Úcopy_merge_paramsÚqsÚ	stringifyr   r   Úauth_headersÚdefault_headersr   r’  rF   rè   ro  r1   Úvalues©rM   r_   r^   r‰   rÏ   r‘  rq   r’  rN   rN   rO   r€  ú  sZ   €
€ÿÿþÿü
ÿÿüþ


ÿýüz&AsyncLiveConnectionManager._connect_wsú
httpx2.URLc                 C  ób   | j jd urt | j j¡}n| j jj}|dkrdnd}| j jj|d�}|j d¡d }|j|d�S ©Nr‹  rƒ  r‰  r�  ó   /s   /live/sessions)Úraw_path)	rk  Úwebsocket_base_urlÚhttpx2ÚURLÚ	_base_urlrŽ  r¥  r´  Úrstrip©rM   r¦  rŽ  Ú	ws_schemeÚmerge_raw_pathrN   rN   rO   r¤  (  ó   
z'AsyncLiveConnectionManager._prepare_urlÚexc_typeútype[BaseException] | NonerÏ   úBaseException | NoneÚexc_tbúTracebackType | Nonec                 Ã  s$   �| j d ur| j  ¡ I d H  d S d S rJ   )rl  r  ©rM   r¾  rÏ   rÁ  rN   rN   rO   Ú	__aexit__3  s   €
ÿz$AsyncLiveConnectionManager.__aexit__)r‡   rC   r_   r   r^   r   r{   r=   r|   r}   r~   r   r€   r�   r‚   r�   rƒ   r   rH   r–   r^  rJ   )rá   rÞ   r6  r7  rH   r{  )rá   rÞ   r6  r;  rH   r“   )rH   r§   )r_   r   r^   r   rH   r¬   ©rH   r°  ©r¾  r¿  rÏ   rÀ  rÁ  rÂ  rH   r–   )r�   rŽ   r�   rd  r›   rú   rE  rL  rQ  r„  Úenterr€  r¤  rÄ  rN   rN   rN   rO   r“   y  s&    õ
ÿ
ÿ
 

.r“   c                	   @  r¦   )^ÚLiveConnectionr¨   ÚLiveSessionResourcerb   ÚLiveResponseResourcer«   ÚWebSocketConnectionr­   Nrw   rx   ry   r®   r±   r¯   ú6Callable[[Query, Headers], WebSocketConnection] | Noner|   r}   r~   r   r€   r�   r‚   r_   r   r^   r   r°   r³   rH   r–   c          
      C  sr   || _ || _|| _|| _d| _|| _|| _|| _|| _d| _	d| _
|	p%tƒ | _tdd�| _t| ƒ| _t| ƒ| _d S )Nr   FTr´   )r­   r¶   r·   r¸   r¹   rº   r»   r¼   r½   r¾   r¿   r0   rÀ   r3   rÁ   rÉ  rb   rÊ  r«   rÂ   rN   rN   rO   r›   B  rÃ   zLiveConnection.__init__úIterator[ServerEvent]c              
   c  s„   � ddl m}m} 	 z|  ¡ V  W n/ |y   Y dS  |y@ } z|  |¡s6| j ¡ }|r5td|d�|‚‚ W Y d}~nd}~ww q
rÅ   rÉ   rÎ   rN   rN   rO   Ú__iter__`  s,   €

þýù€ÿûzLiveConnection.__iter__r6   c                 C  sZ   |   |  ¡ ¡}ttt|ƒtƒrtd|ƒ d¡nt|ddƒ}t|tƒr+|r+|dkr+d| _	|S )rÒ   rÓ   rÔ   NrÕ   r   rÖ   rß   rN   rN   rO   rË   v  s   ÿ
ýzLiveConnection.recvrâ   c              	   C  sŒ   | j jdd�}t dt|ƒ¡ | jrDzt |¡}W n tt	fy&   | Y S w t
|tƒr4td|ƒ d¡nd}t
|tƒrD|rD|dkrDd| _|S )	rã   Frä   ræ   rÓ   rÔ   NrÕ   r   rç   rî   rN   rN   rO   rØ   ˆ  s   ÿzLiveConnection.recv_bytesrà   rñ   c                 C  sp   t |tƒr|jdddd�nt t|tƒ¡}| jr | j 	|¡ d S z	| j
 |¡ W d S  ty7   | j 	|¡ ‚ w rò   )rÙ   r   r÷   rê   rø   r   r:   r¿   rÀ   rù   r­   rú   rû   rü   rN   rN   rO   rú   �  s   ÿýþzLiveConnection.sendrý   rþ   c                 C  s>   | j rt|tƒr
|n| d¡}| j |¡ d S | j |¡ d S rÿ   r   r  rN   rN   rO   r  ¬  s
   zLiveConnection.send_rawr  r  r  r  r  rÞ   c                C  s   d| _ | jj||d� d S r	  r
  r  rN   rN   rO   r  ³  s   zLiveConnection.closer  c                 C  r  r  r  r  rN   rN   rO   r×   ·  r  zLiveConnection.parse_eventrÏ   rû   r  c           
   	   C  s¶  | j du s
| jdu rdS ddlm} d}t||ƒr"|jdur"|jj}t|ƒs(dS d| _t	| j
d | jd ƒD ]Ÿ}|| _
t| jd|d   | jƒ}d	t ¡ d
  }|| }t|| j||| j| jd�}z|   |¡}	W n tyv   d| _Y  dS w |	dur†|	 d¡r†d| _ dS |	durœd|	v r“|	d | _d|	v rœ|	d | _t d|| j|¡ t |¡ | jr³d| _ dS z|  | j| j¡| _t d¡ d| _|  ¡  W  dS  tyÕ   Y q6w d| _dS )r  NFr   r  r  Tr   r  r  r  r  r!  r_   r^   r"  r#  )r·   r¶   rÊ   rÇ   rÙ   r%  r  r9   r¿   r&  r¹   r¸   r'  rº   r»   r(  r7   r¼   r½   rû   rÜ   rF   r)  Útimer*  r¾   r­   r+  )
rM   rÏ   rÇ   r   r  r,  r-  r  rà   r.  rN   rN   rO   rÌ   ¿  sr   ú	þ

ü

ÿzLiveConnection._reconnectc                   s:   zˆ j  ‡ fdd„¡ W dS  ty   t d¡ Y dS w )r/  c                   s   ˆ j  | ¡S rJ   r0  r1  rL   rN   rO   Ú<lambda>  s    z2LiveConnection._flush_send_queue.<locals>.<lambda>r3  N)rÀ   Ú
flush_syncrû   rF   r5  rL   rN   rL   rO   r+  
  s
   ÿz LiveConnection._flush_send_queuerá   r6  r7  úIUnion[LiveConnection, Callable[[Callable[..., Any]], Callable[..., Any]]]c                   r9  )a'  Adds the handler to the end of the handlers list for the given event type.

        No checks are made to see if the handler has already been added. Multiple calls
        passing the same combination of event type and handler will result in the handler
        being added, and called, multiple times.

        Can be used as a method (returns ``self`` for chaining)::

            connection.on("session.started", my_handler)

        Or as a decorator::

            @connection.on("session.started")
            def my_handler(event): ...
        Nr:  r;  rH   c                   r<  rJ   r=  r?  r@  rN   rO   rA  '  rB  z$LiveConnection.on.<locals>.decoratorrC  r=  rD  rN   r@  rO   rE    rF  zLiveConnection.onr;  c                 C  rG  rH  rI  rK  rN   rN   rO   rL  -  rM  zLiveConnection.offc                   rN  )
rO  NTrP  r:  r;  rH   c                   rR  rS  r=  r?  r@  rN   rO   rA  =  rT  z&LiveConnection.once.<locals>.decoratorrC  r=  rD  rN   r@  rO   rQ  2  rU  zLiveConnection.oncec                 C  sx   | D ]7}|j }| j |¡}| j d¡}|dkr'|s'|s't|tƒr'td|› �ƒ‚|D ]}||ƒ q)|D ]}||ƒ q2qdS )ay  Run the event loop, dispatching received events to registered handlers.

        Blocks the current thread until the connection is closed. This is the push-based
        alternative to iterating with ``for event in connection``.

        If an ``"error"`` event arrives and no handler is registered for
        ``"error"`` or ``"event"``, an ``OpenAIError`` is raised.
        rà   rÕ   rV  N)rÔ   rÁ   rW  rÙ   r4   r.   )rM   rà   rá   rY  rZ  r6  rN   rN   rO   r[  C  s   	


ÿôzLiveConnection.dispatch_events)r±   rË  r¯   rÌ  r|   r}   r~   r   r€   r�   r‚   r�   r_   r   r^   r   r°   r³   rH   r–   )rH   rÍ  r\  r]  r^  r_  r`  ra  rb  rc  rJ   )rá   rÞ   r6  r7  rH   rÒ  )rá   rÞ   r6  r;  rH   rÈ  )r�   rŽ   r�   rd  re  r›   rÎ  rË   rØ   rú   r  r  r×   rÌ   r+  rE  rL  rQ  r[  rN   rN   rN   rO   rÈ  :  s:   
 õ







Kÿ
ÿrÈ  c                   @  rf  )Fr„   a  Context manager over a `LiveConnection` that is returned by `live.connect()`

    This context manager ensures that the connection will be closed when it exits.

    ---

    Note that if your application doesn't work well with the context manager approach then you
    can call the `.enter()` method directly to initiate a connection.

    **Warning**: You must remember to close the connection with `.close()`.

    ```py
    connection = client.live.connect(...).enter()
    # ...
    connection.close()
    ```
    Nrw   rx   ry   rz   rg  r‡   rB   r_   r   r^   r   r{   r=   r|   r}   r~   r   r€   r�   r‚   rƒ   rH   r–   c       	   
      C  rh  )Nri  Tr´   )Ú_LiveConnectionManager__clientÚ"_LiveConnectionManager__connectionÚ#_LiveConnectionManager__extra_queryÚ%_LiveConnectionManager__extra_headersÚ4_LiveConnectionManager__websocket_connection_optionsÚ'_LiveConnectionManager__on_reconnectingÚ#_LiveConnectionManager__max_retriesÚ%_LiveConnectionManager__initial_delayÚ!_LiveConnectionManager__max_delayr0   Ú"_LiveConnectionManager__send_queuer3   Ú._LiveConnectionManager__event_handler_registryrv  rN   rN   rO   r›   o  rw  zLiveConnectionManager.__init__rà   rñ   c                 C  rx  ry  )	rÙ   r   r÷   rê   rø   r   r:   rÜ  rù   rü   rN   rN   rO   rú   ˆ  rz  zLiveConnectionManager.sendrá   rÞ   r6  r7  úPUnion[LiveConnectionManager, Callable[[Callable[..., Any]], Callable[..., Any]]]c                   r9  )zÕRegister an event handler before the connection is established.

        Handlers are transferred to the connection on enter. Supports the
        same method and decorator forms as ``LiveConnection.on``.
        Nr:  r;  rH   c                   r<  rJ   ©rÝ  r>  r?  r@  rN   rO   rA  ¡  rB  z+LiveConnectionManager.on.<locals>.decoratorrC  rß  rD  rN   r@  rO   rE  •  r}  zLiveConnectionManager.onr;  c                 C  rG  rH  )rÝ  rJ  rK  rN   rN   rO   rL  §  rM  zLiveConnectionManager.offc                   rN  )
r~  NTrP  r:  r;  rH   c                   rR  rS  rß  r?  r@  rN   rO   rA  ´  rT  z-LiveConnectionManager.once.<locals>.decoratorrC  rß  rD  rN   r@  rO   rQ  ¬  r  zLiveConnectionManager.oncerÈ  c                 C  sj   |   | j| j¡}t|| jdur| j nd| j| j| j| j| j| j| jd�	| _	| j
 | j	j¡ | j	 ¡  | j	S )am  
        If your application doesn't work well with the context manager approach then you
        can call this method directly to initiate a connection.

        **Warning**: You must remember to close the connection with `.close()`.

        ```py
        connection = client.live.connect(...).enter()
        # ...
        connection.close()
        ```
        Nr®   )r€  rÕ  rÖ  rÈ  rØ  rÙ  rÚ  rÛ  rÜ  rÔ  rÝ  r�  rÁ   r+  r‚  rN   rN   rO   Ú	__enter__º  s   ÷
zLiveConnectionManager.__enter__rË  c              
   C  sL  zddl m} W n ty } ztdƒ|‚d }~ww |  ¡ ji | jjj¥|¥d�}|jdddœ 	|j
|j
¡d�}| j tjd	t|ƒt|ƒd
did�¡}| j |j¡ | jj tt|jƒ¡¡}|jdddœ 	|j
|j
¡d�}dd„ | jji | jjt|jƒr|jni fD ƒ}t d¡ | jr‘t d¡ |t|ƒfd tt| ¡ ƒi ƒdœ| j¤ŽS )Nr   )r‰   r†  r‡  rƒ  r‰  rŠ  r�  rÜ   rl   Tr�  c                 S  r“  rN   r”  r—  rN   rN   rO   r›  õ  rœ  z5LiveConnectionManager._connect_ws.<locals>.<dictcomp>r�  rž  rŸ  )Úwebsockets.sync.clientr‰   r£  r.   r¤  r¥  rÓ  r¦  rˆ  rÜ   rŽ  r§  r'   r¨  rÞ   rÛ   r‘  r©  rª  r«  r   r   r¬  r­  r   r’  rF   rè   r×  r1   r®  r¯  rN   rN   rO   r€  Ü  sX   
€ÿÿþÿüÿÿüþ


ÿýüz!LiveConnectionManager._connect_wsr°  c                 C  r±  r²  )	rÓ  rµ  r¶  r·  r¸  rŽ  r¥  r´  r¹  rº  rN   rN   rO   r¤  
  r½  z"LiveConnectionManager._prepare_urlr¾  r¿  rÏ   rÀ  rÁ  rÂ  c                 C  s   | j d ur| j  ¡  d S d S rJ   )rÔ  r  rÃ  rN   rN   rO   Ú__exit__  s   
ÿzLiveConnectionManager.__exit__)r‡   rB   r_   r   r^   r   r{   r=   r|   r}   r~   r   r€   r�   r‚   r�   rƒ   r   rH   r–   r^  rJ   )rá   rÞ   r6  r7  rH   rÞ  )rá   rÞ   r6  r;  rH   r„   )rH   rÈ  )r_   r   r^   r   rH   rË  rÅ  rÆ  )r�   rŽ   r�   rd  r›   rú   rE  rL  rQ  rà  rÇ  r€  r¤  râ  rN   rN   rN   rO   r„   \  s&    õ
ÿ
ÿ
 

.r„   c                   @  ó   e Zd Zddd„ZdS )	ÚBaseLiveConnectionResourcer±   rÈ  rH   r–   c                 C  ó
   || _ d S rJ   ©r­   ©rM   r±   rN   rN   rO   r›     ó   
z#BaseLiveConnectionResource.__init__N)r±   rÈ  rH   r–   ©r�   rŽ   r�   r›   rN   rN   rN   rO   rä    ó    rä  c                   @  ót   e Zd Zeddd„ƒZeddd„ƒZedd	d
„ƒZeddd„ƒZedœd dd„Z	edœd!dd„Z
edœd"dd„ZdS )#rÉ  rH   ÚLiveSessionCommentaryResourcec                 C  rI   rJ   )rì  r­   rL   rN   rN   rO   Ú
commentary"  rQ   zLiveSessionResource.commentaryÚLiveSessionInputAudioResourcec                 C  rI   rJ   )rî  r­   rL   rN   rN   rO   Úinput_audio&  rQ   zLiveSessionResource.input_audioÚLiveSessionInstructionsResourcec                 C  rI   rJ   )rð  r­   rL   rN   rN   rO   Úinstructions*  rQ   z LiveSessionResource.instructionsÚLiveSessionThinkingResourcec                 C  rI   rJ   )rò  r­   rL   rN   rN   rO   Úthinking.  rQ   zLiveSessionResource.thinking©Úevent_idrõ  úOptional[str] | Omitr–   c                C  ó    | j  tttd|dœƒƒ¡ dS ©z…Request that the Live session close.

        The terminal `session.closed` event contains the close reason and final usage.
        zsession.close©rÔ   rõ  N©r­   rú   r   r:   r   ©rM   rõ  rN   rN   rO   r  2  s    zLiveSessionResource.closerb   r?   c             	   C  ó"   | j  tttd||dœƒƒ¡ dS ©zŒUpdate the delegation settings of an active Live session.

        The server acknowledges accepted changes with `session.updated`.
        zsession.update©rÔ   rb   rõ  Nrú  ©rM   rb   rõ  rN   rN   rO   Úupdate9  ó
   ÿÿzLiveSessionResource.updater<   c             	   C  rü  ©z„Start a Live session on a primary WebSocket.

        Send this event before other commands and wait for `session.started`.
        zsession.startrþ  Nrú  rÿ  rN   rN   rO   ÚstartD  s   ÿzLiveSessionResource.startN)rH   rì  )rH   rî  )rH   rð  )rH   rò  ©rõ  rö  rH   r–   ©rb   r?   rõ  rö  rH   r–   ©rb   r<   rõ  rö  rH   r–   ©r�   rŽ   r�   r&   rí  rï  rñ  ró  r   r  r   r  rN   rN   rN   rO   rÉ  !  s    rÉ  c                   @  ó   e Zd Zedœdd
d„ZdS )rì  rô  ÚcontentrÞ   Údelegation_idúOptional[str]rõ  rö  rH   r–   c             
   C  ó$   | j  tttd|||dœƒƒ¡ dS ©z{
        Provide context the Live model can communicate to the user, optionally for an existing client delegation.
        zsession.commentary.append©rÔ   r	  r
  rõ  Nrú  ©rM   r	  r
  rõ  rN   rN   rO   ÚappendO  ó   üÿþÿz$LiveSessionCommentaryResource.appendN©r	  rÞ   r
  r  rõ  rö  rH   r–   ©r�   rŽ   r�   r   r  rN   rN   rN   rO   rì  N  ó    rì  c                   @  ó<   e Zd Zedœddd	„Zedœdd
d„Zedœddd„ZdS )rî  rô  ÚaudiorÞ   rõ  rö  rH   r–   c             	   C  rü  ©z‰Send audio to a Live session over its primary WebSocket.

        WebRTC and SIP sessions send audio over their media transport.
        zsession.input_audio.append)rÔ   r  rõ  Nrú  ©rM   r  rõ  rN   rN   rO   r  c  s   þÿz$LiveSessionInputAudioResource.appendc                C  r÷  ©z‹Mute audio input to the Live model without closing the session.

        The server acknowledges with `session.input_audio.muted`.
        zsession.input_audio.muterù  Nrú  rû  rN   rN   rO   Úmuteo  ó   ÿz"LiveSessionInputAudioResource.mutec                C  r÷  ©z�Resume audio input to a Live model after muting it.

        The server acknowledges with `session.input_audio.unmuted`.
        zsession.input_audio.unmuterù  Nrú  rû  rN   rN   rO   Úunmutex  r  z$LiveSessionInputAudioResource.unmuteN©r  rÞ   rõ  rö  rH   r–   r  ©r�   rŽ   r�   r   r  r  r  rN   rN   rN   rO   rî  b  ó    	rî  c                   @  r  )rð  rô  r	  rÞ   r
  r  rõ  rö  rH   r–   c             
   C  r  ©z“
        Append instructions to the Live conversation while it is running, optionally associating them with an existing client delegation.
        zsession.instructions.appendr  Nrú  r  rN   rN   rO   r  ƒ  r  z&LiveSessionInstructionsResource.appendNr  r  rN   rN   rN   rO   rð  ‚  r  rð  c                   @  r  )rò  rô  r	  rÞ   r
  r  rõ  rö  rH   r–   c             
   C  r  ©z
        Provide silent reasoning or progress context to the Live model, optionally for an existing client delegation.
        zsession.thinking.appendr  Nrú  r  rN   rN   rO   r  —  r  z"LiveSessionThinkingResource.appendNr  r  rN   rN   rN   rO   rò  –  r  rò  c                   @  ó*   e Zd Zeddd„ƒZedœdd	d
„ZdS )rÊ  rH   ÚLiveResponseItemResourcec                 C  rI   rJ   )r$  r­   rL   rN   rN   rO   Úitem«  rQ   zLiveResponseResource.itemrô  rõ  rö  r–   c                C  r÷  ©u¼   
        Request a response from the Live sessionâ€™s Responses backend, or continue a
        delegated response waiting for tool results.

        Requires Responses delegation.
        zresponse.createrù  Nrú  rû  rN   rN   rO   rv   ¯  s   ÿzLiveResponseResource.createN)rH   r$  r  ©r�   rŽ   r�   r&   r%  r   rv   rN   rN   rN   rO   rÊ  ª  ó    rÊ  c                   @  ó   e Zd Zedœddd	„Zd
S )r$  rô  r%  r@   rõ  rö  rH   r–   c             	   C  rü  ©uš   Add an input item to the Live sessionâ€™s Responses backend.

        Requires Responses delegation; use `response.create` to request a response.
        zresponse.item.create)rÔ   r%  rõ  Nrú  ©rM   r%  rõ  rN   rN   rO   rv   ¼  r  zLiveResponseItemResource.createN©r%  r@   rõ  rö  rH   r–   ©r�   rŽ   r�   r   rv   rN   rN   rN   rO   r$  »  r  r$  c                   @  rã  )	ÚBaseAsyncLiveConnectionResourcer±   r§   rH   r–   c                 C  rå  rJ   ræ  rç  rN   rN   rO   r›   É  rè  z(BaseAsyncLiveConnectionResource.__init__N)r±   r§   rH   r–   ré  rN   rN   rN   rO   r.  È  rê  r.  c                   @  rë  )#r©   rH   Ú"AsyncLiveSessionCommentaryResourcec                 C  rI   rJ   )r/  r­   rL   rN   rN   rO   rí  Î  rQ   z#AsyncLiveSessionResource.commentaryÚ"AsyncLiveSessionInputAudioResourcec                 C  rI   rJ   )r0  r­   rL   rN   rN   rO   rï  Ò  rQ   z$AsyncLiveSessionResource.input_audioÚ$AsyncLiveSessionInstructionsResourcec                 C  rI   rJ   )r1  r­   rL   rN   rN   rO   rñ  Ö  rQ   z%AsyncLiveSessionResource.instructionsÚ AsyncLiveSessionThinkingResourcec                 C  rI   rJ   )r2  r­   rL   rN   rN   rO   ró  Ú  rQ   z!AsyncLiveSessionResource.thinkingrô  rõ  rö  r–   c                Ã  ó(   �| j  tttd|dœƒƒ¡I dH  dS rø  rú  rû  rN   rN   rO   r  Þ  ó   €ÿzAsyncLiveSessionResource.closerb   r?   c             	   Ã  ó*   �| j  tttd||dœƒƒ¡I dH  dS rý  rú  rÿ  rN   rN   rO   r   ç  ó   €ÿÿzAsyncLiveSessionResource.updater<   c             	   Ã  r5  r  rú  rÿ  rN   rN   rO   r  ò  s   €ÿzAsyncLiveSessionResource.startN)rH   r/  )rH   r0  )rH   r1  )rH   r2  r  r  r  r  rN   rN   rN   rO   r©   Í  s    	r©   c                   @  r  )r/  rô  r	  rÞ   r
  r  rõ  rö  rH   r–   c             
   Ã  ó,   �| j  tttd|||dœƒƒ¡I dH  dS r  rú  r  rN   rN   rO   r  ý  ó   €üÿþÿz)AsyncLiveSessionCommentaryResource.appendNr  r  rN   rN   rN   rO   r/  ü  ó    ÿr/  c                   @  r  )r0  rô  r  rÞ   rõ  rö  rH   r–   c             	   Ã  r5  r  rú  r  rN   rN   rO   r    s   €þÿz)AsyncLiveSessionInputAudioResource.appendc                Ã  r3  r  rú  rû  rN   rN   rO   r    r4  z'AsyncLiveSessionInputAudioResource.mutec                Ã  r3  r  rú  rû  rN   rN   rO   r  (  r4  z)AsyncLiveSessionInputAudioResource.unmuteNr  r  r  rN   rN   rN   rO   r0    r   r0  c                   @  r  )r1  rô  r	  rÞ   r
  r  rõ  rö  rH   r–   c             
   Ã  r7  r!  rú  r  rN   rN   rO   r  3  r8  z+AsyncLiveSessionInstructionsResource.appendNr  r  rN   rN   rN   rO   r1  2  r9  r1  c                   @  r  )r2  rô  r	  rÞ   r
  r  rõ  rö  rH   r–   c             
   Ã  r7  r"  rú  r  rN   rN   rO   r  I  r8  z'AsyncLiveSessionThinkingResource.appendNr  r  rN   rN   rN   rO   r2  H  r9  r2  c                   @  r#  )rª   rH   ÚAsyncLiveResponseItemResourcec                 C  rI   rJ   )r:  r­   rL   rN   rN   rO   r%  _  rQ   zAsyncLiveResponseResource.itemrô  rõ  rö  r–   c                Ã  r3  r&  rú  rû  rN   rN   rO   rv   c  s   €ÿz AsyncLiveResponseResource.createN)rH   r:  r  r'  rN   rN   rN   rO   rª   ^  r(  rª   c                   @  r)  )r:  rô  r%  r@   rõ  rö  rH   r–   c             	   Ã  r5  r*  rú  r+  rN   rN   rO   rv   p  r6  z$AsyncLiveResponseItemResource.createNr,  r-  rN   rN   rN   rO   r:  o  r  r:  )ˆÚ
__future__r   rê   rÏ  r(  ÚloggingÚtypesr   Útypingr   r   r   r   r   r	   r
   r   Útyping_extensionsr   r¶  Úpydanticr   r  r   rR   r   r   Ú_typesr   r   r   r   r   r   r   Ú_utilsr   r   r   r   rS   r   r   r    r!   r"   r#   rP   r$   r%   Ú_compatr&   Ú_modelsr'   r(   Ú	_resourcer)   r*   Ú	_responser+   r,   Ú
types.liver-   Ú_exceptionsr.   r/   rÀ   r0   Ú_base_clientr1   r2   Ú_event_handlerr3   Útypes.live.error_eventr4   Útypes.live.client_eventr5   Útypes.live.server_eventr6   Útypes.websocket_reconnectionr7   r8   r9   Útypes.live.client_event_paramr:   Útypes.live.live_create_responser;   Útypes.live.session_config_paramr<   Ú"types.websocket_connection_optionsr=   Ú%types.live.media_session_config_paramr>   Ú&types.live.session_update_config_paramr?   Ú)types.responses.response_input_item_paramr@   rá  rA   rË  Úwebsockets.asyncio.clientr¬   rK   rB   rC   Ú__all__Ú	getLoggerr�   rF   re  rD   rE   rT   r‘   rY   r’   r§   r“   rÈ  r„   rä  rÉ  rì  rî  rð  rò  rÊ  r$  r.  r©   r/  r0  r1  r2  rª   r:  rN   rN   rN   rO   Ú<module>   s”   ($ mm  0 B  $ A- / 