o
    ?HhqN                     @  s   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 deZ#G dd deZ$G dd dZ%G dd dZ&G dd dZ'G dd dZ(dS )    )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                   @  X   e Zd Zed-ddZed.ddZeeeeeeeeeeeeeddded	d/d+d,ZdS )0r   returnSessionsWithRawResponsec                 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
        )r   self r!   g/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/openai/resources/beta/realtime/sessions.pywith_raw_response      zSessions.with_raw_responseSessionsWithStreamingResponsec                 C  r   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%   r   r!   r!   r"   with_streaming_response%      z Sessions.with_streaming_responseNinput_audio_formatinput_audio_noise_reductioninput_audio_transcriptioninstructionsmax_response_output_tokens
modalitiesmodeloutput_audio_formattemperaturetool_choicetoolsturn_detectionvoiceextra_headersextra_query
extra_bodytimeoutr*   5Literal['pcm16', 'g711_ulaw', 'g711_alaw'] | NotGivenr+   9session_create_params.InputAudioNoiseReduction | NotGivenr,   8session_create_params.InputAudioTranscription | NotGivenr-   str | NotGivenr.   %Union[int, Literal['inf']] | NotGivenr/   )List[Literal['text', 'audio']] | NotGivenr0   Literal['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'] | NotGivenr1   r2   float | NotGivenr3   r4   /Iterable[session_create_params.Tool] | NotGivenr5   .session_create_params.TurnDetection | NotGivenr6   ~Union[str, Literal['alloy', 'ash', 'ballad', 'coral', 'echo', 'fable', 'onyx', 'nova', 'sage', 'shimmer', 'verse']] | NotGivenr7   Headers | Noner8   Query | Noner9   Body | Noner:   'float | httpx.Timeout | None | NotGivenr   c                C  sR   ddi|pi }| j dt|||||||||	|
|||dtjt||||dtdS )n  
        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:
          input_audio_format: The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
              `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
              (mono), and little-endian byte order.

          input_audio_noise_reduction: Configuration for input audio noise reduction. This can be set to `null` to turn
              off. Noise reduction filters audio added to the input audio buffer before it is
              sent to VAD and the model. Filtering the audio can improve VAD and turn
              detection accuracy (reducing false positives) and model performance by improving
              perception of the input audio.

          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
              [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription)
              and should be treated as guidance of input audio content rather than precisely
              what the model heard. The client can optionally set the language and prompt for
              transcription, these offer additional guidance to the transcription service.

          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"].

          model: The Realtime model used for this session.

          output_audio_format: The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
              For `pcm16`, output audio is sampled at a rate of 24kHz.

          temperature: Sampling temperature for the model, limited to [0.6, 1.2]. For audio models a
              temperature of 0.8 is highly recommended for best performance.

          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, ether Server VAD or Semantic VAD. This can be
              set to `null` to turn off, in which case the client must manually trigger model
              response. 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. Semantic VAD
              is more advanced and uses a turn detection model (in conjuction with VAD) to
              semantically estimate whether the user has finished speaking, then dynamically
              sets a timeout based on this probability. For example, if user audio trails off
              with "uhhm", the model will score a low probability of turn end and wait longer
              for the user to continue speaking. This can be useful for more natural
              conversations, but may have a higher latency.

          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`, `fable`, `onyx`, `nova`, `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r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   bodyoptionscast_to)_postr   r   SessionCreateParamsr   r   r    r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r!   r!   r"   create.   s2   vzSessions.create)r   r   )r   r%   $r*   r;   r+   r<   r,   r=   r-   r>   r.   r?   r/   r@   r0   rA   r1   r;   r2   rB   r3   r>   r4   rC   r5   rD   r6   rE   r7   rF   r8   rG   r9   rH   r:   rI   r   r   __name__
__module____qualname__r   r#   r'   r	   rW   r!   r!   r!   r"   r      .    	c                   @  r   )0r   r   AsyncSessionsWithRawResponsec                 C  r   r   )r^   r   r!   r!   r"   r#      r$   zAsyncSessions.with_raw_response"AsyncSessionsWithStreamingResponsec                 C  r   r&   )r_   r   r!   r!   r"   r'      r(   z%AsyncSessions.with_streaming_responseNr)   r*   r;   r+   r<   r,   r=   r-   r>   r.   r?   r/   r@   r0   rA   r1   r2   rB   r3   r4   rC   r5   rD   r6   rE   r7   rF   r8   rG   r9   rH   r:   rI   r   c                  s`   ddi|pi }| j dt|||||||||	|
|||dtjI dH t||||dtdI dH S )rJ   rK   rL   rM   rN   NrO   rP   )rT   r   r   rU   r   r   rV   r!   r!   r"   rW      s4   vzAsyncSessions.create)r   r^   )r   r_   rX   rY   r!   r!   r!   r"   r      r]   c                   @     e Zd ZdddZdS )	r   sessionsr   r   Nonec                 C     || _ t|j| _d S N)	_sessionsr   to_raw_response_wrapperrW   r    ra   r!   r!   r"   __init__g     
z SessionsWithRawResponse.__init__Nra   r   r   rb   rZ   r[   r\   rh   r!   r!   r!   r"   r   f      r   c                   @  r`   )	r^   ra   r   r   rb   c                 C  rc   rd   )re   r   async_to_raw_response_wrapperrW   rg   r!   r!   r"   rh   p  ri   z%AsyncSessionsWithRawResponse.__init__Nra   r   r   rb   rk   r!   r!   r!   r"   r^   o  rl   r^   c                   @  r`   )	r%   ra   r   r   rb   c                 C     || _ t|j| _d S rd   )re   r   rW   rg   r!   r!   r"   rh   y     
z&SessionsWithStreamingResponse.__init__Nrj   rk   r!   r!   r!   r"   r%   x  rl   r%   c                   @  r`   )	r_   ra   r   r   rb   c                 C  ro   rd   )re   r   rW   rg   r!   r!   r"   rh     rp   z+AsyncSessionsWithStreamingResponse.__init__Nrn   rk   r!   r!   r!   r"   r_     rl   r_   ))
__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   r^   r%   r_   r!   r!   r!   r"   <module>   s,    ' '			