o
    Th                    @  sF  d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ d dlmZ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 dd	lmZmZ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'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z.m/Z/ ddl0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9m:Z:m;Z< ddl=m>Z> ddl?m@Z@ ddlAmBZBmCZC ddlDmEZE ddlFmGZG ddlHmIZI ddlJmKZKmLZL ddlMmNZN ddlOmPZP ddlQmRZR ddlSmTZT ddlUmVZV dd lWmXZX d!d"gZYG d#d! d!e!ZZG 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_d3d1d2Z`dS )4    )annotations)AnyListTypeUnionIterableOptionalcast)partial)LiteraloverloadN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNoneTypeNotGiven)is_givenrequired_argsmaybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper   )
InputItemsAsyncInputItemsInputItemsWithRawResponseAsyncInputItemsWithRawResponseInputItemsWithStreamingResponse$AsyncInputItemsWithStreamingResponse)StreamAsyncStream)PydanticFunctionToolResponsesPydanticFunctionTool)make_request_options)response_create_paramsresponse_retrieve_params)TextFormatTparse_responsetype_to_text_format_param)	ChatModel)Response)	ToolParamParseableToolParam)Metadata)	Reasoning)ParsedResponse)ResponseStreamManagerAsyncResponseStreamManager)ResponseIncludable)ResponsesModel)ResponseInputParam)ResponsePromptParam)ResponseStreamEvent)ResponseTextConfigParam	ResponsesAsyncResponsesc                   @    e Zd ZedsddZedtddZedud	d
Zeeeeeeeeeeeeeeeeeeeedddeddvd<d=Z	eeeeeeeeeeeeeeeeeeeddded>dwdAd=Z	eeeeeeeeeeeeeeeeeeeddded>dxdDd=Z	e
ddgg dEeeeeeeeeeeeeeeeeeeedddeddydGd=Z	eeeedddedHdzdQdRZeeeeeeeeeeeeeeeeeedddedSd{dUdRZeeeeeeeeeeeeeeeeeeeeedddedVd|dYdRZeeeeeeeeeeeeeeeeedddedZd}d\d]Zeeeeddded^d~dadbZeeedddedcddddbZeeedddedcddedbZedfeedddedgddhdbZeeedddedcddidbZeeedddedcddjdbZeeeddded^ddldbZdddedmddodpZdddedmddqdrZdS )r>   returnr   c                 C  
   t | jS N)r   _clientself rG   e/home/air/segue/gemini/back/venv/lib/python3.10/site-packages/openai/resources/responses/responses.pyinput_items4      
zResponses.input_itemsResponsesWithRawResponsec                 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
        )rK   rE   rG   rG   rH   with_raw_response8      zResponses.with_raw_responseResponsesWithStreamingResponsec                 C  rL   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
        )rP   rE   rG   rG   rH   with_streaming_responseB      z!Responses.with_streaming_responseN
backgroundincludeinstructionsmax_output_tokensmetadataparallel_tool_callsprevious_response_idprompt	reasoningservice_tierstorestreamtemperaturetexttool_choicetoolstop_p
truncationuserextra_headersextra_query
extra_bodytimeoutinputUnion[str, ResponseInputParam]modelr9   rU   Optional[bool] | NotGivenrV   -Optional[List[ResponseIncludable]] | NotGivenrW   Optional[str] | NotGivenrX   Optional[int] | NotGivenrY   Optional[Metadata] | NotGivenrZ   r[   r\   (Optional[ResponsePromptParam] | NotGivenr]   Optional[Reasoning] | NotGivenr^   @Optional[Literal['auto', 'default', 'flex', 'scale']] | NotGivenr_   r`   #Optional[Literal[False]] | NotGivenra   Optional[float] | NotGivenrb   "ResponseTextConfigParam | NotGivenrc   ,response_create_params.ToolChoice | NotGivenrd   Iterable[ToolParam] | NotGivenre   rf   0Optional[Literal['auto', 'disabled']] | NotGivenrg   str | NotGivenrh   Headers | Noneri   Query | Nonerj   Body | Nonerk   'float | httpx.Timeout | None | NotGivenr0   c                C     dS a$  Creates a model response.

        Provide
        [text](https://platform.openai.com/docs/guides/text) or
        [image](https://platform.openai.com/docs/guides/images) inputs to generate
        [text](https://platform.openai.com/docs/guides/text) or
        [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
        the model call your own
        [custom code](https://platform.openai.com/docs/guides/function-calling) or use
        built-in [tools](https://platform.openai.com/docs/guides/tools) like
        [web search](https://platform.openai.com/docs/guides/tools-web-search) or
        [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
        your own data as input for the model's response.

        Args:
          input: Text, image, or file inputs to the model, used to generate a response.

              Learn more:

              - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
              - [Image inputs](https://platform.openai.com/docs/guides/images)
              - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
              - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
              - [Function calling](https://platform.openai.com/docs/guides/function-calling)

          model: Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
              wide range of models with different capabilities, performance characteristics,
              and price points. Refer to the
              [model guide](https://platform.openai.com/docs/models) to browse and compare
              available models.

          background: Whether to run the model response in the background.
              [Learn more](https://platform.openai.com/docs/guides/background).

          include: Specify additional output data to include in the model response. Currently
              supported values are:

              - `file_search_call.results`: Include the search results of the file search tool
                call.
              - `message.input_image.image_url`: Include image urls from the input message.
              - `computer_call_output.output.image_url`: Include image urls from the computer
                call output.
              - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
                tokens in reasoning item outputs. This enables reasoning items to be used in
                multi-turn conversations when using the Responses API statelessly (like when
                the `store` parameter is set to `false`, or when an organization is enrolled
                in the zero data retention program).
              - `code_interpreter_call.outputs`: Includes the outputs of python code execution
                in code interpreter tool call items.

          instructions: A system (or developer) message inserted into the model's context.

              When using along with `previous_response_id`, the instructions from a previous
              response will not be carried over to the next response. This makes it simple to
              swap out system (or developer) messages in new responses.

          max_output_tokens: An upper bound for the number of tokens that can be generated for a response,
              including visible output tokens and
              [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).

          metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
              for storing additional information about the object in a structured format, and
              querying for objects via API or the dashboard.

              Keys are strings with a maximum length of 64 characters. Values are strings with
              a maximum length of 512 characters.

          parallel_tool_calls: Whether to allow the model to run tool calls in parallel.

          previous_response_id: The unique ID of the previous response to the model. Use this to create
              multi-turn conversations. Learn more about
              [conversation state](https://platform.openai.com/docs/guides/conversation-state).

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

          reasoning: **o-series models only**

              Configuration options for
              [reasoning models](https://platform.openai.com/docs/guides/reasoning).

          service_tier: Specifies the latency tier to use for processing the request. This parameter is
              relevant for customers subscribed to the scale tier service:

              - If set to 'auto', and the Project is Scale tier enabled, the system will
                utilize scale tier credits until they are exhausted.
              - If set to 'auto', and the Project is not Scale tier enabled, the request will
                be processed using the default service tier with a lower uptime SLA and no
                latency guarantee.
              - If set to 'default', the request will be processed using the default service
                tier with a lower uptime SLA and no latency guarantee.
              - If set to 'flex', the request will be processed with the Flex Processing
                service tier.
                [Learn more](https://platform.openai.com/docs/guides/flex-processing).
              - When not set, the default behavior is 'auto'.

              When this parameter is set, the response body will include the `service_tier`
              utilized.

          store: Whether to store the generated model response for later retrieval via API.

          stream: If set to true, the model response data will be streamed to the client as it is
              generated using
              [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
              See the
              [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
              for more information.

          temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
              make the output more random, while lower values like 0.2 will make it more
              focused and deterministic. We generally recommend altering this or `top_p` but
              not both.

          text: Configuration options for a text response from the model. Can be plain text or
              structured JSON data. Learn more:

              - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
              - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)

          tool_choice: How the model should select which tool (or tools) to use when generating a
              response. See the `tools` parameter to see how to specify which tools the model
              can call.

          tools: An array of tools the model may call while generating a response. You can
              specify which tool to use by setting the `tool_choice` parameter.

              The two categories of tools you can provide the model are:

              - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
                capabilities, like
                [web search](https://platform.openai.com/docs/guides/tools-web-search) or
                [file search](https://platform.openai.com/docs/guides/tools-file-search).
                Learn more about
                [built-in tools](https://platform.openai.com/docs/guides/tools).
              - **Function calls (custom tools)**: Functions that are defined by you, enabling
                the model to call your own code. Learn more about
                [function calling](https://platform.openai.com/docs/guides/function-calling).

          top_p: An alternative to sampling with temperature, called nucleus sampling, where the
              model considers the results of the tokens with top_p probability mass. So 0.1
              means only the tokens comprising the top 10% probability mass are considered.

              We generally recommend altering this or `temperature` but not both.

          truncation: The truncation strategy to use for the model response.

              - `auto`: If the context of this response and previous ones exceeds the model's
                context window size, the model will truncate the response to fit the context
                window by dropping input items in the middle of the conversation.
              - `disabled` (default): If a model response will exceed the context window size
                for a model, the request will fail with a 400 error.

          user: A stable identifier for your end-users. Used to boost cache hit rates by better
              bucketing similar requests and to help OpenAI detect and prevent abuse.
              [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

          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
        NrG   rF   rl   rn   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rG   rG   rH   createK       EzResponses.createrU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   Literal[True]Stream[ResponseStreamEvent]c                C  r   a$  Creates a model response.

        Provide
        [text](https://platform.openai.com/docs/guides/text) or
        [image](https://platform.openai.com/docs/guides/images) inputs to generate
        [text](https://platform.openai.com/docs/guides/text) or
        [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
        the model call your own
        [custom code](https://platform.openai.com/docs/guides/function-calling) or use
        built-in [tools](https://platform.openai.com/docs/guides/tools) like
        [web search](https://platform.openai.com/docs/guides/tools-web-search) or
        [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
        your own data as input for the model's response.

        Args:
          input: Text, image, or file inputs to the model, used to generate a response.

              Learn more:

              - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
              - [Image inputs](https://platform.openai.com/docs/guides/images)
              - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
              - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
              - [Function calling](https://platform.openai.com/docs/guides/function-calling)

          model: Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
              wide range of models with different capabilities, performance characteristics,
              and price points. Refer to the
              [model guide](https://platform.openai.com/docs/models) to browse and compare
              available models.

          stream: If set to true, the model response data will be streamed to the client as it is
              generated using
              [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
              See the
              [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
              for more information.

          background: Whether to run the model response in the background.
              [Learn more](https://platform.openai.com/docs/guides/background).

          include: Specify additional output data to include in the model response. Currently
              supported values are:

              - `file_search_call.results`: Include the search results of the file search tool
                call.
              - `message.input_image.image_url`: Include image urls from the input message.
              - `computer_call_output.output.image_url`: Include image urls from the computer
                call output.
              - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
                tokens in reasoning item outputs. This enables reasoning items to be used in
                multi-turn conversations when using the Responses API statelessly (like when
                the `store` parameter is set to `false`, or when an organization is enrolled
                in the zero data retention program).
              - `code_interpreter_call.outputs`: Includes the outputs of python code execution
                in code interpreter tool call items.

          instructions: A system (or developer) message inserted into the model's context.

              When using along with `previous_response_id`, the instructions from a previous
              response will not be carried over to the next response. This makes it simple to
              swap out system (or developer) messages in new responses.

          max_output_tokens: An upper bound for the number of tokens that can be generated for a response,
              including visible output tokens and
              [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).

          metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
              for storing additional information about the object in a structured format, and
              querying for objects via API or the dashboard.

              Keys are strings with a maximum length of 64 characters. Values are strings with
              a maximum length of 512 characters.

          parallel_tool_calls: Whether to allow the model to run tool calls in parallel.

          previous_response_id: The unique ID of the previous response to the model. Use this to create
              multi-turn conversations. Learn more about
              [conversation state](https://platform.openai.com/docs/guides/conversation-state).

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

          reasoning: **o-series models only**

              Configuration options for
              [reasoning models](https://platform.openai.com/docs/guides/reasoning).

          service_tier: Specifies the latency tier to use for processing the request. This parameter is
              relevant for customers subscribed to the scale tier service:

              - If set to 'auto', and the Project is Scale tier enabled, the system will
                utilize scale tier credits until they are exhausted.
              - If set to 'auto', and the Project is not Scale tier enabled, the request will
                be processed using the default service tier with a lower uptime SLA and no
                latency guarantee.
              - If set to 'default', the request will be processed using the default service
                tier with a lower uptime SLA and no latency guarantee.
              - If set to 'flex', the request will be processed with the Flex Processing
                service tier.
                [Learn more](https://platform.openai.com/docs/guides/flex-processing).
              - When not set, the default behavior is 'auto'.

              When this parameter is set, the response body will include the `service_tier`
              utilized.

          store: Whether to store the generated model response for later retrieval via API.

          temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
              make the output more random, while lower values like 0.2 will make it more
              focused and deterministic. We generally recommend altering this or `top_p` but
              not both.

          text: Configuration options for a text response from the model. Can be plain text or
              structured JSON data. Learn more:

              - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
              - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)

          tool_choice: How the model should select which tool (or tools) to use when generating a
              response. See the `tools` parameter to see how to specify which tools the model
              can call.

          tools: An array of tools the model may call while generating a response. You can
              specify which tool to use by setting the `tool_choice` parameter.

              The two categories of tools you can provide the model are:

              - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
                capabilities, like
                [web search](https://platform.openai.com/docs/guides/tools-web-search) or
                [file search](https://platform.openai.com/docs/guides/tools-file-search).
                Learn more about
                [built-in tools](https://platform.openai.com/docs/guides/tools).
              - **Function calls (custom tools)**: Functions that are defined by you, enabling
                the model to call your own code. Learn more about
                [function calling](https://platform.openai.com/docs/guides/function-calling).

          top_p: An alternative to sampling with temperature, called nucleus sampling, where the
              model considers the results of the tokens with top_p probability mass. So 0.1
              means only the tokens comprising the top 10% probability mass are considered.

              We generally recommend altering this or `temperature` but not both.

          truncation: The truncation strategy to use for the model response.

              - `auto`: If the context of this response and previous ones exceeds the model's
                context window size, the model will truncate the response to fit the context
                window by dropping input items in the middle of the conversation.
              - `disabled` (default): If a model response will exceed the context window size
                for a model, the request will fail with a 400 error.

          user: A stable identifier for your end-users. Used to boost cache hit rates by better
              bucketing similar requests and to help OpenAI detect and prevent abuse.
              [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

          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
        NrG   rF   rl   rn   r`   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rG   rG   rH   r     r   bool&Response | Stream[ResponseStreamEvent]c                C  r   r   rG   r   rG   rG   rH   r     r   rl   rn   r`   3Optional[Literal[False]] | Literal[True] | NotGivenc             	   C  s   | j dti d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|||||d|rDtjntjt||||dt|pRdtt dS N
/responsesrl   rn   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   )rd   re   rf   rg   rh   ri   rj   rk   F)bodyoptionscast_tor`   
stream_cls)	_postr   r*   ResponseCreateParamsStreaming ResponseCreateParamsNonStreamingr)   r0   r%   r<   r   rG   rG   rH   r     sl    	
ݩtext_formatstarting_afterrd   rh   ri   rj   rk   response_idstrr   type[TextFormatT] | NotGivenr   int | NotGiven'Iterable[ParseableToolParam] | NotGiven"ResponseStreamManager[TextFormatT]c          	      C     d S rC   rG   	rF   r   r   r   rd   rh   ri   rj   rk   rG   rG   rH   r`        zResponses.streamrU   r   rd   rV   rW   rX   rY   rZ   r[   r]   r_   ra   rb   rc   re   rf   rg   rh   ri   rj   rk   Union[str, ChatModel]c                C  r   rC   rG   rF   rl   rn   rU   r   rd   rV   rW   rX   rY   rZ   r[   r]   r_   ra   rb   rc   re   rf   rg   rh   ri   rj   rk   rG   rG   rH   r`        r   rl   rn   rU   r   rd   rV   rW   rX   rY   rZ   r[   r]   r_   ra   rb   rc   re   rf   rg   r   rh   ri   rj   rk   )Union[str, ResponseInputParam] | NotGiven Union[str, ChatModel] | NotGivenc                  s  i d|d|dd|d|	d|
d|d|d	|d
|d|d|d|d|d|d|d|}dd |  D }tsFt|rUt|dkrUtdd| t|}t|dkrt|sgtdt|sotdt|r|swi }d|v rtdt||d< tj	fi d|d|d|dd|d|	d|
d|d|d
|ddd|d|d|d	|d|d|d|d|ddd  d!}t
|||d d"S tstd#t
 fd$d%||t|r|d"S d d"S )&Nrl   rn   rV   rW   rX   rY   rZ   r[   r]   r_   ra   rb   rc   re   rf   rg   rU   c                 S     g | ]
\}}t |r|qS rG   r   .0kvrG   rG   rH   
<listcomp>C      z$Responses.stream.<locals>.<listcomp>r   OCannot provide both response_id/starting_after can't be provided together with , 3input must be provided when creating a new response3model must be provided when creating a new responseformat1Cannot mix and match text.format with text_formatrd   r`   Trh   ri   rj   rk   r   input_toolsr   z7id must be provided when streaming an existing responsec                
     s   j dpg  tdS )NT)r   r`   rV   rh   ri   rj   r   rk   )retriever   rG   rj   rh   ri   rV   r   rF   rk   rG   rH   <lambda>|  s    z"Responses.stream.<locals>.<lambda>)itemsr   len
ValueErrorjoin_make_tools	TypeError_type_to_text_format_paramr
   r   r6   rF   r   rl   rn   rU   r   rd   rV   rW   rX   rY   rZ   r[   r]   r_   ra   rb   rc   re   rf   rg   r   rh   ri   rj   rk   new_response_argsnew_response_args_namesapi_requestrG   r   rH   r`     s   	
	


r   rd   rV   rW   rX   rY   rZ   r[   r]   r_   r`   ra   rb   rc   re   rf   rg   rh   ri   rj   rk   ParsedResponse[TextFormatT]c             
     s   t  r|si }d|v rtdt |d< td fdd}| jd	ti d
|d|d|d|d|d|d|	d|
d|d|d|d|d|d|dd|d|d|itjt|||||dt	t
tt  tdS )Nr   r   raw_responser0   rA   r   c                      t  | dS N)r   r   responser-   r   r   rd   rG   rH   parser  
   zResponses.parse.<locals>.parserr   rl   rn   rV   rW   rX   rY   rZ   r[   r]   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   post_parserr   r   r   r   r0   rA   r   r   r   r   r   r   r   r*   ResponseCreateParamsr)   r	   r   r5   r,   r0   rF   rl   rn   r   rd   rV   rW   rX   rY   rZ   r[   r]   r_   r`   ra   rb   rc   re   rf   rg   rh   ri   rj   rk   r   rG   r   rH   parse  sv   	
	zResponses.parserV   r   r`   rh   ri   rj   rk   #List[ResponseIncludable] | NotGivenLiteral[False] | NotGivenc          	      C  r   rC   rG   	rF   r   rV   r   r`   rh   ri   rj   rk   rG   rG   rH   r        zResponses.retrieverV   r   rh   ri   rj   rk   c          	      C  r   rC   rG   	rF   r   r`   rV   r   rh   ri   rj   rk   rG   rG   rH   r     r   c          	      C  r   rC   rG   r   rG   rG   rH   r     r   Fr`   rV   r   rh   ri   rj   rk   c          	      C  r   a  
        Retrieves a model response with the given ID.

        Args:
          include: Additional fields to include in the response. See the `include` parameter for
              Response creation above for more information.

          starting_after: The sequence number of the event after which to start streaming.

          stream: If set to true, the model response data will be streamed to the client as it is
              generated using
              [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
              See the
              [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
              for more information.

          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
        NrG   r   rG   rG   rH   r        'c          	      C  r   a  
        Retrieves a model response with the given ID.

        Args:
          stream: If set to true, the model response data will be streamed to the client as it is
              generated using
              [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
              See the
              [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
              for more information.

          include: Additional fields to include in the response. See the `include` parameter for
              Response creation above for more information.

          starting_after: The sequence number of the event after which to start streaming.

          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
        NrG   r   rG   rG   rH   r   8  r   c          	      C  r   r   rG   r   rG   rG   rH   r   a  r   )Literal[False] | Literal[True] | NotGivenc          	      C  sR   |s	t d|| jd| t||||t|||dtjdt|p#dtt dS N:Expected a non-empty value for `response_id` but received /responses/)rV   r   r`   )rh   ri   rj   rk   queryF)r   r   r`   r   )	r   _getr)   r   r+   ResponseRetrieveParamsr0   r%   r<   r   rG   rG   rH   r     s*   r   Nonec                C  sD   |s	t d|ddi|pi }| jd| t||||dtdS )_  
        Deletes a model response with the given ID.

        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
        r   Accept*/*r   r   r   r   r   _deleter)   r   rF   r   rh   ri   rj   rk   rG   rG   rH   delete  s   zResponses.deletec                C  s6   |s	t d|| jd| dt||||dtdS )  Cancels a model response with the given ID.

        Only responses created with the
        `background` parameter set to `true` can be cancelled.
        [Learn more](https://platform.openai.com/docs/guides/background).

        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
        r   r   /cancelr   r   r   r   r)   r0   r   rG   rG   rH   cancel  s   
zResponses.cancel)rA   r   )rA   rK   )rA   rP   4rl   rm   rn   r9   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r\   rt   r]   ru   r^   rv   r_   ro   r`   rw   ra   rx   rb   ry   rc   rz   rd   r{   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r0   )4rl   rm   rn   r9   r`   r   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r\   rt   r]   ru   r^   rv   r_   ro   ra   rx   rb   ry   rc   rz   rd   r{   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r   )4rl   rm   rn   r9   r`   r   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r\   rt   r]   ru   r^   rv   r_   ro   ra   rx   rb   ry   rc   rz   rd   r{   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r   )4rl   rm   rn   r9   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r\   rt   r]   ru   r^   rv   r_   ro   r`   r   ra   rx   rb   ry   rc   rz   rd   r{   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r   )r   r   r   r   r   r   rd   r   rh   r~   ri   r   rj   r   rk   r   rA   r   )0rl   rm   rn   r   rU   ro   r   r   rd   r   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r]   ru   r_   ro   ra   rx   rb   ry   rc   rz   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r   )4r   r}   rl   r   rn   r   rU   ro   r   r   rd   r   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r]   ru   r_   ro   ra   rx   rb   ry   rc   rz   re   rx   rf   r|   rg   r}   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r   0rl   rm   rn   r   r   r   rd   r   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r]   ru   r_   ro   r`   r   ra   rx   rb   ry   rc   rz   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r   r   r   rV   r   r   r   r`   r   rh   r~   ri   r   rj   r   rk   r   rA   r0   )r   r   r`   r   rV   r   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r   )r   r   r`   r   rV   r   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r   )r   r   rV   r   r   r   r`   r   rh   r~   ri   r   rj   r   rk   r   rA   r   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r0   __name__
__module____qualname__r   rI   rN   rR   r   r   r   r   r`   r   r   r   r   rG   rG   rG   rH   r>   3   s    	 F F FE!T((,+(c                   @  r@   )r?   rA   r    c                 C  rB   rC   )r    rD   rE   rG   rG   rH   rI     rJ   zAsyncResponses.input_itemsAsyncResponsesWithRawResponsec                 C  rL   rM   )r  rE   rG   rG   rH   rN     rO   z AsyncResponses.with_raw_response#AsyncResponsesWithStreamingResponsec                 C  rL   rQ   )r  rE   rG   rG   rH   rR     rS   z&AsyncResponses.with_streaming_responseNrT   rl   rm   rn   r9   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   r[   r\   rt   r]   ru   r^   rv   r_   r`   rw   ra   rx   rb   ry   rc   rz   rd   r{   re   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   r0   c                     dS r   rG   r   rG   rG   rH   r         EzAsyncResponses.creater   r    AsyncStream[ResponseStreamEvent]c                  r  r   rG   r   rG   rG   rH   r     r	  r   +Response | AsyncStream[ResponseStreamEvent]c                  r  r   rG   r   rG   rG   rH   r     r	  r   r   c             	     s   | j dti d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|||||d|rEtjntjI d H t||||dt|pVdtt dI d H S r   )	r   r   r*   r   r   r)   r0   r&   r<   r   rG   rG   rH   r   `  sn    	
r   r   r   r   r   r   r   r   'AsyncResponseStreamManager[TextFormatT]c          	      C  r   rC   rG   r   rG   rG   rH   r`     r   zAsyncResponses.streamr   r   c                C  r   rC   rG   r   rG   rG   rH   r`     r   r   r   r   c             	   C  s  i d|d|d|d|d|	d|
d|d|d	|d
|d|d|d|d|d|d|d|}dd |  D }t|sFt|rUt|dkrUtdd| t|}t|dkrt|trhtdt|sptdt|r|sxi }d|v rtdt	||d< | j
d%i d|d|ddd|d|d|d|	d|
d|d|d
|d|d|d|d	|d|d|d|d|d|d |d!|}t|||d d"S t|trtd#| j|d|pg ||||d$}t|||t|r|d"S d d"S )&Nrl   rn   rV   rW   rX   rY   rZ   r[   r]   r_   ra   rb   rc   re   rf   rg   rU   c                 S  r   rG   r   r   rG   rG   rH   r     r   z)AsyncResponses.stream.<locals>.<listcomp>r   r   r   r   r   r   r   r`   Trd   rh   ri   rj   rk   r   z@response_id must be provided when streaming an existing response)r`   rV   rh   ri   rj   rk   rG   )r   r   r   r   r   r   
isinstancer   r   r   r   r7   r   r   rG   rG   rH   r`     s   	


	

	
r   r   c             
     s   t  r|s	i }d|v rtdt |d< td fdd}| jd	ti d
|d|d|d|d|d|d|	d|
d|d|d|d|d|d|dd|d|d|itjt|||||dt	t
tt  tdI d H S )Nr   r   r   r0   rA   r   c                   r   r   r   r   r   rG   rH   r   z  r   z$AsyncResponses.parse.<locals>.parserr   rl   rn   rV   rW   rX   rY   rZ   r[   r]   r_   r`   ra   rb   rc   rd   re   rf   rg   r   r   r   r   r   rG   r   rH   r   R  sx   	
	zAsyncResponses.parser   r   r   c          	           d S rC   rG   r   rG   rG   rH   r        zAsyncResponses.retriever   c          	        r  rC   rG   r   rG   rG   rH   r     r  c          	        r  rC   rG   r   rG   rG   rH   r     r  Fr   c          	        r  r   rG   r   rG   rG   rH   r        'c          	        r  r   rG   r   rG   rG   rH   r     r  c          	        r  r   rG   r   rG   rG   rH   r   (	  r  r   c          	        s`   |s
t d|| jd| t||||t|||dtjI d H dt|p'dtt dI d H S r   )	r   r   r)   r   r+   r   r0   r&   r<   r   rG   rG   rH   r   Q	  s,   r   r   c                  sL   |s
t d|ddi|pi }| jd| t||||dtdI dH S )r   r   r   r   r   r   r   Nr   r   rG   rG   rH   r   v	  s   zAsyncResponses.deletec                  s>   |s
t d|| jd| dt||||dtdI dH S )r   r   r   r   r   r   Nr   r   rG   rG   rH   r   	  s   
zAsyncResponses.cancel)rA   r    )rA   r  )rA   r  r   )4rl   rm   rn   r9   r`   r   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r\   rt   r]   ru   r^   rv   r_   ro   ra   rx   rb   ry   rc   rz   rd   r{   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r
  )4rl   rm   rn   r9   r`   r   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r\   rt   r]   ru   r^   rv   r_   ro   ra   rx   rb   ry   rc   rz   rd   r{   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r  )4rl   rm   rn   r9   rU   ro   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r\   rt   r]   ru   r^   rv   r_   ro   r`   r   ra   rx   rb   ry   rc   rz   rd   r{   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r  )r   r   r   r   r   r   rd   r   rh   r~   ri   r   rj   r   rk   r   rA   r  )0rl   rm   rn   r   rU   ro   r   r   rd   r   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r]   ru   r_   ro   ra   rx   rb   ry   rc   rz   re   rx   rf   r|   rg   r}   rh   r~   ri   r   rj   r   rk   r   rA   r  )4r   r}   rl   r   rn   r   rU   ro   r   r   rd   r   rV   rp   rW   rq   rX   rr   rY   rs   rZ   ro   r[   rq   r]   ru   r_   ro   ra   rx   rb   ry   rc   rz   re   rx   rf   r|   rg   r}   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r  r   r   )r   r   r`   r   rV   r   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r
  )r   r   r`   r   rV   r   r   r   rh   r~   ri   r   rj   r   rk   r   rA   r  )r   r   rV   r   r   r   r`   r   rh   r~   ri   r   rj   r   rk   r   rA   r  r   r  r  rG   rG   rG   rH   r?     s   	 F F FE! T((,+(c                   @  $   e Zd ZdddZeddd	Zd
S )rK   	responsesr>   rA   r   c                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S rC   )
_responsesr   to_raw_response_wrapperr   r   r   r   r   rF   r  rG   rG   rH   __init__	      
z!ResponsesWithRawResponse.__init__r!   c                 C     t | jjS rC   )r!   r  rI   rE   rG   rG   rH   rI   	     z$ResponsesWithRawResponse.input_itemsNr  r>   rA   r   )rA   r!   r  r  r  r  r   rI   rG   rG   rG   rH   rK   	      
rK   c                   @  r  )r  r  r?   rA   r   c                 C  r  rC   )r  r   async_to_raw_response_wrapperr   r   r   r   r   r  rG   rG   rH   r  	  r  z&AsyncResponsesWithRawResponse.__init__r"   c                 C  r  rC   )r"   r  rI   rE   rG   rG   rH   rI   	  r  z)AsyncResponsesWithRawResponse.input_itemsNr  r?   rA   r   )rA   r"   r  rG   rG   rG   rH   r  	  r  r  c                   @  r  )rP   r  r>   rA   r   c                 C  :   || _ t|j| _t|j| _t|j| _t|j| _d S rC   )r  r   r   r   r   r   r  rG   rG   rH   r  	     
z'ResponsesWithStreamingResponse.__init__r#   c                 C  r  rC   )r#   r  rI   rE   rG   rG   rH   rI    
  r  z*ResponsesWithStreamingResponse.input_itemsNr  )rA   r#   r  rG   rG   rG   rH   rP   	      
rP   c                   @  r  )r  r  r?   rA   r   c                 C  r   rC   )r  r   r   r   r   r   r  rG   rG   rH   r  
  r!  z,AsyncResponsesWithStreamingResponse.__init__r$   c                 C  r  rC   )r$   r  rI   rE   rG   rG   rH   rI   
  r  z/AsyncResponsesWithStreamingResponse.input_itemsNr  )rA   r$   r  rG   rG   rG   rH   r  
  r"  r  rd   r   rA   List[ToolParam] | NotGivenc              	   C  s   t | stS g }| D ]M}|d dkr|| q
d|vr"|| q
tt|d }t|ts2tdd|v s8J td|d |	d|d |	dpJdd	|j
}||  q
|S )
NtypefunctionzcExpected Chat Completions function tool shape to be created using `openai.pydantic_function_tool()`
parametersnamedescriptionstrictF)r$  r'  r(  r&  r)  )r   r   appendr	   r   r  r'   	Exceptionr(   getrn   )rd   converted_toolstoolr%  new_toolrG   rG   rH   r   
  s6   


r   )rd   r   rA   r#  )a
__future__r   typingr   r   r   r   r   r   r	   	functoolsr
   typing_extensionsr   r   httpx r   _typesr   r   r   r   r   r   _utilsr   r   r   r   _compatr   	_resourcer   r   	_responser   r   rI   r   r    r!   r"   r#   r$   
_streamingr%   r&   
lib._toolsr'   r(   _base_clientr)   types.responsesr*   r+   lib._parsing._responsesr,   r-   r.   r   types.shared.chat_modelr/   types.responses.responser0   types.responses.tool_paramr1   r2   types.shared_params.metadatar3   types.shared_params.reasoningr4   types.responses.parsed_responser5   "lib.streaming.responses._responsesr6   r7   #types.responses.response_includabler8   #types.shared_params.responses_modelr9   $types.responses.response_input_paramr:   %types.responses.response_prompt_paramr;   %types.responses.response_stream_eventr<   *types.responses.response_text_config_paramr=   __all__r>   r?   rK   r  rP   r  r   rG   rG   rG   rH   <module>   sp   $           L         P