
    _jmm                      % S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
JrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJrJr  S SKrS SKJr  S	S
KJr  S	SK J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)  S	SK*J+r+J,r,J-r-J.r.J/r/  S	SK0J1r1  S	SK2J3r3  S	SK4J5r5J6r6  S	SK7J8r8J9r9  SSK:J;r;J<r<J=r=J>r>J?r?J@r@  S	SKAJBrBJCrC  S	SKDJErEJFrF  SSKGJHrHJIrIJJrJJKrKJLrLJMrM  S	SKNJOrOJPrP  S	SKQJRrR  S	SKSJTrTJUrU  S	SKVJWrW  S	SKXJYrYJZrZJ[r[J\r\  S	SK]J^r^J_r_J`ra  S	SKbJcrc  S	SKdJereJfrf  S	SKgJhrh  S	SKiJjrjJkrkJlrl  S	S KmJnrn  S	S!KoJprp  S	S"KqJrrrJsrs  S	S#KtJuru  S	S$KvJwrw  S	S%KxJyry  S	S&KzJ{r{  S	S'K|J}r}  S	S(K~Jr  S	S)KJr  S	S*KJr  S	S+KJr  S	S,KJr  S	S-KJr  S	S.KJr  S	S/KJr  \
(       a  S S0KJr  S S0KJr  S	S1KJrJr  S2S3/r\GR.                  " \5      rS4\S5'    " S6 S2\55      r " S7 S3\65      r " S8 S95      r " S: S;5      r " S< S=5      r " S> S?5      rSQS@ jr " SA SB5      r " SC SD5      r " SE SF5      r " SG SH5      r " SI SJ5      r " SK SL\5      r " SM SN5      r " SO SP\5      rg)R    )annotationsN)copy)TracebackType)TYPE_CHECKINGAnyListTypeUnionCallableIterableIteratorOptional	AwaitableAsyncIteratorcast)partial)Literaloverload)	BaseModel   )_legacy_response)		NOT_GIVENBodyOmitQueryHeadersNoneTypeNotGivenomit	not_given)is_givenpath_templatemaybe_transformstrip_not_givenasync_maybe_transform)cached_property)construct_type_unchecked)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper   )
InputItemsAsyncInputItemsInputItemsWithRawResponseAsyncInputItemsWithRawResponseInputItemsWithStreamingResponse$AsyncInputItemsWithStreamingResponse)StreamAsyncStream)PydanticFunctionToolResponsesPydanticFunctionTool)InputTokensAsyncInputTokensInputTokensWithRawResponseAsyncInputTokensWithRawResponse InputTokensWithStreamingResponse%AsyncInputTokensWithStreamingResponse)OpenAIErrorWebSocketConnectionClosedError)	SendQueue)_merge_mappingsmake_request_options)EventHandlerRegistry)response_create_paramsresponse_compact_paramsresponse_retrieve_paramsresponses_client_event_param)TextFormatTparse_responsetype_to_text_format_param)Response)	ToolParamParseableToolParam)Metadata)ReconnectingEventReconnectingOverridesis_recoverable_close)	Reasoning)ParsedResponse)ResponseStreamManagerAsyncResponseStreamManager)CompactedResponse)WebSocketConnectionOptions)ResponseIncludable)ResponsesModel)ResponseErrorEvent)ResponseInputParam)ResponsePromptParam)ResponseStreamEvent)ResponsesClientEvent)ResponsesServerEvent)ResponseInputItemParam)ResponseTextConfigParam)ResponsesClientEventParam)ClientConnection)OpenAIAsyncOpenAI	ResponsesAsyncResponseszlogging.Loggerlogc            $      	   \ rS rSr\S,S j5       r\S-S j5       r\S.S j5       r\S/S j5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.!                                                                   S0S jj5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S	.                                                                    S1S
 jj5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S	.                                                                    S2S jj5       r\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.!                                                                   S3S jjr\	\
\
\
SSS\S.                 S4S jj5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.                                                                   S5S jj5       r\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.#                                                                       S6S jjr\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.#                                                                       S7S jjr\	\
\
\
\
SSS\S.                   S8S jj5       r\	\
\
SSS\S.                 S9S jj5       r\	\
\
SSS\S.                 S:S jj5       r\	S\
\
SSS\S.                 S:S jj5       r\	\
\
\
SSS\S.                   S;S jj5       r\	\
\
\
SSS\S.                   S<S jj5       r\
\
\
\
SSS\S.                   S=S  jjrSSS\S!.           S>S" jjrSSS\S!.           S?S# jjr\
\
\
\
\
SSS\S$.	                     S@S% jjr0 0 0 SS&S'S(S)4                 SAS* jjrS+rg)Bre   g   c                ,    [        U R                  5      $ N)r-   _clientselfs    Y/home/rurouni/.local/lib/python3.13/site-packages/openai/resources/responses/responses.pyinput_itemsResponses.input_itemsh   s    $,,''    c                ,    [        U R                  5      $ rk   )r7   rl   rm   s    ro   input_tokensResponses.input_tokensl   s    4<<((rr   c                    [        U 5      $ z
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
)ResponsesWithRawResponserm   s    ro   with_raw_responseResponses.with_raw_responsep   s     (--rr   c                    [        U 5      $ 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
)ResponsesWithStreamingResponserm   s    ro   with_streaming_response!Responses.with_streaming_responsez   s     .d33rr   N!
backgroundcontext_managementconversationincludeinputinstructionsmax_output_tokensmax_tool_callsmetadatamodelparallel_tool_callsprevious_response_idpromptprompt_cache_keyprompt_cache_retention	reasoningsafety_identifierservice_tierstorestreamstream_optionstemperaturetexttool_choicetoolstop_logprobstop_p
truncationuserextra_headersextra_query
extra_bodytimeoutc       !            g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:
  background: Whether to run the model response in the background.
      [Learn more](https://platform.openai.com/docs/guides/background).

  context_management: Context management configuration for this request.

  conversation: The conversation that this response belongs to. Items from this conversation are
      prepended to `input_items` for this response request. Input items and output
      items from this response are automatically added to this conversation after this
      response completes.

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

      - `web_search_call.action.sources`: Include the sources of the web search tool
        call.
      - `code_interpreter_call.outputs`: Includes the outputs of python code execution
        in code interpreter tool call items.
      - `computer_call_output.output.image_url`: Include image urls from the computer
        call output.
      - `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.
      - `message.output_text.logprobs`: Include logprobs with assistant messages.
      - `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).

  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)

  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).

  max_tool_calls: The maximum number of total calls to built-in tools that can be processed in a
      response. This maximum number applies across all built-in tool calls, not per
      individual tool. Any further attempts to call a tool by the model will be
      ignored.

  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.

  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.

  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).
      Cannot be used in conjunction with `conversation`.

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

  prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize your cache
      hit rates. Replaces the `user` field.
      [Learn more](https://platform.openai.com/docs/guides/prompt-caching).

  prompt_cache_retention: The retention policy for the prompt cache. Set to `24h` to enable extended
      prompt caching, which keeps cached prefixes active for longer, up to a maximum
      of 24 hours.
      [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).

  reasoning: **gpt-5 and o-series models only**

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

  safety_identifier: A stable identifier used to help detect users of your application that may be
      violating OpenAI's usage policies. The IDs should be a string that uniquely
      identifies each user, with a maximum length of 64 characters. We recommend
      hashing their username or email address, in order to avoid sending us any
      identifying information.
      [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).

  service_tier: Specifies the processing type used for serving the request.

      - If set to 'auto', then the request will be processed with the service tier
        configured in the Project settings. Unless otherwise configured, the Project
        will use 'default'.
      - If set to 'default', then the request will be processed with the standard
        pricing and performance for the selected model.
      - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
        '[priority](https://openai.com/api-priority-processing/)', then the request
        will be processed with the corresponding service tier.
      - When not set, the default behavior is 'auto'.

      When the `service_tier` parameter is set, the response body will include the
      `service_tier` value based on the processing mode actually used to serve the
      request. This response value may be different from the value set in the
      parameter.

  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.

  stream_options: Options for streaming responses. Only set this when you set `stream: true`.

  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.

      We support the following categories of tools:

      - **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).
      - **MCP Tools**: Integrations with third-party systems via custom MCP servers or
        predefined connectors such as Google Drive and SharePoint. Learn more about
        [MCP Tools](https://platform.openai.com/docs/guides/tools-connectors-mcp).
      - **Function calls (custom tools)**: Functions that are defined by you, enabling
        the model to call your own code with strongly typed arguments and outputs.
        Learn more about
        [function calling](https://platform.openai.com/docs/guides/function-calling).
        You can also use custom tools to call your own code.

  top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens
      to return at each token position, each with an associated log probability. In
      some cases, the number of returned tokens may be fewer than requested.

  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 input to this Response exceeds the model's context window size,
        the model will truncate the response to fit the context window by dropping
        items from the beginning of the conversation.
      - `disabled` (default): If the input size will exceed the context window size
        for a model, the request will fail with a 400 error.

  user: This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
      `prompt_cache_key` instead to maintain caching optimizations. 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#safety-identifiers).

  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
N "rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s"                                     ro   createResponses.create       p 	rr    r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c       !            g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:
  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).

  context_management: Context management configuration for this request.

  conversation: The conversation that this response belongs to. Items from this conversation are
      prepended to `input_items` for this response request. Input items and output
      items from this response are automatically added to this conversation after this
      response completes.

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

      - `web_search_call.action.sources`: Include the sources of the web search tool
        call.
      - `code_interpreter_call.outputs`: Includes the outputs of python code execution
        in code interpreter tool call items.
      - `computer_call_output.output.image_url`: Include image urls from the computer
        call output.
      - `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.
      - `message.output_text.logprobs`: Include logprobs with assistant messages.
      - `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).

  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)

  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).

  max_tool_calls: The maximum number of total calls to built-in tools that can be processed in a
      response. This maximum number applies across all built-in tool calls, not per
      individual tool. Any further attempts to call a tool by the model will be
      ignored.

  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.

  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.

  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).
      Cannot be used in conjunction with `conversation`.

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

  prompt_cache_key: Used by OpenAI to cache responses for similar requests to optimize your cache
      hit rates. Replaces the `user` field.
      [Learn more](https://platform.openai.com/docs/guides/prompt-caching).

  prompt_cache_retention: The retention policy for the prompt cache. Set to `24h` to enable extended
      prompt caching, which keeps cached prefixes active for longer, up to a maximum
      of 24 hours.
      [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).

  reasoning: **gpt-5 and o-series models only**

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

  safety_identifier: A stable identifier used to help detect users of your application that may be
      violating OpenAI's usage policies. The IDs should be a string that uniquely
      identifies each user, with a maximum length of 64 characters. We recommend
      hashing their username or email address, in order to avoid sending us any
      identifying information.
      [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).

  service_tier: Specifies the processing type used for serving the request.

      - If set to 'auto', then the request will be processed with the service tier
        configured in the Project settings. Unless otherwise configured, the Project
        will use 'default'.
      - If set to 'default', then the request will be processed with the standard
        pricing and performance for the selected model.
      - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
        '[priority](https://openai.com/api-priority-processing/)', then the request
        will be processed with the corresponding service tier.
      - When not set, the default behavior is 'auto'.

      When the `service_tier` parameter is set, the response body will include the
      `service_tier` value based on the processing mode actually used to serve the
      request. This response value may be different from the value set in the
      parameter.

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

  stream_options: Options for streaming responses. Only set this when you set `stream: true`.

  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.

      We support the following categories of tools:

      - **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).
      - **MCP Tools**: Integrations with third-party systems via custom MCP servers or
        predefined connectors such as Google Drive and SharePoint. Learn more about
        [MCP Tools](https://platform.openai.com/docs/guides/tools-connectors-mcp).
      - **Function calls (custom tools)**: Functions that are defined by you, enabling
        the model to call your own code with strongly typed arguments and outputs.
        Learn more about
        [function calling](https://platform.openai.com/docs/guides/function-calling).
        You can also use custom tools to call your own code.

  top_logprobs: An integer between 0 and 20 specifying the maximum number of most likely tokens
      to return at each token position, each with an associated log probability. In
      some cases, the number of returned tokens may be fewer than requested.

  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 input to this Response exceeds the model's context window size,
        the model will truncate the response to fit the context window by dropping
        items from the beginning of the conversation.
      - `disabled` (default): If the input size will exceed the context window size
        for a model, the request will fail with a 400 error.

  user: This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
      `prompt_cache_key` instead to maintain caching optimizations. 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#safety-identifiers).

  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
Nr   "rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s"                                     ro   r   r   }  r   rr   c       !            gr   r   r   s"                                     ro   r   r   w  r   rr   c       !        V   U R                  S[        0 SU_SU_SU_SU_SU_SU_SU_S	U_S
U	_SU
_SU_SU_SU_SU_SU_SU_SU_UUUUUUUUUUUUS.EU(       a  [        R                  O[        R                  5      [        UUU U!SS0S9[        U=(       d    S[        [           S9$ N
/responsesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   bearer_authTr   r   r   r   securityF)bodyoptionscast_tor   
stream_cls)	_postr#   rC   ResponseCreateParamsStreaming ResponseCreateParamsNonStreamingrA   rJ   r3   r\   r   s"                                     ro   r   r   q  su   N zz  *(*< #L w	
 U #L (): %n  U *+> +,@ f '(8 -.D   !" ():#$ %1"$&4#. #."$0"", ;@  'DD+LLE#H )+'%'. ?U12_  0
 0	
rr   text_formatstarting_afterr   r   r   r   r   c                   g rk   r   	rn   response_idr   r   r   r   r   r   r   s	            ro   r   Responses.stream  s     .1rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c       !            g rk   r   "rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s"                                     ro   r   r     s    N .1rr   #r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c       #        Z  ^ ^^	^ ^!^"^# 0 SU_SU_SU_SU_ST	_SU
_SU_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SU_UUUUUUUUUUS.
En$U$R                  5        V%V&s/ s H  u  n%n&[        U&5      (       d  M  U%PM     n'n%n&[        T5      (       d  [        U5      (       a,  [        U'5      S:  a  [        SSR	                  U'5      -   5      e[        U5      n[        U'5      S:  a  [        U5      (       d  [        S5      e[        U5      (       d  [        S5      e[        U5      (       a3  U(       d  0 nSU;   a  [        S5      e[        U5      n[        U5      US'   [        T R                  40 SU_SU_SU_SU_SU_ST	_SU
_SU_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SS_SU_S U_S!U_SU_SU_SU_S"U_S#U_S$U_S%U_S&U_S'T _S(T!_S)T"_S*T#_6n([        U(XgS S+9$ [        T5      (       d  [        S,5      e[        U"U U!U	UU U#4S- jUU[        U5      (       a  US+9$ S S+9$ s  sn&n%f ).Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
r   r   r   r   r   r   r   r   r   r   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_formatr   r   r   r   Tr   r   r   r   r   r   r   r   r   r   r   r   r   input_toolsr   z7id must be provided when streaming an existing responsec                 J   > TR                  TST=(       d    / TTT [        TS9$ )NT)r   r   r   r   r   r   r   r   )retriever   )r   r   r   r   r   rn   r   s   ro   <lambda>"Responses.stream.<locals>.<lambda>  s/     +#Mr"/ +)#'# & 	rr   )itemsr!   len
ValueErrorjoin_make_tools	TypeErrorr   _type_to_text_format_paramr   r   rS   )rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   new_response_argskvnew_response_args_namesapi_requests)   ``       `                      ````     ro   r   r     s   R
U
U
 !"4
 L	

 w
 L
  !2
 n
 
 "#6
 #$8
 f
  0
 %&<
 
   !2!
" L#
$ ,&&($$7
: 2C1H1H1J"Z1JAhWXk11J"Z[!!Xn%=%=3G^C_bcCca))345  E"&'!+E?? !VWWE?? !VWW$$Dt##$WXXDz!;K!HX@G#A#A #A 	#A
 $6#A *#A  #A *#A #4#A  .#A "#A %8#A &:#A #A "2#A  (>!#A" ##A$  .%#A& '#A( ()#A* +#A, (-#A. $/#A0 #41#A2 *3#A4 *5#A6 7#A8 &9#A: ;#A< &=#A> ,?#A@ (A#AB &C#AD  E#AKJ )+quvvK(( !Z[[(	 	 (!19.1I1I~  PT G #[s   H'8H'#r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	verbosityr   r   r   r   c       #          ^^ [        T5      (       a3  U(       d  0 nSU;   a  [        S5      e[        U5      n[        T5      US'   [	        T5      mSUU4S jjn$U R                  S[        0 SU_SU_SU_SU_S	U_S
U_SU_SU	_SU
_SU_SU_SU_SU_SU_SU_SU_SU_UUUUUUUTUUUUUS.E[        R                  5      [        U U!U"U#U$SS0S9[        [        [        [              [        5      S9$ )Nr   r   c                   > [        TTU S9$ N)r   r   responserH   raw_responser   r   s    ro   parserResponses.parse.<locals>.parser      !!'% rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Tr   r   r   r   post_parserr   r   r   r   r   rJ   returnParsedResponse[TextFormatT]r!   r   r   r   r   r   r#   rC   ResponseCreateParamsrA   r   r	   rR   rG   rJ   %rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s%    `                        `          ro   parseResponses.parse  s   R K  4 STT:D7DDNE"	 	 zz  *(*< #L w	
 U #L (): %n  U *+> +,@ f '(8 -.D   !" ():#$ %1"$&4#. #."$0"", !*=@ ';;C"F )+'%"'. n[9:HE_  0
 0	
rr   r   include_obfuscationr   r   r   r   r   r   c                   g rk   r   
rn   r   r   r   r   r   r   r   r   r   s
             ro   r   Responses.retrieve  s     rr   r   r   r   r   r   r   c                   g rk   r   	rn   r   r   r   r   r   r   r   r   s	            ro   r   r     s     '*rr   c                   g rk   r   r   s	            ro   r   r   )  s     25rr   Fr   r   r   r   r   r   r   c                   g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.

  include_obfuscation: When true, stream obfuscation will be enabled. Stream obfuscation adds random
      characters to an `obfuscation` field on streaming delta events to normalize
      payload sizes as a mitigation to certain side-channel attacks. These obfuscation
      fields are included by default, but add a small amount of overhead to the data
      stream. You can set `include_obfuscation` to false to optimize for bandwidth if
      you trust the network links between your application and the OpenAI API.

  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
Nr   r   s	            ro   r   r   9  s    \ 	rr   r   r   r   r   r   r   r   c                   g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.

  include_obfuscation: When true, stream obfuscation will be enabled. Stream obfuscation adds random
      characters to an `obfuscation` field on streaming delta events to normalize
      payload sizes as a mitigation to certain side-channel attacks. These obfuscation
      fields are included by default, but add a small amount of overhead to the data
      stream. You can set `include_obfuscation` to false to optimize for bandwidth if
      you trust the network links between your application and the OpenAI API.

  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
Nr   
rn   r   r   r   r   r   r   r   r   r   s
             ro   r   r   i      ^ 	rr   c                   gr  r   r  s
             ro   r   r     r	  rr   c                   U(       d  [        SU< 35      eU R                  [        SUS9[        UUUU	[	        UUUUS.[
        R                  5      SS0S9[        U=(       d    S[        [           S	9$ 
N:Expected a non-empty value for `response_id` but received /responses/{response_id}r   )r   r   r   r   r   T)r   r   r   r   queryr   F)r   r   r   r   )
r   _getr"   rA   r#   rE   ResponseRetrieveParamsrJ   r3   r\   r   s
             ro   r   r     s     YZeYhijjyy4+N(+'%%#*/B*8"(	 -CC (.  ?U12)  
 	
rr   r   r   r   r   c                   U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  [        SUS9[        UUUUSS0S9[        S	9$ )
'  
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   Tr   r   r   r   _deleter"   rA   r   rn   r   r   r   r   r   s         ro   deleteResponses.delete  sr    . YZeYhijj!5B]-@bB||4+N(+'%'.   

 
	
rr   c                   U(       d  [        SU< 35      eU R                  [        SUS9[        UUUUSS0S9[        S9$ )  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  /responses/{response_id}/cancelr  r   Tr   r  r   r   r"   rA   rJ   r  s         ro   cancelResponses.cancel  s^    4 YZeYhijjzz;U(+'%'.   

 
	
rr   	r   r   r   r   r   r   r   r   r   c       
            U R                  S[        UUUUUUS.[        R                  5      [	        UUU	U
SS0S9[
        S9$ )  Compact a conversation.

Returns a compacted response object.

Learn when and how to compact long-running conversations in the
[conversation state guide](https://platform.openai.com/docs/guides/conversation-state#managing-the-context-window).
For ZDR-compatible compaction details, see
[Compaction (advanced)](https://platform.openai.com/docs/guides/conversation-state#compaction-advanced).

Args:
  model: Model ID used to generate the response, like `gpt-5` 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.

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

  instructions: A system (or developer) message inserted into the model's context. When used
      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.

  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).
      Cannot be used in conjunction with `conversation`.

  prompt_cache_key: A key to use when reading from or writing to the prompt cache.

  prompt_cache_retention: How long to retain a prompt cache entry created by this request.

  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
/responses/compactr   r   r   r   r   r   r   Tr   r   )r   r#   rD   ResponseCompactParamsrA   rU   rn   r   r   r   r   r   r   r   r   r   r   s              ro   compactResponses.compactA  sk    r zz  ""$0,@(8.D (==
 )+'%'. &)  
 	
rr            ?       @   c	                8    [        U R                  UUUUUUUUS9	$ zConnect to a persistent Responses API WebSocket.

Send `response.create` events and receive response stream events over the socket.
)	clientr   r   websocket_connection_optionson_reconnectingmax_retriesinitial_delay	max_delaymax_queue_size)ResponsesConnectionManagerrl   	rn   r   r   r4  r5  r6  r7  r8  r9  s	            ro   connectResponses.connect  s0     *<<#')E+#')

 
	
rr   r   )r   r-   )r   r7   )r   rx   )r   r}   Dr   Optional[bool] | Omitr   COptional[Iterable[response_create_params.ContextManagement]] | Omitr   4Optional[response_create_params.Conversation] | Omitr   )Optional[List[ResponseIncludable]] | Omitr   %Union[str, ResponseInputParam] | Omitr   Optional[str] | Omitr   Optional[int] | Omitr   rE  r   Optional[Metadata] | Omitr   ResponsesModel | Omitr   r?  r   rD  r   $Optional[ResponsePromptParam] | Omitr   
str | Omitr   ,Optional[Literal['in_memory', '24h']] | Omitr   Optional[Reasoning] | Omitr   rI  r   HOptional[Literal['auto', 'default', 'flex', 'scale', 'priority']] | Omitr   r?  r   zOptional[Literal[False]] | Omitr   5Optional[response_create_params.StreamOptions] | Omitr   Optional[float] | Omitr   ResponseTextConfigParam | Omitr   (response_create_params.ToolChoice | Omitr   Iterable[ToolParam] | Omitr   rE  r   rN  r   ,Optional[Literal['auto', 'disabled']] | Omitr   rI  r   Headers | Noner   Query | Noner   Body | Noner   'float | httpx.Timeout | None | NotGivenr   rJ   )Dr   Literal[True]r   r?  r   r@  r   rA  r   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rQ  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r   Stream[ResponseStreamEvent])Dr   boolr   r?  r   r@  r   rA  r   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rQ  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r   &Response | Stream[ResponseStreamEvent])Dr   r?  r   r@  r   rA  r   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   /Optional[Literal[False]] | Literal[True] | Omitr   rM  r   rN  r   rO  r   rP  r   rQ  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r   rZ  )r   strr   type[TextFormatT] | Omitr   
int | Omitr   #Iterable[ParseableToolParam] | Omitr   rS  r   rT  r   rU  r   rV  r   "ResponseStreamManager[TextFormatT])Dr   Union[str, ResponseInputParam]r   rX   r   r?  r   r@  r   r]  r   r_  r   rA  r   rB  r   rD  r   rE  r   rE  r   rF  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r   r`  )Hr   rI  r   rC  r   rG  r   r?  r   r@  r   r]  r   r_  r   rA  r   rB  r   rD  r   rE  r   rE  r   rF  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rE  r   rN  r   rR  r   rI  r   r^  r   rS  r   rT  r   rU  r   rV  r   r`  Hr   r]  r   r?  r   r@  r   rA  r   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   r[  r   rM  r   rN  r   rO  r   rP  r   r_  r   rE  r   rN  r   rR  r   rI  r   z1Optional[Literal['low', 'medium', 'high']] | Omitr   rS  r   rT  r   rU  r   rV  r   r   r   r\  r   List[ResponseIncludable] | Omitr   bool | Omitr   r^  r   zLiteral[False] | Omitr   rS  r   rT  r   rU  r   rV  r   rJ   )r   r\  r   rW  r   rd  r   r^  r   rS  r   rT  r   rU  r   rV  r   rX  )r   r\  r   rY  r   rd  r   r^  r   rS  r   rT  r   rU  r   rV  r   rZ  )r   r\  r   rW  r   rd  r   re  r   r^  r   rS  r   rT  r   rU  r   rV  r   rX  )r   r\  r   rY  r   rd  r   re  r   r^  r   rS  r   rT  r   rU  r   rV  r   rZ  )r   r\  r   rd  r   re  r   r^  r   %Literal[False] | Literal[True] | Omitr   rS  r   rT  r   rU  r   rV  r   rZ  r   r\  r   rS  r   rT  r   rU  r   rV  r   Noner   r\  r   rS  r   rT  r   rU  r   rV  r   rJ   r   a  Union[Literal['gpt-5.4', 'gpt-5.4-mini', 'gpt-5.4-nano', 'gpt-5.4-mini-2026-03-17', 'gpt-5.4-nano-2026-03-17', 'gpt-5.3-chat-latest', 'gpt-5.2', 'gpt-5.2-2025-12-11', 'gpt-5.2-chat-latest', 'gpt-5.2-pro', 'gpt-5.2-pro-2025-12-11', 'gpt-5.1', 'gpt-5.1-2025-11-13', 'gpt-5.1-codex', 'gpt-5.1-mini', 'gpt-5.1-chat-latest', 'gpt-5', 'gpt-5-mini', 'gpt-5-nano', 'gpt-5-2025-08-07', 'gpt-5-mini-2025-08-07', 'gpt-5-nano-2025-08-07', 'gpt-5-chat-latest', 'gpt-4.1', 'gpt-4.1-mini', 'gpt-4.1-nano', 'gpt-4.1-2025-04-14', 'gpt-4.1-mini-2025-04-14', 'gpt-4.1-nano-2025-04-14', 'o4-mini', 'o4-mini-2025-04-16', 'o3', 'o3-2025-04-16', 'o3-mini', 'o3-mini-2025-01-31', 'o1', 'o1-2024-12-17', 'o1-preview', 'o1-preview-2024-09-12', 'o1-mini', 'o1-mini-2024-09-12', 'gpt-4o', 'gpt-4o-2024-11-20', 'gpt-4o-2024-08-06', 'gpt-4o-2024-05-13', 'gpt-4o-audio-preview', 'gpt-4o-audio-preview-2024-10-01', 'gpt-4o-audio-preview-2024-12-17', 'gpt-4o-audio-preview-2025-06-03', 'gpt-4o-mini-audio-preview', 'gpt-4o-mini-audio-preview-2024-12-17', 'gpt-4o-search-preview', 'gpt-4o-mini-search-preview', 'gpt-4o-search-preview-2025-03-11', 'gpt-4o-mini-search-preview-2025-03-11', 'chatgpt-4o-latest', 'codex-mini-latest', 'gpt-4o-mini', 'gpt-4o-mini-2024-07-18', 'gpt-4-turbo', 'gpt-4-turbo-2024-04-09', 'gpt-4-0125-preview', 'gpt-4-turbo-preview', 'gpt-4-1106-preview', 'gpt-4-vision-preview', 'gpt-4', 'gpt-4-0314', 'gpt-4-0613', 'gpt-4-32k', 'gpt-4-32k-0314', 'gpt-4-32k-0613', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-0301', 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo-1106', 'gpt-3.5-turbo-0125', 'gpt-3.5-turbo-16k-0613', 'o1-pro', 'o1-pro-2025-03-19', 'o3-pro', 'o3-pro-2025-06-10', 'o3-deep-research', 'o3-deep-research-2025-06-26', 'o4-mini-deep-research', 'o4-mini-deep-research-2025-06-26', 'computer-use-preview', 'computer-use-preview-2025-03-11', 'gpt-5-codex', 'gpt-5-pro', 'gpt-5-pro-2025-10-06', 'gpt-5.1-codex-max'], str, None]r   z9Union[str, Iterable[ResponseInputItemParam], None] | Omitr   rD  r   rD  r   rD  r   rJ  r   rS  r   rT  r   rU  r   rV  r   rU   )r   r   r   r   r4  rV   r5  BCallable[[ReconnectingEvent], ReconnectingOverrides | None] | Noner6  intr7  floatr8  rm  r9  rl  r   r:  __name__
__module____qualname____firstlineno__r&   rp   rt   ry   r~   r   r   r    r   r   r   r   r   r  r"  r+  r<  __static_attributes__r   rr   ro   re   re   g   sn   ( ( ) ) . . 4 4  -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+26PT.2/3@D,0-1(,CG )-$("&;DKw *w `	w
 Kw ;w 5w +w 0w -w ,w %w 3w 3w 5w  %!w" !M#w$ .%w& &'w( _)w* %+w, 0-w. N/w0 ,1w2 -3w4 >5w6 *7w8 +9w: &;w< A=w> ?wD &EwF "GwH  IwJ 9KwL 
Mw wr 
 -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+PT.2/3@D,0-1(,CG )-$("&;DKw w *	w
 `w Kw ;w 5w +w 0w -w ,w %w 3w 3w  5!w" %#w$ !M%w& .'w( &)w* _+w, %-w. N/w0 ,1w2 -3w4 >5w6 *7w8 +9w: &;w< A=w> ?wD &EwF "GwH  IwJ 9KwL 
%Mw wr 
 -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+PT.2/3@D,0-1(,CG )-$("&;DKw w *	w
 `w Kw ;w 5w +w 0w -w ,w %w 3w 3w  5!w" %#w$ !M%w& .'w( &)w* _+w, %-w. N/w0 ,1w2 -3w4 >5w6 *7w8 +9w: &;w< A=w> ?wD &EwF "GwH  IwJ 9KwL 
0Mw wx -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+BFPT.2/3@D,0-1(,CG )-$("&;DKW
 *W
 `	W

 KW
 ;W
 5W
 +W
 0W
 -W
 ,W
 %W
 3W
 3W
 5W
  %!W
" !M#W
$ .%W
& &'W
( _)W
* %+W
, @-W
. N/W
0 ,1W
2 -3W
4 >5W
6 *7W
8 +9W
: &;W
< A=W
> ?W
D &EW
F "GW
H  IW
J 9KW
L 
0MW
r 
 15%)59(,$("&;D1 1 .	1
 #1 31 &1 "1  1 91 
,1 1  -1bf0459MQ=A-126/3.259597;'+OS04(,ae'+PT.2/3@D-1(,CG )-$("&;DK&1 .&1 	&1
 *&1 `&1 .&1 3&1 K&1 ;&1 +&1 0&1 -&1 ,&1 3&1  3!&1" 5#&1$ %%&1& !M'&1( .)&1* &+&1, _-&1. %/&10 N1&12 ,3&14 -5&16 >7&18 +9&1: &;&1< A=&1> ?&1D &E&1F "G&1H  I&1J 9K&1L 
,M&1 &1V #'7;'+,0bf0459MQ=A-126/3.259597;'+OS04(,ae'+PT.2/3@D-1(,CG%) )-$("&;DOW  W 5	W
 %W *W `W .W 3W KW ;W +W 0W -W ,W  3!W" 3#W$ 5%W& %'W( !M)W* .+W, &-W. _/W0 %1W2 N3W4 ,5W6 -7W8 >9W: +;W< &=W> A?W@ AWB #CWH &IWJ "KWL  MWN 9OWP 
,QWx 15,0bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+BFPT.2/3@D59-1(,CGGK )-$("&;DOk
 .k
 *	k

 `k
 Kk
 ;k
 5k
 +k
 0k
 -k
 ,k
 %k
 3k
 3k
  5!k
" %#k
$ !M%k
& .'k
( &)k
* _+k
, %-k
. @/k
0 N1k
2 ,3k
4 -5k
6 >7k
8 39k
: +;k
< &=k
> A?k
@ Ak
B ECk
H &Ik
J "Kk
L  Mk
N 9Ok
P 
%Qk
Z 
 48+/%)(, )-$("&;D 1	
 ) # & & "   9 
    48%) )-$("&;D** 	*
 1* #* &* "*  * 9* 
%* *  48%) )-$("&;D55 	5
 15 #5 &5 "5  5 95 
05 5 
 37%) )-$("&;D-- 	-
 1- #- &- "-  - 9- 
0- -^  48+/%) )-$("&;D.. 	.
 1. ). #. &. ".  . 9. 
%. .`  48+/%) )-$("&;D.. 	.
 1. ). #. &. ".  . 9. 
0. .h 48+/%)8< )-$("&;D&
&
 1	&

 )&
 #&
 6&
 &&
 "&
  &
 9&
 
0&
\ )-$("&;D$
$
 &$
 "$
  $
 9$
 
$
X )-$("&;D&
&
 &&
 "&
  &
 9&
 
&
Z LP-15915OS )-$("&;D_n
a
n
J IKn
L +Mn
N 3On
P /Qn
R !MSn
X &Yn
Z "[n
\  ]n
^ 9_n
` 
an
d  !#CE^b"'

 
 'A	

 \
 
 
 
 
 
$
 
rr   c            $      	   \ rS rSr\S,S j5       r\S-S j5       r\S.S j5       r\S/S j5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.!                                                                   S0S jj5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S	.                                                                    S1S
 jj5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S	.                                                                    S2S jj5       r\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.!                                                                   S3S jjr\	\
\
\
SSS\S.                 S4S jj5       r\	\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.                                                                   S5S jj5       r\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.#                                                                       S6S jjr\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
\
SSS\S.#                                                                       S7S jjr\	\
\
\
\
SSS\S.                   S8S jj5       r\	\
\
SSS\S.                 S9S jj5       r\	\
\
SSS\S.                 S:S jj5       r\	S\
\
SSS\S.                 S:S jj5       r\	\
\
\
SSS\S.                   S;S jj5       r\	\
\
\
SSS\S.                   S<S jj5       r\
\
\
\
SSS\S.                   S=S  jjrSSS\S!.           S>S" jjrSSS\S!.           S?S# jjr\
\
\
\
\
SSS\S$.	                     S@S% jjr0 0 0 SS&S'S(S)4                 SAS* jjrS+rg)Brf   i  c                ,    [        U R                  5      $ rk   )r.   rl   rm   s    ro   rp   AsyncResponses.input_items  s    t||,,rr   c                ,    [        U R                  5      $ rk   )r8   rl   rm   s    ro   rt   AsyncResponses.input_tokens  s    --rr   c                    [        U 5      $ rw   )AsyncResponsesWithRawResponserm   s    ro   ry    AsyncResponses.with_raw_response  s     -T22rr   c                    [        U 5      $ r|   )#AsyncResponsesWithStreamingResponserm   s    ro   r~   &AsyncResponses.with_streaming_response   s     3488rr   Nr   c       !           #    g7fr   r   r   s"                                     ro   r   AsyncResponses.create)       p 	   r   c       !           #    g7fr   r   r   s"                                     ro   r   r  #  r  r  c       !           #    g7fr   r   r   s"                                     ro   r   r  	  r  r  c       !          #    U R                  S[        0 SU_SU_SU_SU_SU_SU_SU_S	U_S
U	_SU
_SU_SU_SU_SU_SU_SU_SU_UUUUUUUUUUUUS.EU(       a  [        R                  O[        R                  5      I S h  vN [        UUU U!SS0S9[        U=(       d    S[        [           S9I S h  vN $  N7 N7fr   )	r   r%   rC   r   r   rA   rJ   r4   r\   r   s"                                     ro   r   r  
  s    N ZZ, *(*< #L w	
 U #L (): %n  U *+> +,@ f '(8 -.D   !" ():#$ %1"$&4#. #."$0"", ;@  'DD+LLE# #H )+'%'. ?U"#67_   0
 0
 0	
#0
s$   BCB=
2C8B?9C?Cr   c                   g rk   r   r   s	            ro   r   AsyncResponses.streamp
  s     36rr   r   c       !            g rk   r   r   s"                                     ro   r   r  
  s    N 36rr   r   c       #           0 SU_SU_SU_SU_SU	_SU
_SU_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SU_UUUUUUUUUUS.
En$U$R                  5        V%V&s/ s H  u  n%n&[        U&5      (       d  M  U%PM     n'n%n&[        U5      (       d  [        U5      (       a,  [        U'5      S:  a  [        SSR	                  U'5      -   5      e[        U5      n[        U'5      S:  a  [        U[        5      (       a  [        S5      e[        U5      (       d  [        S5      e[        U5      (       a3  U(       d  0 nSU;   a  [        S5      e[        U5      n[        U5      US'   U R                  " S.0 SU_SU_SS_SU_SU_SU_SU	_SU
_SU_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SU_S U_S!U_SU_SU_SU_S"U_S#U_S$U_S%U_S&U_S'U _S(U!_S)U"_S*U#_6n([        U(UUS S+9$ [        U[        5      (       a  [        S,5      eU R                  USU	=(       d    / U U!U"U#S-9n([        U(UU[        U5      (       a  US+9$ S S+9$ s  sn&n%f )/Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Tr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   z@response_id must be provided when streaming an existing response)r   r   r   r   r   r   r   )r   r!   r   r   r   r   
isinstancer   r   r   r   r   rT   r   r   r   s)                                            ro   r   r  
  s   R
U
U
 !"4
 L	

 w
 L
  !2
 n
 
 "#6
 #$8
 f
  0
 %&<
 
   !2!
" L#
$ ,&&($$7
: 2C1H1H1J"Z1JAhWXk11J"Z[!!Xn%=%=3G^C_bcCca))345 
 E"&'!+%** !VWWE?? !VWW$$Dt##$WXXDz!;K!HX++ """ " 	"
 $6" *"  " *" #4"  ." "" %8" &:" " "2"  (>!"" #"$  .%"& ('"( )"* (+", $-". #4/"0 *1"2 *3"4 5"6 &7"8 9": &;"< ,="> (?"@ &A"B  C"KH .'!#	  +t,, !cdd--2+'% ( K .'!19.1I1I~	  PT	 a #[s   H;1H;r   c       #          ^^#    [        T5      (       a3  U(       d  0 nSU;   a  [        S5      e[        U5      n[        T5      US'   [	        T5      mSUU4S jjn$U R                  S[        0 SU_SU_SU_SU_S	U_S
U_SU_SU	_SU
_SU_SU_SU_SU_SU_SU_SU_SU_UUUUUUUTUUUUUS.E[        R                  5      [        U U!U"U#U$SS0S9[        [        [        [              [        5      S9I S h  vN $  N7f)Nr   r   c                   > [        TTU S9$ r   r   r   s    ro   r   $AsyncResponses.parse.<locals>.parsery  r   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Tr   r   r   r   r   s%    `                        `          ro   r   AsyncResponses.parseE  s    R K  4 STT:D7DDNE"	 	 ZZ  *(*< #L w	
 U #L (): %n  U *+> +,@ f '(8 -.D   !" ():#$ %1"$&4#. #."$0"", !*=@ ';;C"F )+'%"'. n[9:HE_   0
 0
 0	
 0
s   C6D:C?;Dr   c                  #    g 7frk   r   r   s
             ro   r   AsyncResponses.retrieve  s
      r  r   c                  #    g 7frk   r   r   s	            ro   r   r    s
      ,/r  c                  #    g 7frk   r   r   s	            ro   r   r    s
      7:r  Fr  c                  #    g7fr  r   r   s	            ro   r   r    s     \ 	r  r  c                  #    g7fr  r   r  s
             ro   r   r         ^ 	r  c                  #    g7fr  r   r  s
             ro   r   r  D  r  r  c                 #    U(       d  [        SU< 35      eU R                  [        SUS9[        UUUU	[	        UUUUS.[
        R                  5      I S h  vN SS0S9[        U=(       d    S[        [           S	9I S h  vN $  N. N7fr  )
r   r  r"   rA   r%   rE   r  rJ   r4   r\   r   s
             ro   r   r  u  s      YZeYhijjYY4+N(+'%1#*/B*8"(	 -CC  (.  ?U"#67)  
 
 	

s$   ABB)BB	B	Br  c                  #    U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  [        SUS9[        UUUUSS0S9[        S	9I S
h  vN $  N7f)r  r  r  r  r  r  r   Tr   r  Nr  r  s         ro   r  AsyncResponses.delete  s     . YZeYhijj!5B]-@bB\\4+N(+'%'.  " 

 

 
	
 

s   AAAAc                  #    U(       d  [        SU< 35      eU R                  [        SUS9[        UUUUSS0S9[        S9I Sh  vN $  N7f)	r  r  r   r  r   Tr   r  Nr!  r  s         ro   r"  AsyncResponses.cancel  sk     4 YZeYhijjZZ;U(+'%'.    

 

 
	
 

s   AAAAr$  c       
           #    U R                  S[        UUUUUUS.[        R                  5      I Sh  vN [	        UUU	U
SS0S9[
        S9I Sh  vN $  N! N7f)r&  r'  r(  Nr   Tr   r   )r   r%   rD   r)  rA   rU   r*  s              ro   r+  AsyncResponses.compact  s     r ZZ ,""$0,@(8.D (==
 
 )+'%'. &)   
 
 	


s!   1AA
AAAAr-  r.  r/  r0  c	                8    [        U R                  UUUUUUUUS9	$ r2  )AsyncResponsesConnectionManagerrl   r;  s	            ro   r<  AsyncResponses.connect  s0     /<<#')E+#')

 
	
rr   r   )r   r.   )r   r8   )r   rz  )r   r}  r>  )Dr   rW  r   r?  r   r@  r   rA  r   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rQ  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r    AsyncStream[ResponseStreamEvent])Dr   rY  r   r?  r   r@  r   rA  r   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rQ  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r   +Response | AsyncStream[ResponseStreamEvent])Dr   r?  r   r@  r   rA  r   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   r[  r   rM  r   rN  r   rO  r   rP  r   rQ  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r   r  )r   r\  r   r]  r   r^  r   r_  r   rS  r   rT  r   rU  r   rV  r   'AsyncResponseStreamManager[TextFormatT])Dr   ra  r   rX   r   r?  r   r@  r   r]  r   r_  r   rA  r   rB  r   rD  r   rE  r   rE  r   rF  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rE  r   rN  r   rR  r   rI  r   rS  r   rT  r   rU  r   rV  r   r  )Hr   rI  r   rC  r   rG  r   r?  r   r@  r   r]  r   r_  r   rA  r   rB  r   rD  r   rE  r   rE  r   rF  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   rM  r   rN  r   rO  r   rP  r   rE  r   rN  r   rR  r   rI  r   r^  r   rS  r   rT  r   rU  r   rV  r   r  rb  rc  )r   r\  r   rW  r   rd  r   r^  r   rS  r   rT  r   rU  r   rV  r   r  )r   r\  r   rY  r   rd  r   r^  r   rS  r   rT  r   rU  r   rV  r   r  )r   r\  r   rW  r   rd  r   re  r   r^  r   rS  r   rT  r   rU  r   rV  r   r  )r   r\  r   rY  r   rd  r   re  r   r^  r   rS  r   rT  r   rU  r   rV  r   r  )r   r\  r   rd  r   re  r   r^  r   rf  r   rS  r   rT  r   rU  r   rV  r   r  rg  ri  rj  )r   r   r   r   r4  rV   r5  rk  r6  rl  r7  rm  r8  rm  r9  rl  r   r  rn  r   rr   ro   rf   rf     sn   - - . . 3 3 9 9  -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+26PT.2/3@D,0-1(,CG )-$("&;DKw *w `	w
 Kw ;w 5w +w 0w -w ,w %w 3w 3w 5w  %!w" !M#w$ .%w& &'w( _)w* %+w, 0-w. N/w0 ,1w2 -3w4 >5w6 *7w8 +9w: &;w< A=w> ?wD &EwF "GwH  IwJ 9KwL 
Mw wr 
 -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+PT.2/3@D,0-1(,CG )-$("&;DKw w *	w
 `w Kw ;w 5w +w 0w -w ,w %w 3w 3w  5!w" %#w$ !M%w& .'w( &)w* _+w, %-w. N/w0 ,1w2 -3w4 >5w6 *7w8 +9w: &;w< A=w> ?wD &EwF "GwH  IwJ 9KwL 
*Mw wr 
 -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+PT.2/3@D,0-1(,CG )-$("&;DKw w *	w
 `w Kw ;w 5w +w 0w -w ,w %w 3w 3w  5!w" %#w$ !M%w& .'w( &)w* _+w, %-w. N/w0 ,1w2 -3w4 >5w6 *7w8 +9w: &;w< A=w> ?wD &EwF "GwH  IwJ 9KwL 
5Mw wx -1bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+BFPT.2/3@D,0-1(,CG )-$("&;DKW
 *W
 `	W

 KW
 ;W
 5W
 +W
 0W
 -W
 ,W
 %W
 3W
 3W
 5W
  %!W
" !M#W
$ .%W
& &'W
( _)W
* %+W
, @-W
. N/W
0 ,1W
2 -3W
4 >5W
6 *7W
8 +9W
: &;W
< A=W
> ?W
D &EW
F "GW
H  IW
J 9KW
L 
5MW
r 
 15%)59(,$("&;D6 6 .	6
 #6 36 &6 "6  6 96 
16 6  -1bf0459MQ=A-126/3.259597;'+OS04(,ae'+PT.2/3@D-1(,CG )-$("&;DK&6 .&6 	&6
 *&6 `&6 .&6 3&6 K&6 ;&6 +&6 0&6 -&6 ,&6 3&6  3!&6" 5#&6$ %%&6& !M'&6( .)&6* &+&6, _-&6. %/&60 N1&62 ,3&64 -5&66 >7&68 +9&6: &;&6< A=&6> ?&6D &E&6F "G&6H  I&6J 9K&6L 
1M&6 &6V #'7;'+,0bf0459MQ=A-126/3.259597;'+OS04(,ae'+PT.2/3@D-1(,CG%) )-$("&;DO[  [ 5	[
 %[ *[ `[ .[ 3[ K[ ;[ +[ 0[ -[ ,[  3![" 3#[$ 5%[& %'[( !M)[* .+[, &-[. _/[0 %1[2 N3[4 ,5[6 -7[8 >9[: +;[< &=[> A?[@ A[B #C[H &I[J "K[L  M[N 9O[P 
1Q[@ 15,0bfMQ=A7;-126/3.2'+59597;'+OS04(,ae'+BFPT.2/3@D59-1(,CGGK )-$("&;DOk
 .k
 *	k

 `k
 Kk
 ;k
 5k
 +k
 0k
 -k
 ,k
 %k
 3k
 3k
  5!k
" %#k
$ !M%k
& .'k
( &)k
* _+k
, %-k
. @/k
0 N1k
2 ,3k
4 -5k
6 >7k
8 39k
: +;k
< &=k
> A?k
@ Ak
B ECk
H &Ik
J "Kk
L  Mk
N 9Ok
P 
%Qk
Z 
 48+/%)(, )-$("&;D 1	
 ) # & & "   9 
    48%) )-$("&;D// 	/
 1/ #/ &/ "/  / 9/ 
*/ /  48%) )-$("&;D:: 	:
 1: #: &: ":  : 9: 
5: : 
 37%) )-$("&;D-- 	-
 1- #- &- "-  - 9- 
5- -^  48+/%) )-$("&;D.. 	.
 1. ). #. &. ".  . 9. 
*. .`  48+/%) )-$("&;D.. 	.
 1. ). #. &. ".  . 9. 
5. .h 48+/%)8< )-$("&;D&
&
 1	&

 )&
 #&
 6&
 &&
 "&
  &
 9&
 
5&
\ )-$("&;D$
$
 &$
 "$
  $
 9$
 
$
X )-$("&;D&
&
 &&
 "&
  &
 9&
 
&
Z LP-15915OS )-$("&;D_n
a
n
J IKn
L +Mn
N 3On
P /Qn
R !MSn
X &Yn
Z "[n
\  ]n
^ 9_n
` 
an
d  !#CE^b"'

 
 'A	

 \
 
 
 
 
 
)
 
rr   c                  F    \ rS rSrSS jr\SS j5       r\S	S j5       rSrg)
rx   i  c                   Xl         [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR
                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        g rk   )	
_responsesr   to_raw_response_wrapperr   r   r  r"  r+  r   rn   	responsess     ro   __init__!ResponsesWithRawResponse.__init__  s    #&>>
 )@@
 '>>
 '>>
 (??
 &==OO

rr   c                @    [        U R                  R                  5      $ rk   )r/   r  rp   rm   s    ro   rp   $ResponsesWithRawResponse.input_items  s    ()D)DEErr   c                @    [        U R                  R                  5      $ rk   )r9   r  rt   rm   s    ro   rt   %ResponsesWithRawResponse.input_tokens  s    )$//*F*FGGrr   r  r"  r+  r   r  r   r   Nr  re   r   rh  )r   r/   )r   r9   	ro  rp  rq  rr  r  r&   rp   rt   rs  r   rr   ro   rx   rx     s3    
, F F H Hrr   rx   c                  F    \ rS rSrSS jr\SS j5       r\S	S j5       rSrg)
rz  i  c                   Xl         [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR
                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        g rk   )	r  r   async_to_raw_response_wrapperr   r   r  r"  r+  r   r  s     ro   r  &AsyncResponsesWithRawResponse.__init__  s    #&DD
 )FF
 'DD
 'DD
 (EE
 &CCOO

rr   c                @    [        U R                  R                  5      $ rk   )r0   r  rp   rm   s    ro   rp   )AsyncResponsesWithRawResponse.input_items  s    -doo.I.IJJrr   c                @    [        U R                  R                  5      $ rk   )r:   r  rt   rm   s    ro   rt   *AsyncResponsesWithRawResponse.input_tokens  s    .t/K/KLLrr   r  Nr  rf   r   rh  )r   r0   )r   r:   r  r   rr   ro   rz  rz    s3    
, K K M Mrr   rz  c                  F    \ rS rSrSS jr\SS j5       r\S	S j5       rSrg)
r}   i  c                   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        g rk   )r  r*   r   r   r  r"  r+  r  s     ro   r  'ResponsesWithStreamingResponse.__init__  sx    #2
 5
 3
 3
 4
rr   c                @    [        U R                  R                  5      $ rk   )r1   r  rp   rm   s    ro   rp   *ResponsesWithStreamingResponse.input_items  s    .t/J/JKKrr   c                @    [        U R                  R                  5      $ rk   )r;   r  rt   rm   s    ro   rt   +ResponsesWithStreamingResponse.input_tokens  s    /0L0LMMrr   r  r"  r+  r   r  r   Nr  )r   r1   )r   r;   r  r   rr   ro   r}   r}     s3    
& L L N Nrr   r}   c                  F    \ rS rSrSS jr\SS j5       r\S	S j5       rSrg)
r}  i  c                   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        g rk   )r  r+   r   r   r  r"  r+  r  s     ro   r  ,AsyncResponsesWithStreamingResponse.__init__  sx    #8
 ;
 9
 9
 :
rr   c                @    [        U R                  R                  5      $ rk   )r2   r  rp   rm   s    ro   rp   /AsyncResponsesWithStreamingResponse.input_items(  s    3DOO4O4OPPrr   c                @    [        U R                  R                  5      $ rk   )r<   r  rt   rm   s    ro   rt   0AsyncResponsesWithStreamingResponse.input_tokens,  s    4T__5Q5QRRrr   r  Nr  )r   r2   )r   r<   r  r   rr   ro   r}  r}    s3    
& Q Q S Srr   r}  c           
        [        U 5      (       d  [        $ / nU  H  nUS   S:w  a  UR                  U5        M  SU;  a  UR                  U5        M8  [        [        U5      S   n[        U[        5      (       d  [        S5      eSU;   d   e[        SUS   UR                  S5      US   UR                  S5      =(       d    SS	.UR                  5      nUR                  UR                  5       5        M     U$ )
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  r5   	Exceptionr6   getr   )r   converted_toolstoolr  new_tools        ro   r   r   1  s    E??')O<:%""4(T!""4(T?:.($899u  x'''0" ('||M:&|4",,x09E NN	
 	x}}/9 < rr   c            	          \ rS rSr% SrS\S'   S\S'   SSSS	S
0 0 SS.                   SS jjrSS jrS S jrS!S jr	S"S jr
S#S jrSSS.S$S jjrS%S jrS&S jrS'S jr S(     S)S jjrS*S jr S(     S)S jjrS'S jrSrg)+AsyncResponsesConnectioniW  ;Represents a live WebSocket connection to the Responses APIAsyncResponsesResponseResourcer   AsyncWebSocketConnection_connectionNr-  r.  r/  make_wsr5  r6  r7  r8  r   r   
send_queuec                   Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        SU l        SU l	        U	=(       d
    [        5       U l        [        SS9U l        [        U 5      U l        g )NFuse_lock)r  _make_ws_on_reconnecting_max_retries_initial_delay
_max_delay_extra_query_extra_headers_intentionally_closed_is_reconnectingr?   _send_queuerB   _event_handler_registryr  r   
rn   
connectionr  r5  r6  r7  r8  r   r   r  s
             ro   r  !AsyncResponsesConnection.__init__^  sj     & /'+#'+%*" %%4';U'K$6t<rr   c               (  #    SSK JnJn    U R                  5       I Sh  vN 7v   M   N	! U a     gU aV  nU R	                  U5      I Sh  vN  (       d-  U R
                  R                  5       nU(       a  [        SUS9Uee  SnANbSnAff = f7fzY
An infinite-iterator that will continue to yield events until
the connection is closed.
r   )ConnectionClosedOKConnectionClosedErrorNz0WebSocket connection closed with unsent messages)unsent_messageswebsockets.exceptionsr  r  recv
_reconnectr  drainr>   rn   r  r  excunsents        ro   	__aiter__"AsyncResponsesConnection.__aiter__z  s     
 	T IIK'' '% ( !__S111!--335F<N,2  ##  2sL   
B, *, B, BBBB
A7B
B
BBc                \   #    U R                  U R                  5       I Sh  vN 5      $  N7f)
Receive the next message from the connection and parses it into a `ResponsesServerEvent` object.

Canceling this method is safe. There's no risk of losing data.
Nparse_event
recv_bytesrm   s    ro   r  AsyncResponsesConnection.recv  s%      doo&7 788 7s   ,*	,c                   #    U R                   R                  SS9I Sh  vN n[        R                  SU5        U$  N7f)Receive the next message from the connection as raw bytes.

Canceling this method is safe. There's no risk of losing data.

If you want to parse the message into a `ResponsesServerEvent` object like `.recv()` does,
then you can call `.parse_event(data)`.
FdecodeNReceived WebSocket message: %sr  r  rg   debugrn   messages     ro   r  #AsyncResponsesConnection.recv_bytes  s<      ((--U-;;		2W= <s   ><>c                  #    [        U[        5      (       a  UR                  SSSS9O+[        R                  " [        U[        5      I S h  vN 5      nU R                  (       a  U R                  R                  U5        g  U R                  R                  U5      I S h  vN   g  NZ N! [         a    U R                  R                  U5        e f = f7fNTuse_api_namesexclude_defaultsexclude_unset)r  r   to_jsonjsondumpsr%   ra   r  r  enqueuer  sendr  rn   eventdatas      ro   r  AsyncResponsesConnection.send  s      %++ MMtSWMX"7?X"YYZ 	
   $$T*	""''--- Z . 	$$T*	s<   A
CB'5CB+ !B)"B+ &C)B+ +'CCc                   #    U R                   (       aD  [        U[        5      (       a  UOUR                  S5      nU R                  R                  U5        g U R                  R                  U5      I S h  vN   g  N7fNzutf-8r  r  r\  r
  r  r  r  r  rn   r  raws      ro   send_raw!AsyncResponsesConnection.send_raw  s[       $T3//$T[[5IC$$S)##D)))s   A4A>6A<7A>   codereasonc               `   #    SU l         U R                  R                  XS9I S h  vN   g  N7fNTr)  r  r  closern   r*  r+  s      ro   r/  AsyncResponsesConnection.close  s*     %)"$$$$>>>s   $.,.c           
     ~    [        [        [        [        R                  " U5      [        [
        [        5      S95      $ z
Converts a raw `str` or `bytes` message into a `ResponsesServerEvent` object.

This is helpful if you're using `.recv_bytes()`.
)valuetype_r   r^   r'   r  loadsr   rn   r  s     ro   r  $AsyncResponsesConnection.parse_event  /      $4::d+;4MaCbc
 	
rr   c           
       #    SSK nU R                  b  U R                  c  gSSKJn  Sn[        X5      (       a#  UR                  b  UR                  R                  n[        U5      (       d  gSU l	        [        SU R                  S-   5       GH  n[        U R                  SUS-
  -  -  U R                  5      nS	[        R                  " 5       S
-  -   nXg-  n[!        UU R                  UUU R"                  U R$                  S9n	 U R                  U	5      n
U
b  U
R)                  S5      (       a	  SU l	          gU
b   SU
;   a
  U
S   U l        SU
;   a
  U
S   U l        [*        R-                  SUU R                  U5        UR/                  U5      I Sh  vN   U R0                  (       a	  SU l	          g U R                  U R"                  U R$                  5      I Sh  vN U l        [*        R-                  S5        SU l	        U R5                  5       I Sh  vN     g   SU l	        g! [&         a    SU l	           gf = f N Nc N,! [&         a     GM  f = f7f)Attempt to reconnect after a connection failure.

Returns ``True`` if a new connection was established, ``False`` if the
caller should re-raise the original exception.
r   NFr    Tr,            ?      ?attemptmax_attemptsdelay
close_coder   r   abortr   r   ?Reconnecting to WebSocket API (attempt %d/%d) after %.1fs delayReconnected to WebSocket API)asyncior  r  r  r  r  rcvdr*  rP   r  ranger  minr  r  randomrN   r  r  r  r  rg   infosleepr  r  _flush_send_queue)rn   r  rJ  r  rF  rC  
base_delayjitterrE  r  results              ro   r  #AsyncResponsesConnection._reconnect  s6     	  (DMM,A?
c11chh6JJ#J// $Q 1 1A 56GT00A'A+4FGYJFMMOd22F'E%!..% --"11E..u5
 !fjj&9&9(-%! F*(.}(=D%"f,*0*AD'HHQ!!	 --&&&))(-%)-t7H7H$J]J])^#^ 78(-%,,..._ 7f !&I  (-%( ' $_ / s   DIH&A;IH>I3)II 8IIII&H;7I:H;;I II
IIIIc                   ^ #    SU 4S jjn T R                   R                  U5      I Sh  vN   g N! [         a    [        R	                  SSS9   gf = f7f)5Send all queued messages over the current connection.c                X   >#    TR                   R                  U 5      I S h  vN   g  N7frk   r  r  r  rn   s    ro   _send9AsyncResponsesConnection._flush_send_queue.<locals>._send  s      ""''---s   *(*N*Failed to flush send queue after reconnectTexc_info)r  r\  r   rh  )r  flush_asyncr  rg   warning)rn   r[  s   ` ro   rQ  *AsyncResponsesConnection._flush_send_queue  sL     	.	U""..u555 	UKKDtKT	Us1   	A3 13 A3 AAAAc                ^   ^ ^ Ub  T R                   R                  TU5        T $ SUU 4S jjnU$ )a  Adds the handler to the end of the handlers list for the given event type.

No checks are made to see if the handler has already been added. Multiple calls
passing the same combination of event type and handler will result in the handler
being added, and called, multiple times.

Can be used as a method (returns ``self`` for chaining)::

    connection.on("response.audio.delta", my_handler)

Or as a decorator::

    @connection.on("response.audio.delta")
    async def my_handler(event): ...
c                @   > TR                   R                  TU 5        U $ rk   r  addfn
event_typern   s    ro   	decorator.AsyncResponsesConnection.on.<locals>.decorator6      ((,,Z<Irr   rh  Callable[..., Any]r   rn  re  rn   ri  handlerrj  s   ``  ro   onAsyncResponsesConnection.on   8    $ ((,,ZAK	 	 rr   c                <    U R                   R                  X5        U $ z-Remove a previously registered event handler.r  removern   ri  rp  s      ro   offAsyncResponsesConnection.off<      $$++J@rr   c                \   ^ ^ Ub  T R                   R                  TUSS9  T $ SUU 4S jjnU$ )RRegister a one-time event handler.

Automatically removed after first invocation.
Toncec                >   > TR                   R                  TU SS9  U $ NTr~  re  rg  s    ro   rj  0AsyncResponsesConnection.once.<locals>.decoratorL  #    ((,,Z$,GIrr   rm  re  ro  s   ``  ro   r  AsyncResponsesConnection.onceA  =     ((,,Zt,LK	 	 rr   c                  #    SSK nU   Sh  vN nUR                  nU R                  R                  U5      nU R                  R                  S5      nUS:X  a1  U(       d*  U(       d#  [	        U[
        5      (       a  [        SU 35      eU H-  nU" U5      nUR                  U5      (       d  M#  UI Sh  vN   M/     U H-  nU" U5      nUR                  U5      (       d  M#  UI Sh  vN   M/     M   N N? N
 g7f)aD  Run the event loop, dispatching received events to registered handlers.

Blocks until the connection is closed. This is the push-based
alternative to iterating with ``async for event in connection``.

If an ``"error"`` event arrives and no handler is registered for
``"error"`` or ``"event"``, an ``OpenAIError`` is raised.
r   Nr  errorWebSocket error: )rJ  r  r  get_handlersr  rY   r=   iscoroutine)rn   rJ  r  ri  specificgenericrp  rT  s           ro   dispatch_events(AsyncResponsesConnection.dispatch_eventsR  s      	 	!%J33@@LH22??HGW$Xge%788%(9%&ABB# &&v.. LL $
 # &&v.. LL #	! !
 !#  sV   C;C9C3C9BC;0C;5C56)C;#C;(C7)
C;3C95C;7C;9C;r  r  r  r  r  r  r  r  r  r  r  r  r   )r  r  r  zFCallable[[Query, Headers], Awaitable[AsyncWebSocketConnection]] | Noner5  rk  r6  rl  r7  rm  r8  rm  r   r   r   r   r  SendQueue | Noner   rh  )r   z#AsyncIterator[ResponsesServerEvent]r   r^   r   bytesr  z0ResponsesClientEvent | ResponsesClientEventParamr   rh  r  zbytes | strr   rh  r*  rl  r+  r\  r   rh  r  zstr | bytesr   r^   r  r  r   rY  r   rh  rk   )ri  r\  rp  Callable[..., Any] | Noner   zSUnion[AsyncResponsesConnection, Callable[[Callable[..., Any]], Callable[..., Any]]])ri  r\  rp  rn  r   r  )ro  rp  rq  rr  __doc____annotations__r  r  r  r  r  r%  r/  r  r  rQ  rq  ry  r  r  rs  r   rr   ro   r  r  W  s   E,,)) [_^b"!#'+=,= X	=
 \= = = = = = %= 
=8,9
* *.R ?	
JX	U EI(A	\8 EI(A	\"!rr   r  c                      \ rS rSrSrSSSSSS.                   SS	 jjrSS
 jr S     SS jjrSS jr S     SS jjr	SS jr
\
rSS jrSS jr        SS jrSrg)r  iq  a  
Context manager over a `AsyncResponsesConnection` that is returned by `responses.connect()`

This context manager ensures that the connection will be closed when it exits.

---

Note that if your application doesn't work well with the context manager approach then you
can call the `.enter()` method directly to initiate a connection.

**Warning**: You must remember to close the connection with `.close()`.

```py
connection = await client.responses.connect(...).enter()
# ...
await connection.close()
```
Nr-  r.  r/  r0  r5  r6  r7  r8  r9  c       	            Xl         S U l        X l        X0l        X@l        XPl        X`l        Xpl        Xl        [        U	S9U l
        [        SS9U l        g )N	max_bytesFr  )(_AsyncResponsesConnectionManager__client,_AsyncResponsesConnectionManager__connection-_AsyncResponsesConnectionManager__extra_query/_AsyncResponsesConnectionManager__extra_headers>_AsyncResponsesConnectionManager__websocket_connection_options1_AsyncResponsesConnectionManager__on_reconnecting-_AsyncResponsesConnectionManager__max_retries/_AsyncResponsesConnectionManager__initial_delay+_AsyncResponsesConnectionManager__max_delayr?   ,_AsyncResponsesConnectionManager__send_queuerB   8_AsyncResponsesConnectionManager__event_handler_registry
rn   r3  r   r   r4  r5  r6  r7  r8  r9  s
             ro   r  (AsyncResponsesConnectionManager.__init__  sU     =A(,.J+!0(,$%?(<e(L%rr   c                    [        U[        5      (       a  UR                  SSSS9O[        R                  " U5      nU R
                  R                  U5        gzQueue a message to be sent when the connection is established.

This can be called before entering the context manager. Queued messages
are automatically sent once the WebSocket connection opens.
Tr  N)r  r   r  r  r  r  r  r  s      ro   r  $AsyncResponsesConnectionManager.send  M     %++ MMtSWMXE" 	
 	!!$'rr   c                ^   ^ ^ Ub  T R                   R                  TU5        T $ SUU 4S jjnU$ )zRegister an event handler before the connection is established.

Handlers are transferred to the connection on enter. Supports the
same method and decorator forms as ``AsyncResponsesConnection.on``.
c                @   > TR                   R                  TU 5        U $ rk   r  rf  rg  s    ro   rj  5AsyncResponsesConnectionManager.on.<locals>.decorator      ))--j"=Irr   rm  r  ro  s   ``  ro   rq  "AsyncResponsesConnectionManager.on  8     ))--j'BK	 	 rr   c                <    U R                   R                  X5        U $ ru  )r  rw  rx  s      ro   ry  #AsyncResponsesConnectionManager.off      %%,,ZArr   c                \   ^ ^ Ub  T R                   R                  TUSS9  T $ SUU 4S jjnU$ )GRegister a one-time event handler before the connection is established.Tr~  c                >   > TR                   R                  TU SS9  U $ r  r  rg  s    ro   rj  7AsyncResponsesConnectionManager.once.<locals>.decorator  #    ))--j"4-HIrr   rm  r  ro  s   ``  ro   r  $AsyncResponsesConnectionManager.once  =     ))--j'-MK	 	 rr   c                  #    U R                  U R                  U R                  5      I Sh  vN n[        UU R                  b  U R                   OSU R                  U R
                  U R                  U R                  U R                  U R                  U R                  S9	U l	        U R                  R                  U R                  R                  5        U R                  R                  5       I Sh  vN   U R                  $  N N7f)a6  
If your application doesn't work well with the context manager approach then you
can call this method directly to initiate a connection.

**Warning**: You must remember to close the connection with `.close()`.

```py
connection = await client.responses.connect(...).enter()
# ...
await connection.close()
```
Nr  )_connect_wsr  r  r  r  r  r  r  r  r  r  
merge_intor  rQ  rn   wss     ro   
__aenter__*AsyncResponsesConnectionManager.__aenter__  s      ##D$6$68L8LMM4(,(>(>(JD$$PT 22**..&&**..((

 	%%001B1B1Z1Z[11333   # N 	4s"   *DDCD2D3DDc                  #     SSK Jn  U R	                  5       R                  0 U R                  R                  R                  EUES9n[        R                  SU5        U R                  (       a   [        R                  SU R                  5        U" [        U5      4U R                  R                  [        0 U R                  R                  EU5      S.U R                  D6I S h  vN $ ! [         a  n[        S5      UeS nAff = f N"7fNr   )r<  z9You need to install `openai[realtime]` to use this method)paramszConnecting to %szConnection options: %s)user_agent_headeradditional_headers)websockets.asyncio.clientr<  ImportErrorr=   _prepare_url	copy_withr  base_urlr  rg   r  r  r\  
user_agentr@   auth_headersrn   r   r   r<  r  urls         ro   r  +AsyncResponsesConnectionManager._connect_ws  s	    	d9 !++--((// , 
 			$c*..II.0S0STH

"mm66.mm00 	 

 11

 

 
	
  	dYZ`cc	d

s4   DC+ CD&D	'D+
D5DDDc                z   U R                   R                  b+  [        R                  " U R                   R                  5      nOMU R                   R                  R
                  nUS:X  a  SOSnU R                   R                  R                  US9nUR                  R                  S5      S-   nUR                  US9$ Nhttpr  wss)scheme   /s
   /responses)raw_path)	r  websocket_base_urlhttpxURL	_base_urlr  r  r  rstriprn   r  r  	ws_schememerge_raw_paths        ro   r  ,AsyncResponsesConnectionManager._prepare_url      ==++7yy!A!ABH]],,33F && 0eI}}..88	8JH!**11$7-G!!>!::rr   c                p   #    U R                   b#  U R                   R                  5       I S h  vN   g g  N7frk   )r  r/  rn   exc_typer  exc_tbs       ro   	__aexit__)AsyncResponsesConnectionManager.__aexit__  s3      (##))+++ )+s   +646__client__connection__event_handler_registry__extra_headers__extra_query__initial_delay__max_delay__max_retries__on_reconnecting__send_queue__websocket_connection_options)r3  rd   r   r   r   r   r4  rV   r5  rk  r6  rl  r7  rm  r8  rm  r9  rl  r   rh  r  rk   )ri  r\  rp  r  r   zZUnion[AsyncResponsesConnectionManager, Callable[[Callable[..., Any]], Callable[..., Any]]])ri  r\  rp  rn  r   r  )r   r  )r   r   r   r   r   r  r   z	httpx.URLr  ztype[BaseException] | Noner  zBaseException | Noner  zTracebackType | Noner   rh  )ro  rp  rq  rr  r  r  r  rq  ry  r  r  enterr  r  r  rs  r   rr   ro   r  r  q  s   4 _c"'M M 	M
 M 'AM \M M M M M 
M2( EI(A	c$ EI(A	c!@ E
8	;,2,9M,Wk,	,rr   r  c            	          \ rS rSr% SrS\S'   S\S'   SSSS	S
0 0 SS.                   SS jjrSS jrS S jrS!S jr	S"S jr
S#S jrSSS.S$S jjrS%S jrS&S jrS'S jr S(     S)S jjrS*S jr S(     S)S jjrS'S jrSrg)+ResponsesConnectioni   r  ResponsesResponseResourcer   WebSocketConnectionr  Nr-  r.  r/  r  c                   Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        SU l        SU l	        U	=(       d
    [        5       U l        [        SS9U l        [        U 5      U l        g )NFTr  )r  r  r  r  r  r  r  r  r  r  r?   r  rB   r  r  r   r  s
             ro   r  ResponsesConnection.__init__'  sj     & /'+#'+%*" %%4';T'J$1$7rr   c              #     #    SSK JnJn    U R                  5       v   M  ! U a     gU aM  nU R	                  U5      (       d-  U R
                  R                  5       nU(       a  [        SUS9Uee  SnANWSnAff = f7fr  r  r  s        ro   __iter__ResponsesConnection.__iter__C  s     
 	Tiik!  & ( s++!--335F<N,2  ##  ,s5   
A>! A>A;A>A;AA61A>6A;;A>c                @    U R                  U R                  5       5      $ )r  r  rm   s    ro   r  ResponsesConnection.recvY  s      122rr   c                d    U R                   R                  SS9n[        R                  SU5        U$ )r  Fr	  r  r  r  s     ro   r  ResponsesConnection.recv_bytesa  s1     ""''u'5		2W=rr   c                ~   [        U[        5      (       a  UR                  SSSS9O#[        R                  " [        U[        5      5      nU R                  (       a  U R                  R                  U5        g  U R                  R                  U5        g ! [         a    U R                  R                  U5        e f = fr  )r  r   r  r  r  r#   ra   r  r  r  r  r  r  r  s      ro   r  ResponsesConnection.sendm  s     %++ MMtSWMXOE3LMN 	
   $$T*	!!$' 	$$T*	s   9B 'B<c                    U R                   (       aD  [        U[        5      (       a  UOUR                  S5      nU R                  R                  U5        g U R                  R                  U5        g r!  r"  r#  s      ro   r%  ResponsesConnection.send_raw|  sR      $T3//$T[[5IC$$S)d#rr   r'  r(  r)  c               D    SU l         U R                  R                  XS9  g r-  r.  r0  s      ro   r/  ResponsesConnection.close  s!    %)"D8rr   c           
     ~    [        [        [        [        R                  " U5      [        [
        [        5      S95      $ r3  r6  r8  s     ro   r  ResponsesConnection.parse_event  r:  rr   c           
     n   U R                   b  U R                  c  gSSKJn  Sn[	        X5      (       a#  UR
                  b  UR
                  R                  n[        U5      (       d  gSU l        [        SU R                  S-   5       GHx  n[        U R                  SUS-
  -  -  U R                  5      nS[        R                  " 5       S	-  -   nXV-  n[        UU R                  UUU R                   U R"                  S
9n U R                  U5      n	U	b  U	R'                  S5      (       a	  SU l          gU	b   SU	;   a
  U	S   U l        SU	;   a
  U	S   U l        [(        R+                  SUU R                  U5        [,        R.                  " U5        U R0                  (       a	  SU l          g U R                  U R                   U R"                  5      U l        [(        R+                  S5        SU l        U R5                  5           g   SU l        g! [$         a    SU l           gf = f! [$         a     GM  f = f)r<  Fr   r=  r>  Tr,   r?  r@  rA  rB  rG  r   r   rH  rI  )r  r  r  r  r  rK  r*  rP   r  rL  r  rM  r  r  rN  rN   r  r  r  r  rg   rO  timerP  r  r  rQ  )
rn   r  r  rF  rC  rR  rS  rE  r  rT  s
             ro   r  ResponsesConnection._reconnect  s      (DMM,A?
c11chh6JJ#J// $Q 1 1A 56GT00A'A+4FGYJFMMOd22F'E%!..% --"11E..u5
 !fjj&9&9(-%! F*(.}(=D%"f,*0*AD'HHQ!!	 JJu))(-%#'==1B1BDDWDW#X 78(-%&&(_ 7f !&I  (-%@  s%   H*AH%H"!H"%
H43H4c                   ^   T R                   R                  U 4S j5        g! [         a    [        R	                  SSS9   gf = f)rW  c                :   > TR                   R                  U 5      $ rk   rY  rZ  s    ro   r   7ResponsesConnection._flush_send_queue.<locals>.<lambda>  s    T5E5E5J5J45Prr   r]  Tr^  N)r  
flush_syncr  rg   ra  rm   s   `ro   rQ  %ResponsesConnection._flush_send_queue  s@    	U''(PQ 	UKKDtKT	Us   # AAc                ^   ^ ^ Ub  T R                   R                  TU5        T $ SUU 4S jjnU$ )a  Adds the handler to the end of the handlers list for the given event type.

No checks are made to see if the handler has already been added. Multiple calls
passing the same combination of event type and handler will result in the handler
being added, and called, multiple times.

Can be used as a method (returns ``self`` for chaining)::

    connection.on("response.audio.delta", my_handler)

Or as a decorator::

    @connection.on("response.audio.delta")
    def my_handler(event): ...
c                @   > TR                   R                  TU 5        U $ rk   re  rg  s    ro   rj  )ResponsesConnection.on.<locals>.decorator  rl  rr   rm  re  ro  s   ``  ro   rq  ResponsesConnection.on  rs  rr   c                <    U R                   R                  X5        U $ ru  rv  rx  s      ro   ry  ResponsesConnection.off  r{  rr   c                \   ^ ^ Ub  T R                   R                  TUSS9  T $ SUU 4S jjnU$ )r}  Tr~  c                >   > TR                   R                  TU SS9  U $ r  re  rg  s    ro   rj  +ResponsesConnection.once.<locals>.decorator  r  rr   rm  re  ro  s   ``  ro   r  ResponsesConnection.once  r  rr   c                L   U  H  nUR                   nU R                  R                  U5      nU R                  R                  S5      nUS:X  a1  U(       d*  U(       d#  [        U[        5      (       a  [        SU 35      eU H  nU" U5        M     U H  nU" U5        M     M     g)aQ  Run the event loop, dispatching received events to registered handlers.

Blocks the current thread until the connection is closed. This is the push-based
alternative to iterating with ``for event in connection``.

If an ``"error"`` event arrives and no handler is registered for
``"error"`` or ``"event"``, an ``OpenAIError`` is raised.
r  r  r  N)r  r  r  r  rY   r=   )rn   r  ri  r  r  rp  s         ro   r  #ResponsesConnection.dispatch_events  s     EJ33@@LH22??HGW$Xge%788%(9%&ABB# $ # # rr   r  )r  r  r  z6Callable[[Query, Headers], WebSocketConnection] | Noner5  rk  r6  rl  r7  rm  r8  rm  r   r   r   r   r  r  r   rh  )r   zIterator[ResponsesServerEvent]r  r  r  r  r  r  r  r  rk   )ri  r\  rp  r  r   zNUnion[ResponsesConnection, Callable[[Callable[..., Any]], Callable[..., Any]]])ri  r\  rp  rn  r   r  )ro  rp  rq  rr  r  r  r  r  r  r  r  r%  r/  r  r  rQ  rq  ry  r  r  rs  r   rr   ro   r  r     s   E''$$ KO^b"!#'+8'8 H	8
 \8 8 8 8 8 8 %8 
88,3
$ $(r 9	
HTU EI(A	W8 EI(A	W"rr   r  c                      \ rS rSrSrSSSSSS.                   SS	 jjrSS
 jr S     SS jjrSS jr S     SS jjr	SS jr
\
rSS jrSS jr        SS jrSrg)r:  i.  a  
Context manager over a `ResponsesConnection` that is returned by `responses.connect()`

This context manager ensures that the connection will be closed when it exits.

---

Note that if your application doesn't work well with the context manager approach then you
can call the `.enter()` method directly to initiate a connection.

**Warning**: You must remember to close the connection with `.close()`.

```py
connection = client.responses.connect(...).enter()
# ...
connection.close()
```
Nr-  r.  r/  r0  r  c       	            Xl         S U l        X l        X0l        X@l        XPl        X`l        Xpl        Xl        [        U	S9U l
        [        SS9U l        g )Nr  Tr  )#_ResponsesConnectionManager__client'_ResponsesConnectionManager__connection(_ResponsesConnectionManager__extra_query*_ResponsesConnectionManager__extra_headers9_ResponsesConnectionManager__websocket_connection_options,_ResponsesConnectionManager__on_reconnecting(_ResponsesConnectionManager__max_retries*_ResponsesConnectionManager__initial_delay&_ResponsesConnectionManager__max_delayr?   '_ResponsesConnectionManager__send_queuerB   3_ResponsesConnectionManager__event_handler_registryr  s
             ro   r  #ResponsesConnectionManager.__init__B  sU     8<(,.J+!0(,$%?(<d(K%rr   c                    [        U[        5      (       a  UR                  SSSS9O[        R                  " U5      nU R
                  R                  U5        gr  )r  r   r  r  r  r4  r  r  s      ro   r  ResponsesConnectionManager.send[  r  rr   c                ^   ^ ^ Ub  T R                   R                  TU5        T $ SUU 4S jjnU$ )zRegister an event handler before the connection is established.

Handlers are transferred to the connection on enter. Supports the
same method and decorator forms as ``ResponsesConnection.on``.
c                @   > TR                   R                  TU 5        U $ rk   r5  rf  rg  s    ro   rj  0ResponsesConnectionManager.on.<locals>.decoratort  r  rr   rm  r;  ro  s   ``  ro   rq  ResponsesConnectionManager.onh  r  rr   c                <    U R                   R                  X5        U $ ru  )r5  rw  rx  s      ro   ry  ResponsesConnectionManager.offz  r  rr   c                \   ^ ^ Ub  T R                   R                  TUSS9  T $ SUU 4S jjnU$ )r  Tr~  c                >   > TR                   R                  TU SS9  U $ r  r;  rg  s    ro   rj  2ResponsesConnectionManager.once.<locals>.decorator  r  rr   rm  r;  ro  s   ``  ro   r  ResponsesConnectionManager.once  r  rr   c                   U R                  U R                  U R                  5      n[        UU R                  b  U R                   OSU R                  U R
                  U R                  U R                  U R                  U R                  U R                  S9	U l	        U R                  R                  U R                  R                  5        U R                  R                  5         U R                  $ )a*  
If your application doesn't work well with the context manager approach then you
can call this method directly to initiate a connection.

**Warning**: You must remember to close the connection with `.close()`.

```py
connection = client.responses.connect(...).enter()
# ...
connection.close()
```
Nr  )r  r-  r.  r  r0  r1  r2  r3  r4  r,  r5  r  r  rQ  r  s     ro   	__enter__$ResponsesConnectionManager.__enter__  s     d00$2F2FG/(,(>(>(JD$$PT 22**..&&**..((

 	%%001B1B1Z1Z[++-   rr   c                    SSK Jn  U R	                  5       R                  0 U R                  R                  R                  EUES9n[        R                  SU5        U R                  (       a   [        R                  SU R                  5        U" [        U5      4U R                  R                  [        0 U R                  R                  EU5      S.U R                  D6$ ! [         a  n[        S5      UeS nAff = fr  )websockets.sync.clientr<  r  r=   r  r  r+  r  r  rg   r  r/  r\  r  r@   r  r  s         ro   r  &ResponsesConnectionManager._connect_ws  s    	d6 !++--((// , 
 			$c*..II.0S0STH

"mm66.mm00 	 

 11

 
	
  	dYZ`cc	ds   C! !
C<+C77C<c                z   U R                   R                  b+  [        R                  " U R                   R                  5      nOMU R                   R                  R
                  nUS:X  a  SOSnU R                   R                  R                  US9nUR                  R                  S5      S-   nUR                  US9$ r  )	r+  r  r  r  r  r  r  r  r  r  s        ro   r  'ResponsesConnectionManager._prepare_url  r  rr   c                T    U R                   b  U R                   R                  5         g g rk   )r,  r/  r  s       ro   __exit__#ResponsesConnectionManager.__exit__  s'     (##% )rr   r  )r3  rc   r   r   r   r   r4  rV   r5  rk  r6  rl  r7  rm  r8  rm  r9  rl  r   rh  r  rk   )ri  r\  rp  r  r   zUUnion[ResponsesConnectionManager, Callable[[Callable[..., Any]], Callable[..., Any]]])ri  r\  rp  rn  r   r:  )r   r  )r   r   r   r   r   r  r  r  )ro  rp  rq  rr  r  r  r  rq  ry  r  rE  r  r  r  rM  rs  r   rr   ro   r:  r:  .  s   4 _c"'L L 	L
 L 'AL \L L L L L 
L2( EI(A	^$ EI(A	^!@ E
8	;&2&9M&Wk&	&rr   r:  c                      \ rS rSrSS jrSrg)BaseResponsesConnectionResourcei  c                    Xl         g rk   r  rn   r  s     ro   r  (BaseResponsesConnectionResource.__init__      %rr   rR  N)r  r  r   rh  ro  rp  rq  rr  r  rs  r   rr   ro   rP  rP        &rr   rP  c                      \ rS rSr\\\\\\\\\\\\\\\\\\\\\\\\\\\\\S.                                                           SS jjrSrg)r  i  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                   U R                   R                  [        [        [	        0 SS_SU_SU_SU_SU_SU_SU_S	U_S
U_SU	_SU
_SU_SU_SU_SU_SU_SU_UUUUUUUUUUUUUS.E5      5      5        g Nr  zresponse.creater   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   ra   r$   rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                                 ro   r    ResponsesResponseResource.create  s.   B 	) 1$j -.@ '	
 "7   ' ,-> ). #H   ./B /0D !& +,<  12H!" $Y#$ .?(4!&"(*8'2 $'2!&(4!&&0 $=!$&	
rr   r   N<r   r?  r   zIOptional[Iterable[responses_client_event_param.ContextManagement]] | Omitr   z:Optional[responses_client_event_param.Conversation] | Omitr   rB  r   rC  r   rD  r   rE  r   rE  r   rF  r   rG  r   r?  r   rD  r   rH  r   rI  r   rJ  r   rK  r   rI  r   rL  r   r?  r   r?  r   z;Optional[responses_client_event_param.StreamOptions] | Omitr   rN  r   rO  r   z.responses_client_event_param.ToolChoice | Omitr   rQ  r   rE  r   rN  r   rR  r   rI  r   rh  ro  rp  rq  rr  r   r   rs  r   rr   ro   r  r        -1hlSW=A7;-126/3.2'+59597;'+OS04(,ae'+(,VZ.2/3FJ,0-1(,CG?G
 *G
 f	G

 QG
 ;G
 5G
 +G
 0G
 -G
 ,G
 %G
 3G
 3G
 5G
  %!G
" !M#G
$ .%G
& &'G
( _)G
* %+G
, &-G
. T/G
0 ,1G
2 -3G
4 D5G
6 *7G
8 +9G
: &;G
< A=G
> ?G
@ 
AG
 G
rr   r  c                      \ rS rSrSS jrSrg)$BaseAsyncResponsesConnectionResourcei-  c                    Xl         g rk   rR  rS  s     ro   r  -BaseAsyncResponsesConnectionResource.__init__.  rU  rr   rR  N)r  r  r   rh  rV  r   rr   ro   rc  rc  -  rW  rr   rc  c                      \ rS rSr\\\\\\\\\\\\\\\\\\\\\\\\\\\\\S.                                                           SS jjrSrg)r  i2  rY  c               
  #    U R                   R                  [        [        [	        0 SS_SU_SU_SU_SU_SU_SU_S	U_S
U_SU	_SU
_SU_SU_SU_SU_SU_SU_UUUUUUUUUUUUUS.E5      5      5      I S h  vN   g  N7fr[  r\  r]  s                                 ro   r   %AsyncResponsesResponseResource.create3  s;    B ##) 1$j -.@ '	
 "7   ' ,-> ). #H   ./B /0D !& +,<  12H!" $Y#$ .?(4!&"(*8'2 $'2!&(4!&&0 $=!$&
 &	
 &	
s   A9B;B<Br   Nr_  r`  r   rr   ro   r  r  2  ra  rr   r  )r   r_  r   zList[ToolParam] | Omit)
__future__r   r  r  rN  loggingr   typesr   typingr   r   r   r	   r
   r   r   r   r   r   r   r   	functoolsr   typing_extensionsr   r   r  pydanticr   r(  r   _typesr   r   r   r   r   r   r   r   r    _utilsr!   r"   r#   r$   r%   _compatr&   _modelsr'   	_resourcer(   r)   	_responser*   r+   rp   r-   r.   r/   r0   r1   r2   
_streamingr3   r4   
lib._toolsr5   r6   rt   r7   r8   r9   r:   r;   r<   _exceptionsr=   r>   r  r?   _base_clientr@   rA   _event_handlerrB   types.responsesrC   rD   rE   rF   lib._parsing._responsesrG   rH   rI   r   types.responses.responserJ   types.responses.tool_paramrK   rL   types.shared_params.metadatarM   types.websocket_reconnectionrN   rO   rP   types.shared_params.reasoningrQ   types.responses.parsed_responserR   "lib.streaming.responses._responsesrS   rT   "types.responses.compacted_responserU   "types.websocket_connection_optionsrV   #types.responses.response_includablerW   #types.shared_params.responses_modelrX   $types.responses.response_error_eventrY   $types.responses.response_input_paramrZ   %types.responses.response_prompt_paramr[   %types.responses.response_stream_eventr\   &types.responses.responses_client_eventr]   &types.responses.responses_server_eventr^   )types.responses.response_input_item_paramr_   *types.responses.response_text_config_paramr`   ,types.responses.responses_client_event_paramra   rH  rb   r  r  r  rl   rc   rd   __all__	getLoggerro  rg   r  re   rf   rx   rz  r}   r}  r   r  r  r  r:  rP  r  rc  r  r   rr   ro   <module>r     s   #           /     ` ` ` f f & / : Y  . M  G $ A 2  
 1 G 4 j j 6 = c C L E A F F H H J J O Q UNV.(
)''1^ 1c
 c
L5g
% g
T5H H@M M@N N:S S:#LW! W!tl, l,^K K\l& l&^& &
H
 ? H
V& &
H
%I H
rr   