
    g>                    D   d dl mZ d dl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mZmZmZmZ ddlmZmZ dd	lmZ dd
lmZmZ ddlmZmZ ddlmZ ddlmZ ddl m!Z! ddgZ" G d de      Z# G d de      Z$ G d d      Z% G d d      Z& G d d      Z' G d d      Z(y)    )annotations)ListUnionIterable)LiteralN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)make_request_options)session_create_params)SessionCreateResponseSessionsAsyncSessionsc                      e Zd Zedd       Zedd       Zeeeeeeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)	r   c                    t        |       S a  
        This property can be used as a prefix for any HTTP method call to return the
        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
        )SessionsWithRawResponseselfs    \/var/www/openai/venv/lib/python3.12/site-packages/openai/resources/beta/realtime/sessions.pywith_raw_responsezSessions.with_raw_response   s     't,,    c                    t        |       S 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
        )SessionsWithStreamingResponser   s    r!   with_streaming_responsez Sessions.with_streaming_response%   s     -T22r#   Ninput_audio_formatinput_audio_transcriptioninstructionsmax_response_output_tokens
modalitiesoutput_audio_formattemperaturetool_choicetoolsturn_detectionvoiceextra_headersextra_query
extra_bodytimeoutc                   ddi|xs i }| j                  dt        |||||||||	|
||dt        j                        t	        ||||      t
              S )  
        Create an ephemeral API token for use in client-side applications with the
        Realtime API. Can be configured with the same session parameters as the
        `session.update` client event.

        It responds with a session object, plus a `client_secret` key which contains a
        usable ephemeral API token that can be used to authenticate browser clients for
        the Realtime API.

        Args:
          model: The Realtime model used for this session.

          input_audio_format: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.

          input_audio_transcription: Configuration for input audio transcription, defaults to off and can be set to
              `null` to turn off once on. Input audio transcription is not native to the
              model, since the model consumes audio directly. Transcription runs
              asynchronously through Whisper and should be treated as rough guidance rather
              than the representation understood by the model.

          instructions: The default system instructions (i.e. system message) prepended to model calls.
              This field allows the client to guide the model on desired responses. The model
              can be instructed on response content and format, (e.g. "be extremely succinct",
              "act friendly", "here are examples of good responses") and on audio behavior
              (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
              instructions are not guaranteed to be followed by the model, but they provide
              guidance to the model on the desired behavior.

              Note that the server sets default instructions which will be used if this field
              is not set and are visible in the `session.created` event at the start of the
              session.

          max_response_output_tokens: Maximum number of output tokens for a single assistant response, inclusive of
              tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
              `inf` for the maximum available tokens for a given model. Defaults to `inf`.

          modalities: The set of modalities the model can respond with. To disable audio, set this to
              ["text"].

          output_audio_format: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.

          temperature: Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.

          tool_choice: How the model chooses tools. Options are `auto`, `none`, `required`, or specify
              a function.

          tools: Tools (functions) available to the model.

          turn_detection: Configuration for turn detection. Can be set to `null` to turn off. Server VAD
              means that the model will detect the start and end of speech based on audio
              volume and respond at the end of user speech.

          voice: The voice the model uses to respond. Voice cannot be changed during the session
              once the model has responded with audio at least once. Current voice options are
              `alloy`, `ash`, `ballad`, `coral`, `echo` `sage`, `shimmer` and `verse`.

          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
        OpenAI-Betaassistants=v2/realtime/sessionsmodelr)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   bodyoptionscast_to)_postr   r   SessionCreateParamsr   r   r    r>   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   s                    r!   createzSessions.create.   s    x 'QM<ORQzz  "*<1J$02L",+>#.#."&4" &99" )+Q[el *-  
 	
r#   )returnr   )rH   r&   "r>   zLiteral['gpt-4o-realtime-preview', 'gpt-4o-realtime-preview-2024-10-01', 'gpt-4o-realtime-preview-2024-12-17', 'gpt-4o-mini-realtime-preview', 'gpt-4o-mini-realtime-preview-2024-12-17']r)   5Literal['pcm16', 'g711_ulaw', 'g711_alaw'] | NotGivenr*   z8session_create_params.InputAudioTranscription | NotGivenr+   str | NotGivenr,   z%Union[int, Literal['inf']] | NotGivenr-   z)List[Literal['text', 'audio']] | NotGivenr.   rJ   r/   zfloat | NotGivenr0   rK   r1   z/Iterable[session_create_params.Tool] | NotGivenr2   z.session_create_params.TurnDetection | NotGivenr3   zYLiteral['alloy', 'ash', 'ballad', 'coral', 'echo', 'sage', 'shimmer', 'verse'] | NotGivenr4   zHeaders | Noner5   zQuery | Noner6   zBody | Noner7   z'float | httpx.Timeout | None | NotGivenrH   r   __name__
__module____qualname__r   r"   r'   r
   rG    r#   r!   r   r      s"   - - 3 3$ U^^g'0LU@IU^(1&/AJIRkt )-$("&;D5t

t
 Rt
 $\t
 %t
 %Jt
 >t
 St
  &!t
" $#t
$ ?%t
& G't
( i)t
. &/t
0 "1t
2  3t
4 95t
6 
7t
r#   c                      e Zd Zedd       Zedd       Zeeeeeeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)	r   c                    t        |       S r   )AsyncSessionsWithRawResponser   s    r!   r"   zAsyncSessions.with_raw_response   s     ,D11r#   c                    t        |       S r%   )"AsyncSessionsWithStreamingResponser   s    r!   r'   z%AsyncSessions.with_streaming_response   s     2$77r#   Nr(   c                  K   ddi|xs i }| j                  dt        |||||||||	|
||dt        j                         d{   t	        ||||      t
               d{   S 7 $7 w)r9   r:   r;   r<   r=   Nr?   r@   )rD   r   r   rE   r   r   rF   s                    r!   rG   zAsyncSessions.create   s     x 'QM<ORQZZ ,"*<1J$02L",+>#.#."&4" &99 " )+Q[el *-   
 
 	

s$   AA,A(
A,#A*$A,*A,)rH   rS   )rH   rU   rI   rL   rP   r#   r!   r   r      s"   2 2 8 8$ U^^g'0LU@IU^(1&/AJIRkt )-$("&;D5t

t
 Rt
 $\t
 %t
 %Jt
 >t
 St
  &!t
" $#t
$ ?%t
& G't
( i)t
. &/t
0 "1t
2  3t
4 95t
6 
7t
r#   c                      e Zd ZddZy)r   c                Z    || _         t        j                  |j                        | _        y N)	_sessionsr	   to_raw_response_wrapperrG   r    sessionss     r!   __init__z SessionsWithRawResponse.__init__1  s"    !&>>OO
r#   Nr]   r   rH   NonerM   rN   rO   r^   rP   r#   r!   r   r   0      
r#   r   c                      e Zd ZddZy)rS   c                Z    || _         t        j                  |j                        | _        y rY   )rZ   r	   async_to_raw_response_wrapperrG   r\   s     r!   r^   z%AsyncSessionsWithRawResponse.__init__:  s"    !&DDOO
r#   Nr]   r   rH   r`   ra   rP   r#   r!   rS   rS   9  rb   r#   rS   c                      e Zd ZddZy)r&   c                F    || _         t        |j                        | _        y rY   )rZ   r   rG   r\   s     r!   r^   z&SessionsWithStreamingResponse.__init__C  s    !2OO
r#   Nr_   ra   rP   r#   r!   r&   r&   B  rb   r#   r&   c                      e Zd ZddZy)rU   c                F    || _         t        |j                        | _        y rY   )rZ   r   rG   r\   s     r!   r^   z+AsyncSessionsWithStreamingResponse.__init__L  s    !8OO
r#   Nrf   ra   rP   r#   r!   rU   rU   K  rb   r#   rU   ))
__future__r   typingr   r   r   typing_extensionsr   httpx r	   _typesr
   r   r   r   r   _utilsr   r   _compatr   	_resourcer   r   	_responser   r   _base_clientr   types.beta.realtimer   +types.beta.realtime.session_create_responser   __all__r   r   r   rS   r&   rU   rP   r#   r!   <module>ry      s    # ( ( %  ! @ @ ( ; Z 1 9 Q
'H
 H
VH
$ H
V
 

 

 

 
r#   