
    -2iρ                       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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mZm Z m!Z!m"Z" ddl#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddgZ8 G d de          Z9 G d de          Z: G d d          Z; G d d          Z< G d d          Z= G d d           Z>dS )!    )annotations)ListUnionOptional)LiteralN   )_legacy_response)BodyOmitQueryHeadersNoneTypeNotGivenomit	not_given)maybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)StreamedBinaryAPIResponseAsyncStreamedBinaryAPIResponseto_streamed_response_wrapper"async_to_streamed_response_wrapper#to_custom_streamed_response_wrapper)async_to_custom_streamed_response_wrapper)make_request_options)call_refer_paramscall_accept_paramscall_create_paramscall_reject_params)ResponsePromptParam)RealtimeTruncationParam)RealtimeAudioConfigParam)RealtimeToolsConfigParam)RealtimeTracingConfigParam)RealtimeToolChoiceConfigParam)!RealtimeSessionCreateRequestParamCalls
AsyncCallsc                      e Zd Zed:d            Zed;d            Zedddedd<dZeeeeeeeeeeedddedd=d1Z	ddded2d>d3Z
ddded2d?d5Zeddded6d@d9ZdS )Ar)   returnCallsWithRawResponsec                     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-   selfs    ^/var/www/html/pixcura-vrs/venv/lib/python3.11/site-packages/openai/resources/realtime/calls.pywith_raw_responsezCalls.with_raw_response*   s     $D)))    CallsWithStreamingResponsec                     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
        )r5   r0   s    r2   with_streaming_responsezCalls.with_streaming_response4   s     *$///r4   Nsessionextra_headersextra_query
extra_bodytimeoutsdpstrr:   (RealtimeSessionCreateRequestParam | Omitr;   Headers | Noner<   Query | Noner=   Body | Noner>   'float | httpx.Timeout | None | NotGiven+_legacy_response.HttpxBinaryResponseContentc          
         ddi|pi }|                      dt          ||dt          j                  t	          ||||          t
          j                  S )=  
        Create a new Realtime API call over WebRTC and receive the SDP answer needed to
        complete the peer connection.

        Args:
          sdp: WebRTC Session Description Protocol (SDP) offer generated by the caller.

          session: Realtime session object configuration.

          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
        Acceptapplication/sdp/realtime/callsr?   r:   r;   r<   r=   r>   bodyoptionscast_to)_postr   r    CallCreateParamsr   r	   HttpxBinaryResponseContentr1   r?   r:   r;   r<   r=   r>   s          r2   createzCalls.create=   s    : "#4N9L"Nzz &  #3  )+Q[el   %?  
 
 	
r4   audioincludeinstructionsmax_output_tokensmodeloutput_modalitiesprompttool_choicetoolstracing
truncationr;   r<   r=   r>   call_idtypeLiteral['realtime']rX   RealtimeAudioConfigParam | OmitrY   ?List[Literal['item.input_audio_transcription.logprobs']] | OmitrZ   
str | Omitr[   !Union[int, Literal['inf']] | Omitr\     Union[str, Literal['gpt-realtime', 'gpt-realtime-2025-08-28', 'gpt-4o-realtime-preview', 'gpt-4o-realtime-preview-2024-10-01', 'gpt-4o-realtime-preview-2024-12-17', 'gpt-4o-realtime-preview-2025-06-03', 'gpt-4o-mini-realtime-preview', 'gpt-4o-mini-realtime-preview-2024-12-17', 'gpt-realtime-mini', 'gpt-realtime-mini-2025-10-06', 'gpt-audio-mini', 'gpt-audio-mini-2025-10-06']] | Omitr]   %List[Literal['text', 'audio']] | Omitr^   $Optional[ResponsePromptParam] | Omitr_   $RealtimeToolChoiceConfigParam | Omitr`   RealtimeToolsConfigParam | Omitra   +Optional[RealtimeTracingConfigParam] | Omitrb   RealtimeTruncationParam | OmitNonec                   |st          d|          ddi|pi }|                     d| dt          ||||||||	|
|||dt          j                  t          ||||          t                    S )	  
        Accept an incoming SIP call and configure the realtime session that will handle
        it.

        Args:
          type: The type of session to create. Always `realtime` for the Realtime API.

          audio: Configuration for input and output audio.

          include: Additional fields to include in server outputs.

              `item.input_audio_transcription.logprobs`: Include logprobs for input audio
              transcription.

          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_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`.

          model: The Realtime model used for this session.

          output_modalities: The set of modalities the model can respond with. It defaults to `["audio"]`,
              indicating that the model will respond with audio plus a transcript. `["text"]`
              can be used to make the model respond with text only. It is not possible to
              request both `text` and `audio` at the same time.

          prompt: Reference to a prompt template and its variables.
              [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

          tool_choice: How the model chooses tools. Provide one of the string modes or force a specific
              function/MCP tool.

          tools: Tools available to the model.

          tracing: Realtime API can write session traces to the
              [Traces Dashboard](/logs?api=traces). Set to null to disable tracing. Once
              tracing is enabled for a session, the configuration cannot be modified.

              `auto` will create a trace for the session with default values for the workflow
              name, group id, and metadata.

          truncation: When the number of tokens in a conversation exceeds the model's input token
              limit, the conversation be truncated, meaning messages (starting from the
              oldest) will not be included in the model's context. A 32k context model with
              4,096 max output tokens can only include 28,224 tokens in the context before
              truncation occurs.

              Clients can configure truncation behavior to truncate with a lower max token
              limit, which is an effective way to control token usage and cost.

              Truncation will reduce the number of cached tokens on the next turn (busting the
              cache), since messages are dropped from the beginning of the context. However,
              clients can also configure truncation to retain messages up to a fraction of the
              maximum context size, which will reduce the need for future truncations and thus
              improve the cache rate.

              Truncation can be disabled entirely, which means the server will never truncate
              but would instead return an error if the conversation exceeds the model's input
              token limit.

          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
        6Expected a non-empty value for `call_id` but received rI   */*/realtime/calls//acceptrd   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rM   rN   )
ValueErrorrR   r   r   CallAcceptParamsr   r   r1   rc   rd   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   r;   r<   r=   r>   s                     r2   acceptzCalls.acceptj   s    n  	caV]aabbb!5B]-@bBzz/w///  "&$0):"):$#."&",  #3 " )+Q[el   -  
 
 	
r4   rM   c          	         |st          d|          ddi|pi }|                     d| dt          ||||          t                    S )  
        End an active Realtime API call, whether it was initiated over SIP or WebRTC.

        Args:
          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
        rt   rI   ru   rv   /hanguprM   rP   rQ   ry   rR   r   r   r1   rc   r;   r<   r=   r>   s         r2   hangupzCalls.hangup   s    .  	caV]aabbb!5B]-@bBzz/w///(+Q[el     
 
 	
r4   
target_uric          
         |st          d|          ddi|pi }|                     d| dt          d|it          j                  t          ||||          t                    S )	  
        Transfer an active SIP call to a new destination using the SIP REFER verb.

        Args:
          target_uri: URI that should appear in the SIP Refer-To header. Supports values like
              `tel:+14155550123` or `sip:agent@example.com`.

          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
        rt   rI   ru   rv   /referr   rM   rN   )ry   rR   r   r   CallReferParamsr   r   r1   rc   r   r;   r<   r=   r>   s          r2   referzCalls.refer  s    6  	caV]aabbb!5B]-@bBzz.w... ,
!;=N=^__(+Q[el     
 
 	
r4   status_coder;   r<   r=   r>   r   
int | Omitc          
         |st          d|          ddi|pi }|                     d| dt          d|it          j                  t          ||||          t                    S )	  
        Decline an incoming SIP call by returning a SIP status code to the caller.

        Args:
          status_code: SIP response code to send back to the caller. Defaults to `603` (Decline) when
              omitted.

          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
        rt   rI   ru   rv   /rejectr   rM   rN   )ry   rR   r   r!   CallRejectParamsr   r   r1   rc   r   r;   r<   r=   r>   s          r2   rejectzCalls.rejectF  s    6  	caV]aabbb!5B]-@bBzz/w/// -!=?Q?bcc(+Q[el     
 
 	
r4   )r,   r-   )r,   r5   r?   r@   r:   rA   r;   rB   r<   rC   r=   rD   r>   rE   r,   rF   $rc   r@   rd   re   rX   rf   rY   rg   rZ   rh   r[   ri   r\   rj   r]   rk   r^   rl   r_   rm   r`   rn   ra   ro   rb   rp   r;   rB   r<   rC   r=   rD   r>   rE   r,   rq   rc   r@   r;   rB   r<   rC   r=   rD   r>   rE   r,   rq   rc   r@   r   r@   r;   rB   r<   rC   r=   rD   r>   rE   r,   rq   rc   r@   r   r   r;   rB   r<   rC   r=   rD   r>   rE   r,   rq   __name__
__module____qualname__r   r3   r8   r   r   rV   r|   r   r   r    r4   r2   r)   r)   )   si       * * * _* 0 0 0 _0 =A )-$("&;D+
 +
 +
 +
 +
 +
d 26SW#'?C$ CG7;<@15?C59 )-$("&;DMQ
 Q
 Q
 Q
 Q
 Q
r )-$("&;D 
  
  
  
  
  
R )-$("&;D%
 %
 %
 %
 %
 %
V #' )-$("&;D%
 %
 %
 %
 %
 %
 %
 %
r4   c                      e Zd Zed:d            Zed;d            Zedddedd<dZeeeeeeeeeeedddedd=d1Z	ddded2d>d3Z
ddded2d?d5Zeddded6d@d9ZdS )Ar*   r,   AsyncCallsWithRawResponsec                     t          |           S r/   )r   r0   s    r2   r3   zAsyncCalls.with_raw_responseo  s     )...r4   AsyncCallsWithStreamingResponsec                     t          |           S r7   )r   r0   s    r2   r8   z"AsyncCalls.with_streaming_responsey  s     /t444r4   Nr9   r?   r@   r:   rA   r;   rB   r<   rC   r=   rD   r>   rE   rF   c          
        K   ddi|pi }|                      dt          ||dt          j                   d{V t	          ||||          t
          j                   d{V S )rH   rI   rJ   rK   rL   NrM   rN   )rR   r   r    rS   r   r	   rT   rU   s          r2   rV   zAsyncCalls.create  s      : "#4N9L"NZZ,&  #3        )+Q[el   %?   
 
 
 
 
 
 
 
 	
r4   rW   rc   rd   re   rX   rf   rY   rg   rZ   rh   r[   ri   r\   rj   r]   rk   r^   rl   r_   rm   r`   rn   ra   ro   rb   rp   rq   c                 K   |st          d|          ddi|pi }|                     d| dt          ||||||||	|
|||dt          j                   d{V t          ||||          t          	           d{V S )
rs   rt   rI   ru   rv   rw   rx   NrM   rN   )ry   rR   r   r   rz   r   r   r{   s                     r2   r|   zAsyncCalls.accept  s
     n  	caV]aabbb!5B]-@bBZZ/w///, "&$0):"):$#."&",  #3       " )+Q[el   -   
 
 
 
 
 
 
 
 	
r4   rM   c          	        K   |st          d|          ddi|pi }|                     d| dt          ||||          t                     d{V S )	r~   rt   rI   ru   rv   r   rM   r   Nr   r   s         r2   r   zAsyncCalls.hangupB  s      .  	caV]aabbb!5B]-@bBZZ/w///(+Q[el      
 
 
 
 
 
 
 
 	
r4   r   c          
        K   |st          d|          ddi|pi }|                     d| dt          d|it          j                   d{V t          ||||          t          	           d{V S )
r   rt   rI   ru   rv   r   r   NrM   rN   )ry   rR   r   r   r   r   r   r   s          r2   r   zAsyncCalls.referd  s      6  	caV]aabbb!5B]-@bBZZ.w...,lJ-GIZIjkkkkkkkk(+Q[el      
 
 
 
 
 
 
 
 	
r4   r   r   r   c          
        K   |st          d|          ddi|pi }|                     d| dt          d|it          j                   d{V t          ||||          t          	           d{V S )
r   rt   rI   ru   rv   r   r   NrM   rN   )ry   rR   r   r!   r   r   r   r   s          r2   r   zAsyncCalls.reject  s      6  	caV]aabbb!5B]-@bBZZ/w///,m[-IK]Knoooooooo(+Q[el      
 
 
 
 
 
 
 
 	
r4   )r,   r   )r,   r   r   r   r   r   r   r   r   r4   r2   r*   r*   n  si       / / / _/ 5 5 5 _5 =A )-$("&;D+
 +
 +
 +
 +
 +
d 26SW#'?C$ CG7;<@15?C59 )-$("&;DMQ
 Q
 Q
 Q
 Q
 Q
r )-$("&;D 
  
  
  
  
  
R )-$("&;D%
 %
 %
 %
 %
 %
V #' )-$("&;D%
 %
 %
 %
 %
 %
 %
 %
r4   c                      e Zd ZddZdS )r-   callsr)   r,   rq   c                @   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S N)_callsr	   to_raw_response_wrapperrV   r|   r   r   r   r1   r   s     r2   __init__zCallsWithRawResponse.__init__  s    &>L
 
 '>L
 
 '>L
 
 &=K
 

 '>L
 
r4   Nr   r)   r,   rq   r   r   r   r   r   r4   r2   r-   r-     (        
 
 
 
 
 
r4   r-   c                      e Zd ZddZdS )r   r   r*   r,   rq   c                @   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S r   )r   r	   async_to_raw_response_wrapperrV   r|   r   r   r   r   s     r2   r   z"AsyncCallsWithRawResponse.__init__  s    &DL
 
 'DL
 
 'DL
 
 &CK
 

 'DL
 
r4   Nr   r*   r,   rq   r   r   r4   r2   r   r     r   r4   r   c                      e Zd ZddZdS )r5   r   r)   r,   rq   c                   || _         t          |j        t                    | _        t	          |j                  | _        t	          |j                  | _        t	          |j                  | _        t	          |j                  | _        d S r   )	r   r   rV   r   r   r|   r   r   r   r   s     r2   r   z#CallsWithStreamingResponse.__init__  s    9L%
 
 3L
 
 3L
 
 2K
 

 3L
 
r4   Nr   r   r   r4   r2   r5   r5     (        
 
 
 
 
 
r4   r5   c                      e Zd ZddZdS )r   r   r*   r,   rq   c                   || _         t          |j        t                    | _        t	          |j                  | _        t	          |j                  | _        t	          |j                  | _        t	          |j                  | _        d S r   )	r   r   rV   r   r   r|   r   r   r   r   s     r2   r   z(AsyncCallsWithStreamingResponse.__init__  s    ?L*
 
 9L
 
 9L
 
 8K
 

 9L
 
r4   Nr   r   r   r4   r2   r   r     r   r4   r   )?
__future__r   typingr   r   r   typing_extensionsr   httpx r	   _typesr
   r   r   r   r   r   r   r   _utilsr   r   _compatr   	_resourcer   r   	_responser   r   r   r   r   r   _base_clientr   types.realtimer   r   r    r!   %types.responses.response_prompt_paramr"   (types.realtime.realtime_truncation_paramr#   *types.realtime.realtime_audio_config_paramr$   *types.realtime.realtime_tools_config_paramr%   ,types.realtime.realtime_tracing_config_paramr&   0types.realtime.realtime_tool_choice_config_paramr'   4types.realtime.realtime_session_create_request_paramr(   __all__r)   r*   r-   r   r5   r   r   r4   r2   <module>r      s   # " " " " " ( ( ( ( ( ( ( ( ( ( % % % % % %              U U U U U U U U U U U U U U U U U U U U < < < < < < < < & & & & & & : : : : : : : :                1 0 0 0 0 0            I H H H H H O O O O O O R R R R R R R R R R R R V V V V V V ] ] ] ] ] ] e e e e e eL
!B
 B
 B
 B
 B
O B
 B
 B
J
B
 B
 B
 B
 B
! B
 B
 B
J

 
 
 
 
 
 
 
*
 
 
 
 
 
 
 
*
 
 
 
 
 
 
 
,
 
 
 
 
 
 
 
 
 
r4   