o
    ?HhWU                    @  s:  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!gZWG d"d  d e!ZXG d#d! d!e"ZYG d$d% d%ZZG d&d' d'Z[G d(d) d)Z\G d*d+ d+Z]d2d0d1Z^dS )3    )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)ResponseStreamEvent)ResponseTextConfigParam	ResponsesAsyncResponsesc                   @    e Zd ZedYddZedZddZed[d	d
Zeeeeeeeeeeeeeeeeedddedd\d7d8Z	eeeeeeeeeeeeeeeeddded9d]d<d8Z	eeeeeeeeeeeeeeeeddded9d^d?d8Z	e
ddgg d@eeeeeeeeeeeeeeeedddedd_dBd8Z	eeeeeeeeeeeeeeeedddedCd`dIdJZeeeeeeeeeeeeeeeeedddedKdadMdNZedddedOdbdSdTZdddedUdcdWdXZdS )dr=   returnr   c                 C  
   t | jS N)r   _clientself rF   d/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/openai/resources/responses/responses.pyinput_items8      
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
        )rJ   rD   rF   rF   rG   with_raw_response<      zResponses.with_raw_responseResponsesWithStreamingResponsec                 C  rK   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
        )rO   rD   rF   rF   rG   with_streaming_responseF      z!Responses.with_streaming_responseNincludeinstructionsmax_output_tokensmetadataparallel_tool_callsprevious_response_id	reasoningstorestreamtemperaturetexttool_choicetoolstop_p
truncationuserextra_headersextra_query
extra_bodytimeoutinputUnion[str, ResponseInputParam]modelr9   rT   -Optional[List[ResponseIncludable]] | NotGivenrU   Optional[str] | NotGivenrV   Optional[int] | NotGivenrW   Optional[Metadata] | NotGivenrX   Optional[bool] | NotGivenrY   rZ   Optional[Reasoning] | NotGivenr[   r\   #Optional[Literal[False]] | NotGivenr]   Optional[float] | NotGivenr^   "ResponseTextConfigParam | NotGivenr_   ,response_create_params.ToolChoice | NotGivenr`   Iterable[ToolParam] | NotGivenra   rb   0Optional[Literal['auto', 'disabled']] | NotGivenrc   str | NotGivenrd   Headers | Nonere   Query | Nonerf   Body | Nonerg   '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 `o1`. 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.

          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.

          instructions: Inserts a system (or developer) message as the first item in 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).

          reasoning: **o-series models only**

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

          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 unique identifier representing your end-user, which can help OpenAI to monitor
              and detect 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
        NrF   rE   rh   rj   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rF   rF   rG   createO       $zResponses.createrT   rU   rV   rW   rX   rY   rZ   r[   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   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 `o1`. 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.

          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.

          instructions: Inserts a system (or developer) message as the first item in 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).

          reasoning: **o-series models only**

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

          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 unique identifier representing your end-user, which can help OpenAI to monitor
              and detect 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
        NrF   rE   rh   rj   r\   rT   rU   rV   rW   rX   rY   rZ   r[   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rF   rF   rG   r      r   bool&Response | Stream[ResponseStreamEvent]c                C  r|   r   rF   r   rF   rF   rG   r     r   rh   rj   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|itjt||||dt|pJdtt dS N
/responsesrh   rj   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   F)bodyoptionscast_tor\   
stream_cls)_postr   r*   ResponseCreateParamsr)   r0   r%   r;   r~   rF   rF   rG   r   >  sb   	
text_formatr`   rT   rU   rV   rW   rX   rY   rZ   r[   r]   r^   r_   ra   rb   rc   rd   re   rf   rg   Union[str, ChatModel]r   type[TextFormatT] | NotGiven'Iterable[ParseableToolParam] | NotGiven"ResponseStreamManager[TextFormatT]c                C  s   t |r|si }d|v rtdt||d< t|}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|}t|||dS )Nformat1Cannot mix and match text.format with text_formatrh   rj   r`   rT   rU   rV   rW   rX   rY   r[   r\   Tr]   r^   r_   rZ   ra   rb   rc   rd   re   rf   rg   r   input_tools)r   	TypeError_type_to_text_format_param_make_toolsr
   r   r6   rE   rh   rj   r   r`   rT   rU   rV   rW   rX   rY   rZ   r[   r]   r^   r_   ra   rb   rc   rd   re   rf   rg   api_requestrF   rF   rG   r\   |  sv   	
zResponses.streamr   r`   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   ra   rb   rc   rd   re   rf   rg   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   r@   r   c                      t  | dS N)r   r   responser-   r   r   r`   rF   rG   parser  
   zResponses.parse.<locals>.parserr   rh   rj   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   post_parserr   r   r   r   r0   r@   r   r   r   r   r   r   r   r*   r   r)   r	   r   r5   r,   r0   rE   rh   rj   r   r`   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   ra   rb   rc   rd   re   rf   rg   r   rF   r   rG   parse  sv   	
	zResponses.parserT   rd   re   rf   rg   response_idstr#List[ResponseIncludable] | NotGivenc             
   C  sB   |s	t d|| jd| t||||td|itjdtdS )  
        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.

          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
        :Expected a non-empty value for `response_id` but received /responses/rT   rd   re   rf   rg   queryr   r   )
ValueError_getr)   r   r+   ResponseRetrieveParamsr0   rE   r   rT   rd   re   rf   rg   rF   rF   rG   retrieve  s   zResponses.retriever   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   _deleter)   r   rE   r   rd   re   rf   rg   rF   rF   rG   delete@  s   zResponses.delete)r@   r   )r@   rJ   )r@   rO   .rh   ri   rj   r9   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r\   rq   r]   rr   r^   rs   r_   rt   r`   ru   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r0   ).rh   ri   rj   r9   r\   r   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r]   rr   r^   rs   r_   rt   r`   ru   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   ).rh   ri   rj   r9   r\   r   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r]   rr   r^   rs   r_   rt   r`   ru   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   ).rh   ri   rj   r9   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r\   r   r]   rr   r^   rs   r_   rt   r`   ru   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   ).rh   ri   rj   r   r   r   r`   r   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r]   rr   r^   rs   r_   rt   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   0rh   ri   rj   r   r   r   r`   r   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r\   r   r]   rr   r^   rs   r_   rt   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   r   r   rT   r   rd   rx   re   ry   rf   rz   rg   r{   r@   r0   r   r   rd   rx   re   ry   rf   rz   rg   r{   r@   r   __name__
__module____qualname__r   rH   rM   rQ   r   r   r   r   r\   r   r   r   rF   rF   rF   rG   r=   7   s,   	 % % %BLX/c                   @  r?   )dr>   r@   r    c                 C  rA   rB   )r    rC   rD   rF   rF   rG   rH   d  rI   zAsyncResponses.input_itemsAsyncResponsesWithRawResponsec                 C  rK   rL   )r   rD   rF   rF   rG   rM   h  rN   z AsyncResponses.with_raw_response#AsyncResponsesWithStreamingResponsec                 C  rK   rP   )r   rD   rF   rF   rG   rQ   r  rR   z&AsyncResponses.with_streaming_responseNrS   rh   ri   rj   r9   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rZ   rp   r[   r\   rq   r]   rr   r^   rs   r_   rt   r`   ru   ra   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r0   c                     dS r}   rF   r~   rF   rF   rG   r   {      $zAsyncResponses.creater   r    AsyncStream[ResponseStreamEvent]c                  r   r   rF   r   rF   rF   rG   r      r   r   +Response | AsyncStream[ResponseStreamEvent]c                  r   r   rF   r   rF   rF   rG   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|itjI d H t||||dt|pNdtt dI d H S r   )r   r   r*   r   r)   r0   r&   r;   r~   rF   rF   rG   r   j  sd   	
r   r   r   r   r   'AsyncResponseStreamManager[TextFormatT]c                C  s   t |r|si }d|v rtdt||d< t|}| 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S )Nr   r   rh   rj   r`   rT   rU   rV   rW   rX   rY   r[   r\   Tr]   r^   r_   rZ   ra   rb   rc   rd   re   rf   rg   r   rF   )r   r   r   r   r   r7   r   rF   rF   rG   r\     sr   
	
zAsyncResponses.streamr   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   r@   r   c                   r   r   r   r   r   rF   rG   r     r   z$AsyncResponses.parse.<locals>.parserr   rh   rj   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   r   r   r   r   r   rF   r   rG   r     sx   	
	zAsyncResponses.parser   r   r   r   c             
     sP   |s
t d|| jd| t||||td|itjI dH dtdI dH S )r   r   r   rT   Nr   r   )r   r   r)   r   r+   r   r0   r   rF   rF   rG   r   B  s    
	zAsyncResponses.retriever   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   rF   rF   rG   r   m  s   zAsyncResponses.delete)r@   r    )r@   r   )r@   r   r   ).rh   ri   rj   r9   r\   r   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r]   rr   r^   rs   r_   rt   r`   ru   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   ).rh   ri   rj   r9   r\   r   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r]   rr   r^   rs   r_   rt   r`   ru   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   ).rh   ri   rj   r9   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r\   r   r]   rr   r^   rs   r_   rt   r`   ru   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   ).rh   ri   rj   r   r   r   r`   r   rT   rk   rU   rl   rV   rm   rW   rn   rX   ro   rY   rl   rZ   rp   r[   ro   r]   rr   r^   rs   r_   rt   ra   rr   rb   rv   rc   rw   rd   rx   re   ry   rf   rz   rg   r{   r@   r   r   r   r   r   rF   rF   rF   rG   r>   c  s,   	 % % %BKX1c                   @  $   e Zd ZdddZeddd	Zd
S )rJ   	responsesr=   r@   r   c                 C  4   || _ t|j| _t|j| _t|j| _d S rB   )
_responsesr   to_raw_response_wrapperr   r   r   rE   r   rF   rF   rG   __init__     
z!ResponsesWithRawResponse.__init__r!   c                 C     t | jjS rB   )r!   r   rH   rD   rF   rF   rG   rH        z$ResponsesWithRawResponse.input_itemsNr   r=   r@   r   )r@   r!   r   r   r   r   r   rH   rF   rF   rF   rG   rJ         
rJ   c                   @  r   )r   r   r>   r@   r   c                 C  r   rB   )r   r   async_to_raw_response_wrapperr   r   r   r   rF   rF   rG   r     r   z&AsyncResponsesWithRawResponse.__init__r"   c                 C  r   rB   )r"   r   rH   rD   rF   rF   rG   rH     r   z)AsyncResponsesWithRawResponse.input_itemsNr   r>   r@   r   )r@   r"   r   rF   rF   rF   rG   r     r   r   c                   @  r   )rO   r   r=   r@   r   c                 C  .   || _ t|j| _t|j| _t|j| _d S rB   )r   r   r   r   r   r   rF   rF   rG   r        
z'ResponsesWithStreamingResponse.__init__r#   c                 C  r   rB   )r#   r   rH   rD   rF   rF   rG   rH     r   z*ResponsesWithStreamingResponse.input_itemsNr   )r@   r#   r   rF   rF   rF   rG   rO     r   rO   c                   @  r   )r   r   r>   r@   r   c                 C  r   rB   )r   r   r   r   r   r   rF   rF   rG   r     r   z,AsyncResponsesWithStreamingResponse.__init__r$   c                 C  r   rB   )r$   r   rH   rD   rF   rF   rG   rH     r   z/AsyncResponsesWithStreamingResponse.input_itemsNr   )r@   r$   r   rF   rF   rF   rG   r     r   r   r`   r   r@   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   
isinstancer'   	Exceptionr(   getrj   )r`   converted_toolstoolr   new_toolrF   rF   rG   r     s6   


r   )r`   r   r@   r   )_
__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   rH   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_stream_eventr;   *types.responses.response_text_config_paramr<   __all__r=   r>   rJ   r   rO   r   r   rF   rF   rF   rG   <module>   sb   $        2      3