o
    ¨Ýjgý  ã                   @  s‚  U d dl m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-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9m:Z: ddl;m<Z< ddl=m>Z>m?Z? ddl@mAZAmBZB ddlCmDZD ddlEmFZFmGZG ddlHmIZI ddlJmKZKmLZL ddlMmNZN ddlOmPZP ddlQmRZR ddlSmTZTmUZU ddlVmWZW ddlXmYZY dd lZm[Z[ dd!l\m]Z]m^Z^ dd"l_m`Z` dd#lambZb dd$lcmdZd e�r*d d%lemfZg d d%lhmfZi dd&ljmkZkmlZl d'd(gZme neo¡Zpd)eqd*< G d+d'„ d'e6ƒZrG d,d(„ d(e7ƒZsG d-d.„ d.ƒZtG d/d0„ d0ƒZuG d1d2„ d2ƒZvG d3d4„ d4ƒZwG d5d6„ d6eLƒZxG d7d8„ d8ƒZyG d9d:„ d:eKƒZzG d;d<„ d<ƒZ{G d=d>„ d>ƒZ|G d?d@„ d@e|ƒZ}G dAdB„ dBe|ƒZ~G dCdD„ dDe|ƒZG dEdF„ dFe|ƒZ€G dGdH„ dHe|ƒZ�G dIdJ„ dJe|ƒZ‚G dKdL„ dLe|ƒZƒG dMdN„ dNe|ƒZ„G dOdP„ dPe|ƒZ…G dQdR„ dRe|ƒZ†G dSdT„ dTe|ƒZ‡G dUdV„ dVƒZˆG dWdX„ dXeˆƒZ‰G dYdZ„ dZeˆƒZŠG d[d\„ d\eˆƒZ‹G d]d^„ d^eˆƒZŒG d_d`„ d`eˆƒZ�G dadb„ dbeˆƒZŽG dcdd„ ddeˆƒZ�G dedf„ dfeˆƒZ�G dgdh„ dheˆƒZ‘G didj„ djeˆƒZ’G dkdl„ dleˆƒZ“dS )mé    )Ú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)Ú!DEFAULT_LIVE_SEND_QUEUE_MAX_BYTES)Úlive_create_paramsÚ decision_item_create_event_param)ÚOpenAIErrorÚWebSocketConnectionClosedError)Ú	SendQueue)Ú_merge_mappingsÚmake_request_options)ÚEventHandlerRegistry)ÚWebSocketConnectionBaseÚAsyncWebSocketConnectionBase)Ú
ErrorEvent)ÚClientEvent)ÚServerEvent)ÚReconnectingEventÚReconnectingOverrides)ÚClientEventParam)ÚLiveCreateResponse)ÚSessionConfigParam)ÚWebSocketConnectionOptionsÚSyncWebSocketConnectionOptions)ÚMediaSessionConfigParam)ÚSessionUpdateConfigParam)ÚResponseInputItemParam)ÚClientConnection)ÚOpenAIÚAsyncOpenAIÚLiveÚ	AsyncLivezlogging.LoggerÚlogc                   @  ó„   e Zd Zed4dd„ƒZed5dd„ƒZed6d	d
„ƒZed7dd„ƒZed8dd„ƒZddde	dœd9d d!„Z
i i i dd"d#d$efd:d2d3„ZdS );rH   Úreturnr$   c                 C  ó
   t | jƒS ©N)r$   Ú_client©Úself© rR   úU/var/www/html/chatgpt/venv/lib/python3.10/site-packages/openai/resources/live/live.pyÚsideband>   ó   
zLive.sidebandr   c                 C  rM   rN   )r   rO   rP   rR   rR   rS   ÚforksB   rU   z
Live.forksr   c                 C  rM   rN   )r   rO   rP   rR   rR   rS   ÚsessionsF   rU   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
        )rX   rP   rR   rR   rS   Úwith_raw_responseJ   ó   zLive.with_raw_responseÚLiveWithStreamingResponsec                 C  rY   ©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
        )r]   rP   rR   rR   rS   Úwith_streaming_responseT   ó   zLive.with_streaming_responseN©Úextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚsessionrB   Ú	transportúlive_create_params.Transportrb   úHeaders | Nonerc   úQuery | Nonerd   úBody | Nonere   ú(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©rf   rg   Úbearer_authT©rb   rc   rd   re   Úsecurity©ÚbodyÚoptionsZcast_to)Ú_postr   r.   ÚLiveCreateParamsr4   r>   ©rQ   rf   rg   rb   rc   rd   re   rR   rR   rS   Úcreate]   s"   þûûðzLive.createé   ç      à?ç       @r   r   Úwebsocket_connection_optionsrA   Ú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.
        )	Úclientrc   rb   r}   r~   r€   r‚   r„   r…   )r†   rO   ©	rQ   rc   rb   r}   r~   r€   r‚   r„   r…   rR   rR   rS   ÚconnectŽ   ó   ÷zLive.connect)rL   r$   )rL   r   )rL   r   )rL   rX   )rL   r]   ©rf   rB   rg   rh   rb   ri   rc   rj   rd   rk   re   rl   rL   r>   )rc   r   rb   r   r}   rA   r~   r   r€   r�   r‚   rƒ   r„   rƒ   r…   r�   rL   r†   ©Ú__name__Ú
__module__Ú__qualname__r&   rT   rV   rW   r[   r_   r   ry   r-   r‹   rR   rR   rR   rS   rH   =   ó2    	ö3÷c                   @  rK   );rI   rL   r%   c                 C  rM   rN   )r%   rO   rP   rR   rR   rS   rT   «   rU   zAsyncLive.sidebandr   c                 C  rM   rN   )r   rO   rP   rR   rR   rS   rV   ¯   rU   zAsyncLive.forksr   c                 C  rM   rN   )r   rO   rP   rR   rR   rS   rW   ³   rU   zAsyncLive.sessionsÚAsyncLiveWithRawResponsec                 C  rY   rZ   )r“   rP   rR   rR   rS   r[   ·   r\   zAsyncLive.with_raw_responseÚAsyncLiveWithStreamingResponsec                 C  rY   r^   )r”   rP   rR   rR   rS   r_   Á   r`   z!AsyncLive.with_streaming_responseNra   rf   rB   rg   rh   rb   ri   rc   rj   rd   rk   re   rl   r>   c             
   Ã  s@   �| j dt||dœtjƒI dH t||||ddid�td�I dH S )rm   rn   ro   Nrp   Trq   rs   )rv   r   r.   rw   r4   r>   rx   rR   rR   rS   ry   Ê   s$   €þûûðzAsyncLive.createrz   r{   r|   r   r   r}   r@   r~   r   r€   r�   r‚   rƒ   r„   r…   ÚAsyncLiveConnectionManagerc	           	      C  r‡   rˆ   )r•   rO   rŠ   rR   rR   rS   r‹   û   rŒ   zAsyncLive.connect)rL   r%   )rL   r   )rL   r   )rL   r“   )rL   r”   r�   )rc   r   rb   r   r}   r@   r~   r   r€   r�   r‚   rƒ   r„   rƒ   r…   r�   rL   r•   rŽ   rR   rR   rR   rS   rI   ª   r’   c                   @  ó$   e Zd Zddd„Zeddd	„ƒZd
S )rX   ÚliverH   rL   ÚNonec                 C  ó   || _ t |j¡| _d S rN   )Ú_liver   Zto_raw_response_wrapperry   ©rQ   r—   rR   rR   rS   Ú__init__  ó   
ÿzLiveWithRawResponse.__init__r    c                 C  ó   t | jjƒS rN   )r    rš   rW   rP   rR   rR   rS   rW     ó   zLiveWithRawResponse.sessionsN©r—   rH   rL   r˜   )rL   r    ©r�   r�   r‘   rœ   r&   rW   rR   rR   rR   rS   rX     ó    
rX   c                   @  r–   )r“   r—   rI   rL   r˜   c                 C  r™   rN   )rš   r   Zasync_to_raw_response_wrapperry   r›   rR   rR   rS   rœ   %  r�   z!AsyncLiveWithRawResponse.__init__r!   c                 C  rž   rN   )r!   rš   rW   rP   rR   rR   rS   rW   ,  rŸ   z!AsyncLiveWithRawResponse.sessionsN©r—   rI   rL   r˜   )rL   r!   r¡   rR   rR   rR   rS   r“   $  r¢   r“   c                   @  r–   )r]   r—   rH   rL   r˜   c                 C  ó   || _ t|jƒ| _d S rN   )rš   r+   ry   r›   rR   rR   rS   rœ   2  ó   
ÿz"LiveWithStreamingResponse.__init__r"   c                 C  rž   rN   )r"   rš   rW   rP   rR   rR   rS   rW   9  rŸ   z"LiveWithStreamingResponse.sessionsNr    )rL   r"   r¡   rR   rR   rR   rS   r]   1  r¢   r]   c                   @  r–   )r”   r—   rI   rL   r˜   c                 C  r¤   rN   )rš   r,   ry   r›   rR   rR   rS   rœ   ?  r¥   z'AsyncLiveWithStreamingResponse.__init__r#   c                 C  rž   rN   )r#   rš   rW   rP   rR   rR   rS   rW   F  rŸ   z'AsyncLiveWithStreamingResponse.sessionsNr£   )rL   r#   r¡   rR   rR   rR   rS   r”   >  r¢   r”   c                	      óº   e Zd ZU dZded< ded< ded< ded	< d
d
dddi i d
dœdB‡ fd!d"„ZdCd$d%„ZdDd'd(„ZdEd*d+„ZdFd.d/„Z	dGd2d3„Z
	
dHdId9d:„ZdJd<d=„Z	
dHdId>d?„ZdKd@dA„Z‡  ZS )LÚAsyncLiveConnectionú6Represents a live WebSocket connection to the Live APIÚAsyncLiveSessionResourcerf   ÚAsyncLiveDecisionResourceÚdecisionÚAsyncLiveResponseResourceÚresponseÚAsyncWebSocketConnectionÚ_connectionNrz   r{   r|   ©Úmake_wsr~   r€   r‚   r„   rc   rb   Ú
send_queueÚ
connectionr±   úFCallable[[Query, Headers], Awaitable[AsyncWebSocketConnection]] | Noner~   r   r€   r�   r‚   rƒ   r„   rc   r   rb   r   r²   úSendQueue | NonerL   r˜   c          
        ó`   t ƒ j|||||||||	d ur|	nttd�td�
 tdd�| _t| ƒ| _t	| ƒ| _
t| ƒ| _d S )N©Z	max_bytes©	r±   r~   r€   r‚   r„   rc   rb   r²   ÚloggerF©Zuse_lock)Úsuperrœ   r2   r-   rJ   r5   Ú_event_handler_registryr©   rf   rª   r«   r¬   r­   ©
rQ   r³   r±   r~   r€   r‚   r„   rc   rb   r²   ©Ú	__class__rR   rS   rœ   T  ó    ö

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)Zunsent_messages©Zwebsockets.exceptionsrÃ   rÄ   ÚrecvZ
_reconnectÚ_send_queueZdrainr1   ©rQ   rÃ   rÄ   ÚexcZunsentrR   rR   rS   Ú	__aiter__s  s,   €
þýù€ÿûzAsyncLiveConnection.__aiter__r:   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ÚstrÚ_reconnect_attempt©rQ   ÚeventÚ
event_typerR   rR   rS   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Æ   rJ   ÚdebugÚlenrØ   ÚjsonÚloadsÚ
ValueErrorÚRecursionErrorrÒ   rÔ   r   rÕ   r×   )rQ   ÚmessageÚ
event_datarÛ   rR   rR   rS   rÑ   ›  s   €ÿzAsyncLiveConnection.recv_bytesrÚ   úClientEvent | ClientEventParamc                 Ã  s\   �t |tƒr|jddd�n
t t|tƒI d H ¡}| jr#| j 	|¡ d S | j
 |¡I d H  d S ©NT©Zuse_api_namesZexclude_unset)rÒ   r   Úto_jsonrâ   Údumpsr   r=   Ú_is_reconnectingrÇ   Úenqueuer¯   Úsend©rQ   rÚ   ÚdatarR   rR   rS   rï   °  s   €ÿýzAsyncLiveConnection.sendrñ   ú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   r:   r(   râ   rã   r   ©rQ   rñ   rR   rR   rS   rÐ   »  ó   zAsyncLiveConnection.parse_eventrÛ   r×   Ú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]rL   c                   ó   ˆj  ˆ | ¡ | S rN   ©r¼   Úadd©rþ   ©rÛ   rQ   rR   rS   Ú	decoratorÙ  ó   z)AsyncLiveConnection.on.<locals>.decorator©rþ   rÿ   rL   rÿ   r  ©rQ   rÛ   rú   r  rR   r  rS   ÚonÃ  ó
   zAsyncLiveConnection.onrÿ   c                 C  ó   | j  ||¡ | S ©z-Remove a previously registered event handler.©r¼   Úremove©rQ   rÛ   rú   rR   rR   rS   Úoffß  ó   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ÿ   rL   c                   ó   ˆj jˆ | dd� | S ©NTr  r  r  r  rR   rS   r  ï  ó   z+AsyncLiveConnection.once.<locals>.decoratorr  r  r  rR   r  rS   r  ä  ó
   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: )ÚasynciorÍ   r¼   Úget_handlersrÒ   r8   r0   Úiscoroutine)rQ   r  rÚ   rÛ   ÚspecificÚgenericrú   ÚresultrR   rR   rS   Údispatch_eventsõ  s*   €	


€

€ýòz#AsyncLiveConnection.dispatch_events)r³   r®   r±   r´   r~   r   r€   r�   r‚   rƒ   r„   rƒ   rc   r   rb   r   r²   rµ   rL   r˜   )rL   rÁ   ©rL   r:   ©rL   rÜ   ©rÚ   rè   rL   r˜   ©rñ   rò   rL   r:   rN   )rÛ   r×   rú   rû   rL   rü   )rÛ   r×   rú   rÿ   rL   r§   ©rL   r˜   )r�   r�   r‘   Ú__doc__Ú__annotations__rœ   rÊ   rÆ   rÑ   rï   rÐ   r	  r  r  r!  Ú__classcell__rR   rR   r¾   rS   r§   K  s4   
 õ




	ÿ
ÿr§   c                   @  ó„   e Zd ZdZddddedœd<dd„Zd=dd„Z	d>d?d$d%„Zd@d'd(„Z	d>d?d)d*„Z	dAd,d-„Z
e
ZdBd/d0„ZdCd2d3„ZdDd:d;„ZdS )Er•   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()
    ```
    Nrz   r{   r|   ©r~   r€   r‚   r„   r…   r‰   rG   rc   r   rb   r   r}   r@   r~   r   r€   r�   r‚   rƒ   r„   r…   rL   r˜   c       	   
      C  óR   || _ d | _|| _|| _|| _|| _|| _|| _|| _t	|	d�| _
tdd�| _d S )Nr·   Frº   )Ú#_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_delayr2   Ú'_AsyncLiveConnectionManager__send_queuer5   Ú3_AsyncLiveConnectionManager__event_handler_registry©
rQ   r‰   rc   rb   r}   r~   r€   r‚   r„   r…   rR   rR   rS   rœ   (  ó   z#AsyncLiveConnectionManager.__init__rÚ   rè   c                 C  ó8   t |tƒr|j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=   r6  rî   rð   rR   rR   rS   rï   A  ó
   ÿýzAsyncLiveConnectionManager.sendrÛ   r×   rú   rû   úUUnion[AsyncLiveConnectionManager, Callable[[Callable[..., Any]], Callable[..., Any]]]c                   rý   )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ÿ   rL   c                   r   rN   ©r7  r  r  r  rR   rS   r  Z  r  z0AsyncLiveConnectionManager.on.<locals>.decoratorr  r>  r  rR   r  rS   r	  N  ó
   zAsyncLiveConnectionManager.onrÿ   c                 C  r  r  )r7  r  r  rR   rR   rS   r  `  r  zAsyncLiveConnectionManager.offc                   r  )
úGRegister a one-time event handler before the connection is established.NTr  rþ   rÿ   rL   c                   r  r  r>  r  r  rR   rS   r  m  r  z2AsyncLiveConnectionManager.once.<locals>.decoratorr  r>  r  rR   r  rS   r  e  ó
   zAsyncLiveConnectionManager.oncer§   c                 Ã  s¶   �|   | j| j¡I dH }z1t|| jdur| j nd| j| j| j| j| j| j| jd�	| _	| j
 | j	j¡ | j	 ¡ I dH  W | j	S  tyZ   d| _	z	| ¡ I dH  W ‚  tyY   Y ‚ w w )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_wsr/  r0  r§   r2  r3  r4  r5  r6  r.  r7  Ú
merge_intor¼   Ú_flush_send_queueÚBaseExceptionÚclose©rQ   ÚwsrR   rR   rS   Ú
__aenter__s  s6   €÷
÷ýýüz%AsyncLiveConnectionManager.__aenter__r®   c           
   
   Ã  s°  �zddl m} W n ty } ztdƒ|‚d }~ww |  ¡ }zt| jdƒ}W n ty4   | jj}Y nw |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¡ | j ¡ }	|	  dd ¡ |	 
d¡d u rÁ|	  dd ¡ |t|ƒfd t!t| "¡ ƒi ƒdœ|	¤ŽI d H S )Nr   )Ú_WebSocketConnectú9You need to install `openai[realtime]` to use this methodÚ_websocket_query_params©ÚparamsrH  Úwss©ÚhttpÚhttps©ÚschemerÕ   rp   T©ÚmethodÚurlÚheadersrr   c                 S  ó,   i | ]}|  ¡ D ]\}}| ¡ ||f“qqS rR   ©ÚitemsÚlower©Ú.0Z
header_setÚkeyrõ   rR   rR   rS   Ú
<dictcomp>½  ó    øùÿz:AsyncLiveConnectionManager._connect_ws.<locals>.<dictcomp>úConnecting to WebSocket APIú,Custom WebSocket connection options providedÚmax_sizeÚcompression©Zuser_agent_headerZadditional_headers)#Úlib._websocketrJ  ÚImportErrorr0   Ú_prepare_urlrÖ   r-  ÚAttributeErrorÚ _websocket_query_params_fallbackÚ	copy_withrÕ   rT  Ú_prepare_optionsr'   Ú	constructr×   rÔ   rW  Úcopy_merge_paramsÚqsÚ	stringifyr   r   rN  Úauth_headersÚdefault_headersr   rX  rJ   rà   r1  ÚcopyÚ
setdefaultr3   Úvalues©
rQ   rc   rb   r‹   rÉ   rW  Zquery_paramsru   rX  Zwebsocket_optionsrR   rR   rS   rB  ž  sl   €
€ÿÿþÿü
ÿÿüþ



ÿýüz&AsyncLiveConnectionManager._connect_wsú
httpx2.URLc                 C  óz   | 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¡d | | }|j|d�S ©	NrQ  rH  rO  rS  ó   ?ó   /s   /live/sessions)Úraw_path)
r-  Úwebsocket_base_urlÚhttpx2ÚURLÚ	_base_urlrT  rl  r}  Ú	partitionÚrstrip©rQ   Úbase_urlrT  Z	ws_schemeÚpathÚ	separatorÚqueryZmerge_raw_pathrR   rR   rS   ri  ×  ó   
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 rN   )r.  rF  ©rQ   rŠ  rÉ   r�  rR   rR   rS   Ú	__aexit__ã  s   €
ÿz$AsyncLiveConnectionManager.__aexit__)r‰   rG   rc   r   rb   r   r}   r@   r~   r   r€   r�   r‚   rƒ   r„   rƒ   r…   r�   rL   r˜   r$  rN   )rÛ   r×   rú   rû   rL   r=  )rÛ   r×   rú   rÿ   rL   r•   )rL   r§   )rc   r   rb   r   rL   r®   ©rL   rx  ©rŠ  r‹  rÉ   rŒ  r�  rŽ  rL   r˜   )r�   r�   r‘   r'  r-   rœ   rï   r	  r  r  rI  ÚenterrB  ri  r�  rR   rR   rR   rS   r•     s&    õ
ÿ
ÿ
)

9r•   c                	      r¦   )LÚLiveConnectionr¨   ÚLiveSessionResourcerf   ÚLiveDecisionResourcer«   ÚLiveResponseResourcer­   ÚWebSocketConnectionr¯   Nrz   r{   r|   r°   r³   r±   ú6Callable[[Query, Headers], WebSocketConnection] | Noner~   r   r€   r�   r‚   rƒ   r„   rc   r   rb   r   r²   rµ   rL   r˜   c          
        r¶   )Nr·   r¸   Trº   )r»   rœ   r2   r-   rJ   r5   r¼   r•  rf   r–  r«   r—  r­   r½   r¾   rR   rS   rœ   ó  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È   rR   rR   rS   Ú__iter__  s,   €

þýù€ÿûzLiveConnection.__iter__r:   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Ù   rR   rR   rS   rÆ   (  s   ÿ
ýzLiveConnection.recvrÜ   c              	   C  s”   ddl m} || jƒ}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 )	rÝ   r   )Ú_recv_bytesrß   rÌ   rÍ   NrÎ   r   )rg  rœ  r¯   rJ   rà   rá   rØ   râ   rã   rä   rå   rÒ   rÔ   r   rÕ   r×   )rQ   rœ  ræ   rç   rÛ   rR   rR   rS   rÑ   :  s   
ÿzLiveConnection.recv_bytesrÚ   rè   c                 C  sN   t |tƒr|jddd�nt t|tƒ¡}| jr| j 	|¡ d S | j
 |¡ d S ré   )rÒ   r   rë   râ   rì   r   r=   rí   rÇ   rî   r¯   rï   rð   rR   rR   rS   rï   Q  s   ÿýzLiveConnection.sendrñ   rò   c                 C  ró   rô   r÷   rø   rR   rR   rS   rÐ   \  rù   zLiveConnection.parse_eventrÛ   r×   rú   rû   úIUnion[LiveConnection, Callable[[Callable[..., Any]], Callable[..., Any]]]c                   rý   )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ÿ   rL   c                   r   rN   r  r  r  rR   rS   r  z  r  z$LiveConnection.on.<locals>.decoratorr  r  r  rR   r  rS   r	  d  r
  zLiveConnection.onrÿ   c                 C  r  r  r  r  rR   rR   rS   r  €  r  zLiveConnection.offc                   r  )
r  NTr  rþ   rÿ   rL   c                   r  r  r  r  r  rR   rS   r  �  r  z&LiveConnection.once.<locals>.decoratorr  r  r  rR   r  rS   r  …  r  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Î   r  N)rÍ   r¼   r  rÒ   r8   r0   )rQ   rÚ   rÛ   r  r  rú   rR   rR   rS   r!  –  s   	


ÿôzLiveConnection.dispatch_events)r³   r˜  r±   r™  r~   r   r€   r�   r‚   rƒ   r„   rƒ   rc   r   rb   r   r²   rµ   rL   r˜   )rL   rš  r"  r#  r$  r%  rN   )rÛ   r×   rú   rû   rL   r�  )rÛ   r×   rú   rÿ   rL   r”  r&  )r�   r�   r‘   r'  r(  rœ   r›  rÆ   rÑ   rï   rÐ   r	  r  r  r!  r)  rR   rR   r¾   rS   r”  ê  s4   
 õ




	ÿ
ÿr”  c                   @  r*  )Er†   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()
    ```
    Nrz   r{   r|   r+  r‰   rF   rc   r   rb   r   r}   rA   r~   r   r€   r�   r‚   rƒ   r„   r…   rL   r˜   c       	   
      C  r,  )Nr·   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_delayr2   Ú"_LiveConnectionManager__send_queuer5   Ú._LiveConnectionManager__event_handler_registryr8  rR   rR   rS   rœ   Â  r9  zLiveConnectionManager.__init__rÚ   rè   c                 C  r:  r;  )	rÒ   r   rë   râ   rì   r   r=   r§  rî   rð   rR   rR   rS   rï   Û  r<  zLiveConnectionManager.sendrÛ   r×   rú   rû   úPUnion[LiveConnectionManager, Callable[[Callable[..., Any]], Callable[..., Any]]]c                   rý   )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ÿ   rL   c                   r   rN   ©r¨  r  r  r  rR   rS   r  ô  r  z+LiveConnectionManager.on.<locals>.decoratorr  rª  r  rR   r  rS   r	  è  r?  zLiveConnectionManager.onrÿ   c                 C  r  r  )r¨  r  r  rR   rR   rS   r  ú  r  zLiveConnectionManager.offc                   r  )
r@  NTr  rþ   rÿ   rL   c                   r  r  rª  r  r  rR   rS   r    r  z-LiveConnectionManager.once.<locals>.decoratorr  rª  r  rR   r  rS   r  ÿ  rA  zLiveConnectionManager.oncer”  c                 C  s¢   |   | j| j¡}z.t|| jdur| j nd| j| j| j| j| j| j| jd�	| _	| j
 | j	j¡ | j	 ¡  W | j	S  tyP   d| _	z| ¡  W ‚  tyO   Y ‚ w w )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°   )rB  r   r¡  r”  r£  r¤  r¥  r¦  r§  rŸ  r¨  rC  r¼   rD  rE  rF  rG  rR   rR   rS   Ú	__enter__  s4   ÷
÷
ýýüzLiveConnectionManager.__enter__r˜  c           
   
   C  s¢  zddl m} W n ty } ztdƒ|‚d }~ww |  ¡ }zt| jdƒ}W n ty3   | jj}Y nw |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¡ | j ¡ }	|	  dd ¡ |	 
d¡d u r½|	  dd ¡ |t|ƒfd t!t| "¡ ƒi ƒdœ|	¤ŽS )Nr   )r‹   rK  rL  rM  rH  rO  rP  rS  rÕ   rp   TrU  c                 S  rY  rR   rZ  r]  rR   rR   rS   r`  W  ra  z5LiveConnectionManager._connect_ws.<locals>.<dictcomp>rb  rc  rd  re  rf  )#Úwebsockets.sync.clientr‹   rh  r0   ri  rÖ   rž  rj  rk  rl  rÕ   rT  rm  r'   rn  r×   rÔ   rW  ro  rp  rq  r   r   rN  rr  rs  r   rX  rJ   rà   r¢  rt  ru  r3   rv  rw  rR   rR   rS   rB  8  sj   
€ÿÿþÿüÿÿüþ



ÿýüz!LiveConnectionManager._connect_wsrx  c                 C  ry  rz  )
rž  r~  r  r€  r�  rT  rl  r}  r‚  rƒ  r„  rR   rR   rS   ri  q  r‰  z"LiveConnectionManager._prepare_urlrŠ  r‹  rÉ   rŒ  r�  rŽ  c                 C  s   | j d ur| j  ¡  d S d S rN   )rŸ  rF  r�  rR   rR   rS   Ú__exit__}  s   
ÿzLiveConnectionManager.__exit__)r‰   rF   rc   r   rb   r   r}   rA   r~   r   r€   r�   r‚   rƒ   r„   rƒ   r…   r�   rL   r˜   r$  rN   )rÛ   r×   rú   rû   rL   r©  )rÛ   r×   rú   rÿ   rL   r†   )rL   r”  )rc   r   rb   r   rL   r˜  r‘  r’  )r�   r�   r‘   r'  r-   rœ   rï   r	  r  r  r«  r“  rB  ri  r­  rR   rR   rR   rS   r†   ¯  s&    õ
ÿ
ÿ
)

9r†   c                   @  ó   e Zd Zddd„ZdS )	ÚBaseLiveConnectionResourcer³   r”  rL   r˜   c                 C  ó
   || _ d S rN   ©r¯   ©rQ   r³   rR   rR   rS   rœ   …  ó   
z#BaseLiveConnectionResource.__init__N)r³   r”  rL   r˜   ©r�   r�   r‘   rœ   rR   rR   rR   rS   r¯  „  ó    r¯  c                   @  ó‚   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„ƒZe	dœd$dd„Z
e	dœd%dd„Ze	dœd&dd„ZdS )'r•  rL   ÚLiveSessionCommentaryResourcec                 C  rM   rN   )r·  r¯   rP   rR   rR   rS   Ú
commentaryŠ  rU   zLiveSessionResource.commentaryÚLiveSessionInputAudioResourcec                 C  rM   rN   )r¹  r¯   rP   rR   rR   rS   Úinput_audioŽ  rU   zLiveSessionResource.input_audioÚLiveSessionInstructionsResourcec                 C  rM   rN   )r»  r¯   rP   rR   rR   rS   Úinstructions’  rU   z LiveSessionResource.instructionsÚLiveSessionOutputAudioResourcec                 C  rM   rN   )r½  r¯   rP   rR   rR   rS   Úoutput_audio–  rU   z LiveSessionResource.output_audioÚLiveSessionThinkingResourcec                 C  rM   rN   )r¿  r¯   rP   rR   rR   rS   Úthinkingš  rU   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   ©rQ   rÂ  rR   rR   rS   rF  ž  s    zLiveSessionResource.closerf   rC   c             	   C  ó"   | j  tttd||dœƒƒ¡ dS ©z¬
        Update the delegation settings or transcript triggers of an active Live session.

        The server acknowledges accepted changes with `session.updated`.
        zsession.update©rÍ   rf   rÂ  NrÇ  ©rQ   rf   rÂ  rR   rR   rS   Úupdate¥  s
   ÿÿ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Ì  rR   rR   rS   Ústart±  s   ÿzLiveSessionResource.startN)rL   r·  )rL   r¹  )rL   r»  )rL   r½  )rL   r¿  ©rÂ  rÃ  rL   r˜   ©rf   rC   rÂ  rÃ  rL   r˜   ©rf   r?   rÂ  rÃ  rL   r˜   ©r�   r�   r‘   r&   r¸  rº  r¼  r¾  rÀ  r   rF  rÍ  rÏ  rR   rR   rR   rS   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Ã  rL   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.

        Rejected while an audio fixture is active.
        zsession.commentary.append©rÍ   rÕ  rÖ  rÂ  NrÇ  ©rQ   rÕ  rÖ  rÂ  rR   rR   rS   Úappend¼  ó   üÿþÿz$LiveSessionCommentaryResource.appendN©rÕ  r×   rÖ  r×  rÂ  rÃ  rL   r˜   ©r�   r�   r‘   r   rÜ  rR   rR   rR   rS   r·  »  ó    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Ã  rL   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Ç  ©rQ   râ  rÂ  rR   rR   rS   rÜ  Ó  ó   þÿ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È  rR   rR   rS   Úmuteß  ó   ÿz"LiveSessionInputAudioResource.mutec                C  rÄ  ©zÉResume audio input to a Live model after muting it.

        The server acknowledges with `session.input_audio.unmuted`. An active audio fixture still pauses inference until playback finishes.
        zsession.input_audio.unmuterÆ  NrÇ  rÈ  rR   rR   rS   Úunmuteè  ré  z$LiveSessionInputAudioResource.unmuteN©râ  r×   rÂ  rÃ  rL   r˜   rÐ  ©r�   r�   r‘   r   rÜ  rè  rë  rR   rR   rR   rS   r¹  Ò  ó    	r¹  c                   @  rÔ  )r»  rÁ  rÕ  r×   rÖ  r×  rÂ  rÃ  rL   r˜   c             
   C  rØ  ©a¡  Append developer instructions to the Live conversation while it is running,
        optionally associating them with an existing client delegation.

        Rejected while an audio fixture is active. These instructions remain in conversation history through compaction and are included in future backend delegations. For external audio, describe content already delivered so the assistant does not repeat it.
        zsession.instructions.appendrÚ  NrÇ  rÛ  rR   rR   rS   rÜ  ó  s   üÿþÿz&LiveSessionInstructionsResource.appendNrÞ  rß  rR   rR   rR   rS   r»  ò  rà  r»  c                   @  ó   e Zd Zeddd„ƒZdS )r½  rL   Ú%LiveSessionOutputAudioFixtureResourcec                 C  rM   rN   )rñ  r¯   rP   rR   rR   rS   Úfixture	  rU   z&LiveSessionOutputAudioResource.fixtureN)rL   rñ  ©r�   r�   r‘   r&   rò  rR   rR   rR   rS   r½    ó    r½  c                   @  rÔ  )r¿  rÁ  rÕ  r×   rÖ  r×  rÂ  rÃ  rL   r˜   c             
   C  rØ  ©z»
        Provide silent reasoning or progress context to the Live model, optionally for
        an existing client delegation.

        Rejected while an audio fixture is active.
        zsession.thinking.appendrÚ  NrÇ  rÛ  rR   rR   rS   rÜ    rÝ  z"LiveSessionThinkingResource.appendNrÞ  rß  rR   rR   rR   rS   r¿    rà  r¿  c                   @  ó   e Zd Zedœddd	„Zd
S )rñ  rÁ  râ  r×   rÂ  rÃ  rL   r˜   c             	   C  rÉ  ©aL  Play one complete audio fixture through the session output.

        Send this event over the primary WebSocket or a server sideband. Audio must be raw mono PCM16 little-endian at 24 kHz, regardless of the session audio format, and at most 30 seconds. The entire payload is validated before model speech is interrupted and input is muted. Only one fixture can be active. fixture.playing acknowledges acceptance and fixture.played reports server mixer drain. These notifications are not exact transport-media boundaries. Input arriving during playback is dropped and not replayed.
        z!session.output_audio.fixture.playrä  NrÇ  rå  rR   rR   rS   Úplay&  ræ  z*LiveSessionOutputAudioFixtureResource.playNrì  ©r�   r�   r‘   r   rø  rR   rR   rR   rS   rñ  %  rà  rñ  c                   @  ó$   e Zd Zeddd„ƒZddd	„Zd
S )r–  rL   ÚLiveDecisionItemResourcec                 C  rM   rN   )rû  r¯   rP   rR   rR   rS   Úitem4  rU   zLiveDecisionResource.itemrÂ  r×   r˜   c                C  s   | j  d|dœ¡ dS ©z¹
        Evaluate the configured questions using the current conversation and Decision
        inputs.

        Reusing an event_id is rejected for the lifetime of the session.
        zdecision.createrÆ  N©r¯   rï   rÈ  rR   rR   rS   ry   8  s   zLiveDecisionResource.createN)rL   rû  ©rÂ  r×   rL   r˜   ©r�   r�   r‘   r&   rü  ry   rR   rR   rR   rS   r–  3  ó    r–  c                   @  ó,   e Zd Zedœddd	„Zedœddd„ZdS )rû  rÁ  Úitem_idr×   rÂ  rÃ  rL   r˜   c             	   C  rÉ  ©z{
        Delete an input item from future decisions without starting an evaluation or changing Live voice context.
        zdecision.item.delete)rÍ   r  rÂ  NrÇ  ©rQ   r  rÂ  rR   rR   rS   ÚdeleteC  s   þÿzLiveDecisionItemResource.deleterü  ú%decision_item_create_event_param.Itemc             	   C  rÉ  ©zz
        Append an input item for future decisions without starting an evaluation or changing Live voice context.
        zdecision.item.create©rÍ   rü  rÂ  NrÇ  ©rQ   rü  rÂ  rR   rR   rS   ry   N  s
   ÿÿzLiveDecisionItemResource.createN©r  r×   rÂ  rÃ  rL   r˜   ©rü  r  rÂ  rÃ  rL   r˜   ©r�   r�   r‘   r   r  ry   rR   rR   rR   rS   rû  B  s    rû  c                   @  ó*   e Zd Zeddd„ƒZedœdd	d
„ZdS )r—  rL   ÚLiveResponseItemResourcec                 C  rM   rN   )r  r¯   rP   rR   rR   rS   rü  Z  rU   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È  rR   rR   rS   ry   ^  s   ÿzLiveResponseResource.createN)rL   r  rÐ  ©r�   r�   r‘   r&   rü  r   ry   rR   rR   rR   rS   r—  Y  ó    r—  c                   @  rö  )r  rÁ  rü  rD   rÂ  rÃ  rL   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.creater	  NrÇ  r
  rR   rR   rS   ry   k  s
   ÿÿzLiveResponseItemResource.createN©rü  rD   rÂ  rÃ  rL   r˜   ©r�   r�   r‘   r   ry   rR   rR   rR   rS   r  j  rà  r  c                   @  r®  )	ÚBaseAsyncLiveConnectionResourcer³   r§   rL   r˜   c                 C  r°  rN   r±  r²  rR   rR   rS   rœ   x  r³  z(BaseAsyncLiveConnectionResource.__init__N)r³   r§   rL   r˜   r´  rR   rR   rR   rS   r  w  rµ  r  c                   @  r¶  )'r©   rL   Ú"AsyncLiveSessionCommentaryResourcec                 C  rM   rN   )r  r¯   rP   rR   rR   rS   r¸  }  rU   z#AsyncLiveSessionResource.commentaryÚ"AsyncLiveSessionInputAudioResourcec                 C  rM   rN   )r  r¯   rP   rR   rR   rS   rº  �  rU   z$AsyncLiveSessionResource.input_audioÚ$AsyncLiveSessionInstructionsResourcec                 C  rM   rN   )r  r¯   rP   rR   rR   rS   r¼  …  rU   z%AsyncLiveSessionResource.instructionsÚ#AsyncLiveSessionOutputAudioResourcec                 C  rM   rN   )r  r¯   rP   rR   rR   rS   r¾  ‰  rU   z%AsyncLiveSessionResource.output_audioÚ AsyncLiveSessionThinkingResourcec                 C  rM   rN   )r  r¯   rP   rR   rR   rS   rÀ  �  rU   z!AsyncLiveSessionResource.thinkingrÁ  rÂ  rÃ  r˜   c                Ã  ó(   �| j  tttd|dœƒƒ¡I dH  dS rÅ  rÇ  rÈ  rR   rR   rS   rF  ‘  ó   €ÿzAsyncLiveSessionResource.closerf   rC   c             	   Ã  ó*   �| j  tttd||dœƒƒ¡I dH  dS rÊ  rÇ  rÌ  rR   rR   rS   rÍ  š  ó   €ÿÿzAsyncLiveSessionResource.updater?   c             	   Ã  r  rÎ  rÇ  rÌ  rR   rR   rS   rÏ  ¦  s   €ÿzAsyncLiveSessionResource.startN)rL   r  )rL   r  )rL   r  )rL   r  )rL   r  rÐ  rÑ  rÒ  rÓ  rR   rR   rR   rS   r©   |  s    	r©   c                   @  rÔ  )r  rÁ  rÕ  r×   rÖ  r×  rÂ  rÃ  rL   r˜   c             
   Ã  ó,   �| j  tttd|||dœƒƒ¡I dH  dS rÙ  rÇ  rÛ  rR   rR   rS   rÜ  ±  ó   €	üÿþÿz)AsyncLiveSessionCommentaryResource.appendNrÞ  rß  rR   rR   rR   rS   r  °  ó    ÿr  c                   @  rá  )r  rÁ  râ  r×   rÂ  rÃ  rL   r˜   c             	   Ã  r  rã  rÇ  rå  rR   rR   rS   rÜ  Ê  ó   €þÿz)AsyncLiveSessionInputAudioResource.appendc                Ã  r  rç  rÇ  rÈ  rR   rR   rS   rè  Ö  r  z'AsyncLiveSessionInputAudioResource.mutec                Ã  r  rê  rÇ  rÈ  rR   rR   rS   rë  ß  r  z)AsyncLiveSessionInputAudioResource.unmuteNrì  rÐ  rí  rR   rR   rR   rS   r  É  rî  r  c                   @  rÔ  )r  rÁ  rÕ  r×   rÖ  r×  rÂ  rÃ  rL   r˜   c             
   Ã  r   rï  rÇ  rÛ  rR   rR   rS   rÜ  ê  s   €üÿþÿz+AsyncLiveSessionInstructionsResource.appendNrÞ  rß  rR   rR   rR   rS   r  é  r"  r  c                   @  rð  )r  rL   Ú*AsyncLiveSessionOutputAudioFixtureResourcec                 C  rM   rN   )r$  r¯   rP   rR   rR   rS   rò    rU   z+AsyncLiveSessionOutputAudioResource.fixtureN)rL   r$  ró  rR   rR   rR   rS   r    rô  r  c                   @  rÔ  )r  rÁ  rÕ  r×   rÖ  r×  rÂ  rÃ  rL   r˜   c             
   Ã  r   rõ  rÇ  rÛ  rR   rR   rS   rÜ    r!  z'AsyncLiveSessionThinkingResource.appendNrÞ  rß  rR   rR   rR   rS   r    r"  r  c                   @  rö  )r$  rÁ  râ  r×   rÂ  rÃ  rL   r˜   c             	   Ã  r  r÷  rÇ  rå  rR   rR   rS   rø  !  r#  z/AsyncLiveSessionOutputAudioFixtureResource.playNrì  rù  rR   rR   rR   rS   r$     rà  r$  c                   @  rú  )rª   rL   ÚAsyncLiveDecisionItemResourcec                 C  rM   rN   )r%  r¯   rP   rR   rR   rS   rü  /  rU   zAsyncLiveDecisionResource.itemrÂ  r×   r˜   c                Ã  s   �| j  d|dœ¡I dH  dS rý  rþ  rÈ  rR   rR   rS   ry   3  s   €z AsyncLiveDecisionResource.createN)rL   r%  rÿ  r   rR   rR   rR   rS   rª   .  r  rª   c                   @  r  )r%  rÁ  r  r×   rÂ  rÃ  rL   r˜   c             	   Ã  r  r  rÇ  r  rR   rR   rS   r  >  s   €þÿz$AsyncLiveDecisionItemResource.deleterü  r  c             	   Ã  r  r  rÇ  r
  rR   rR   rS   ry   I  r  z$AsyncLiveDecisionItemResource.createNr  r  r  rR   rR   rR   rS   r%  =  s    ÿr%  c                   @  r  )r¬   rL   ÚAsyncLiveResponseItemResourcec                 C  rM   rN   )r&  r¯   rP   rR   rR   rS   rü  W  rU   zAsyncLiveResponseResource.itemrÁ  rÂ  rÃ  r˜   c                Ã  r  r  rÇ  rÈ  rR   rR   rS   ry   [  s   €ÿz AsyncLiveResponseResource.createN)rL   r&  rÐ  r  rR   rR   rR   rS   r¬   V  r  r¬   c                   @  rö  )r&  rÁ  rü  rD   rÂ  rÃ  rL   r˜   c             	   Ã  r  r  rÇ  r
  rR   rR   rS   ry   h  s   €ÿÿz$AsyncLiveResponseItemResource.createNr  r  rR   rR   rR   rS   r&  g  rà  r&  )”Ú
__future__r   râ   ÚloggingÚtypesr   Útypingr   r   r   r   r   r	   r
   r   Ztyping_extensionsr   r  Zpydanticr   Ú r   rV   r   r   Ú_typesr   r   r   r   r   r   r   Z_utilsr   r   r   r   rW   r   r   r    r!   r"   r#   rT   r$   r%   Z_compatr&   Z_modelsr'   r(   Z	_resourcer)   r*   Ú	_responser+   r,   Ú
_constantsr-   Z
types.liver.   r/   Ú_exceptionsr0   r1   rÇ   r2   Z_base_clientr3   r4   Z_event_handlerr5   Z_websocket_connectionr6   r7   Ztypes.live.error_eventr8   Ztypes.live.client_eventr9   Ztypes.live.server_eventr:   Ztypes.websocket_reconnectionr;   r<   Ztypes.live.client_event_paramr=   Ztypes.live.live_create_responser>   Ztypes.live.session_config_paramr?   Z"types.websocket_connection_optionsr@   rA   Z%types.live.media_session_config_paramrB   Z&types.live.session_update_config_paramrC   Z)types.responses.response_input_item_paramrD   r¬  rE   r˜  Zwebsockets.asyncio.clientr®   rO   rF   rG   Ú__all__Ú	getLoggerr�   rJ   r(  rH   rI   rX   r“   r]   r”   r§   r•   r”  r†   r¯  r•  r·  r¹  r»  r½  r¿  rñ  r–  rû  r—  r  r  r©   r  r  r  r  r  r$  rª   r%  r¬   r&  rR   rR   rR   rS   Ú<module>   s    ($ mm J W F V2 4 