diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0ac3c2a5..8935e932 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.27.1" + ".": "0.28.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 48863a6e..10c939b2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 118 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-410219ea680089f02bb55163c673919703f946c3d6ad7ff5d6f607121d5287d5.yml -openapi_spec_hash: 2b3eee95d3f6796c7a61dfddf694a59a -config_hash: 666d6bb4b564f0d9d431124b5d1a0665 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-49233088b5e73dbb96bf7af27be3d4547632e3db1c2b00f14184900613325bbc.yml +openapi_spec_hash: b34f14b141d5019244112901c5c7c2d8 +config_hash: 94e9ba08201c3d1ca46e093e6a0138fa diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dc9e9da..0eb9b9ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 0.28.0 (2025-09-30) + +Full Changelog: [v0.27.1...v0.28.0](https://github.com/openai/openai-ruby/compare/v0.27.1...v0.28.0) + +### ⚠ BREAKING CHANGES + +* **api:** `ResponseFunctionToolCallOutputItem.output` and `ResponseCustomToolCallOutput.output` now return `string | Array` instead of `string` only. This may break existing callsites that assume `output` is always a string. + +### Features + +* **api:** Support images and files for function call outputs in responses, BatchUsage ([904348a](https://github.com/openai/openai-ruby/commit/904348a26c713601f10063fef73f9982088aa438)) + + +### Bug Fixes + +* coroutine leaks from connection pool ([7f0b3cd](https://github.com/openai/openai-ruby/commit/7f0b3cdfee0232dbfa1800029ba80f5470f95c13)) + ## 0.27.1 (2025-09-29) Full Changelog: [v0.27.0...v0.27.1](https://github.com/openai/openai-ruby/compare/v0.27.0...v0.27.1) diff --git a/Gemfile.lock b/Gemfile.lock index a6273fa9..897fd805 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - openai (0.27.1) + openai (0.28.0) connection_pool GEM diff --git a/README.md b/README.md index 642344a2..c81e6ffe 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "openai", "~> 0.27.1" +gem "openai", "~> 0.28.0" ``` diff --git a/lib/openai.rb b/lib/openai.rb index 5c6a0daa..6af4b6d8 100644 --- a/lib/openai.rb +++ b/lib/openai.rb @@ -99,6 +99,7 @@ require_relative "openai/models/batch_list_params" require_relative "openai/models/batch_request_counts" require_relative "openai/models/batch_retrieve_params" +require_relative "openai/models/batch_usage" require_relative "openai/models/beta/assistant" require_relative "openai/models/beta/assistant_create_params" require_relative "openai/models/beta/assistant_deleted" @@ -537,6 +538,8 @@ require_relative "openai/models/responses/response_format_text_json_schema_config" require_relative "openai/models/responses/response_function_call_arguments_delta_event" require_relative "openai/models/responses/response_function_call_arguments_done_event" +require_relative "openai/models/responses/response_function_call_output_item" +require_relative "openai/models/responses/response_function_call_output_item_list" require_relative "openai/models/responses/response_function_tool_call_item" require_relative "openai/models/responses/response_function_tool_call_output_item" require_relative "openai/models/responses/response_function_web_search" @@ -550,9 +553,12 @@ require_relative "openai/models/responses/response_input" require_relative "openai/models/responses/response_input_audio" require_relative "openai/models/responses/response_input_content" +require_relative "openai/models/responses/response_input_file_content" +require_relative "openai/models/responses/response_input_image_content" require_relative "openai/models/responses/response_input_item" require_relative "openai/models/responses/response_input_message_content_list" require_relative "openai/models/responses/response_input_message_item" +require_relative "openai/models/responses/response_input_text_content" require_relative "openai/models/responses/response_item" require_relative "openai/models/responses/response_item_list" require_relative "openai/models/responses/response_mcp_call_arguments_delta_event" diff --git a/lib/openai/internal/transport/pooled_net_requester.rb b/lib/openai/internal/transport/pooled_net_requester.rb index 0736b441..9af98e5a 100644 --- a/lib/openai/internal/transport/pooled_net_requester.rb +++ b/lib/openai/internal/transport/pooled_net_requester.rb @@ -134,9 +134,9 @@ def execute(request) # rubocop:disable Metrics/BlockLength enum = Enumerator.new do |y| - with_pool(url, deadline: deadline) do |conn| - next if finished + next if finished + with_pool(url, deadline: deadline) do |conn| req, closing = self.class.build_request(request) do self.class.calibrate_socket_timeout(conn, deadline) end @@ -149,7 +149,7 @@ def execute(request) self.class.calibrate_socket_timeout(conn, deadline) conn.request(req) do |rsp| - y << [conn, req, rsp] + y << [req, rsp] break if finished rsp.read_body do |bytes| @@ -160,6 +160,8 @@ def execute(request) end eof = true end + ensure + conn.finish if !eof && conn&.started? end rescue Timeout::Error raise OpenAI::Errors::APITimeoutError.new(url: url, request: req) @@ -168,16 +170,11 @@ def execute(request) end # rubocop:enable Metrics/BlockLength - conn, _, response = enum.next + _, response = enum.next body = OpenAI::Internal::Util.fused_enum(enum, external: true) do finished = true - tap do - enum.next - rescue StopIteration - nil - end + loop { enum.next } ensure - conn.finish if !eof && conn&.started? closing&.call end [Integer(response.code), response, body] diff --git a/lib/openai/internal/type/base_stream.rb b/lib/openai/internal/type/base_stream.rb index 8b6acc19..38951a78 100644 --- a/lib/openai/internal/type/base_stream.rb +++ b/lib/openai/internal/type/base_stream.rb @@ -13,21 +13,6 @@ module Type module BaseStream include Enumerable - class << self - # Attempt to close the underlying transport when the stream itself is garbage - # collected. - # - # This should not be relied upon for resource clean up, as the garbage collector - # is not guaranteed to run. - # - # @param stream [Enumerable] - # - # @return [Proc] - # - # @see https://rubyapi.org/3.2/o/objectspace#method-c-define_finalizer - def defer_closing(stream) = ->(_id) { OpenAI::Internal::Util.close_fused!(stream) } - end - # @return [Integer] attr_reader :status @@ -82,8 +67,6 @@ def initialize(model:, url:, status:, headers:, response:, unwrap:, stream:) @unwrap = unwrap @stream = stream @iterator = iterator - - ObjectSpace.define_finalizer(self, OpenAI::Internal::Type::BaseStream.defer_closing(@stream)) end # @api private diff --git a/lib/openai/models.rb b/lib/openai/models.rb index ea210354..f03180d9 100644 --- a/lib/openai/models.rb +++ b/lib/openai/models.rb @@ -63,6 +63,8 @@ module OpenAI BatchRetrieveParams = OpenAI::Models::BatchRetrieveParams + BatchUsage = OpenAI::Models::BatchUsage + Beta = OpenAI::Models::Beta Chat = OpenAI::Models::Chat diff --git a/lib/openai/models/batch.rb b/lib/openai/models/batch.rb index b8dffe10..1136387e 100644 --- a/lib/openai/models/batch.rb +++ b/lib/openai/models/batch.rb @@ -115,6 +115,16 @@ class Batch < OpenAI::Internal::Type::BaseModel # @return [Hash{Symbol=>String}, nil] optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true + # @!attribute model + # Model ID used to process the batch, like `gpt-5-2025-08-07`. 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. + # + # @return [String, nil] + optional :model, String + # @!attribute output_file_id # The ID of the file containing the outputs of successfully executed requests. # @@ -127,7 +137,15 @@ class Batch < OpenAI::Internal::Type::BaseModel # @return [OpenAI::Models::BatchRequestCounts, nil] optional :request_counts, -> { OpenAI::BatchRequestCounts } - # @!method initialize(id:, completion_window:, created_at:, endpoint:, input_file_id:, status:, cancelled_at: nil, cancelling_at: nil, completed_at: nil, error_file_id: nil, errors: nil, expired_at: nil, expires_at: nil, failed_at: nil, finalizing_at: nil, in_progress_at: nil, metadata: nil, output_file_id: nil, request_counts: nil, object: :batch) + # @!attribute usage + # Represents token usage details including input tokens, output tokens, a + # breakdown of output tokens, and the total tokens used. Only populated on batches + # created after September 7, 2025. + # + # @return [OpenAI::Models::BatchUsage, nil] + optional :usage, -> { OpenAI::BatchUsage } + + # @!method initialize(id:, completion_window:, created_at:, endpoint:, input_file_id:, status:, cancelled_at: nil, cancelling_at: nil, completed_at: nil, error_file_id: nil, errors: nil, expired_at: nil, expires_at: nil, failed_at: nil, finalizing_at: nil, in_progress_at: nil, metadata: nil, model: nil, output_file_id: nil, request_counts: nil, usage: nil, object: :batch) # Some parameter documentations has been truncated, see {OpenAI::Models::Batch} # for more details. # @@ -165,10 +183,14 @@ class Batch < OpenAI::Internal::Type::BaseModel # # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be # + # @param model [String] Model ID used to process the batch, like `gpt-5-2025-08-07`. OpenAI + # # @param output_file_id [String] The ID of the file containing the outputs of successfully executed requests. # # @param request_counts [OpenAI::Models::BatchRequestCounts] The request counts for different statuses within the batch. # + # @param usage [OpenAI::Models::BatchUsage] Represents token usage details including input tokens, output tokens, a + # # @param object [Symbol, :batch] The object type, which is always `batch`. # The current status of the batch. diff --git a/lib/openai/models/batch_usage.rb b/lib/openai/models/batch_usage.rb new file mode 100644 index 00000000..003b102f --- /dev/null +++ b/lib/openai/models/batch_usage.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true + +module OpenAI + module Models + class BatchUsage < OpenAI::Internal::Type::BaseModel + # @!attribute input_tokens + # The number of input tokens. + # + # @return [Integer] + required :input_tokens, Integer + + # @!attribute input_tokens_details + # A detailed breakdown of the input tokens. + # + # @return [OpenAI::Models::BatchUsage::InputTokensDetails] + required :input_tokens_details, -> { OpenAI::BatchUsage::InputTokensDetails } + + # @!attribute output_tokens + # The number of output tokens. + # + # @return [Integer] + required :output_tokens, Integer + + # @!attribute output_tokens_details + # A detailed breakdown of the output tokens. + # + # @return [OpenAI::Models::BatchUsage::OutputTokensDetails] + required :output_tokens_details, -> { OpenAI::BatchUsage::OutputTokensDetails } + + # @!attribute total_tokens + # The total number of tokens used. + # + # @return [Integer] + required :total_tokens, Integer + + # @!method initialize(input_tokens:, input_tokens_details:, output_tokens:, output_tokens_details:, total_tokens:) + # Represents token usage details including input tokens, output tokens, a + # breakdown of output tokens, and the total tokens used. Only populated on batches + # created after September 7, 2025. + # + # @param input_tokens [Integer] The number of input tokens. + # + # @param input_tokens_details [OpenAI::Models::BatchUsage::InputTokensDetails] A detailed breakdown of the input tokens. + # + # @param output_tokens [Integer] The number of output tokens. + # + # @param output_tokens_details [OpenAI::Models::BatchUsage::OutputTokensDetails] A detailed breakdown of the output tokens. + # + # @param total_tokens [Integer] The total number of tokens used. + + # @see OpenAI::Models::BatchUsage#input_tokens_details + class InputTokensDetails < OpenAI::Internal::Type::BaseModel + # @!attribute cached_tokens + # The number of tokens that were retrieved from the cache. + # [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + # + # @return [Integer] + required :cached_tokens, Integer + + # @!method initialize(cached_tokens:) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::BatchUsage::InputTokensDetails} for more details. + # + # A detailed breakdown of the input tokens. + # + # @param cached_tokens [Integer] The number of tokens that were retrieved from the cache. [More on + end + + # @see OpenAI::Models::BatchUsage#output_tokens_details + class OutputTokensDetails < OpenAI::Internal::Type::BaseModel + # @!attribute reasoning_tokens + # The number of reasoning tokens. + # + # @return [Integer] + required :reasoning_tokens, Integer + + # @!method initialize(reasoning_tokens:) + # A detailed breakdown of the output tokens. + # + # @param reasoning_tokens [Integer] The number of reasoning tokens. + end + end + end +end diff --git a/lib/openai/models/responses/response_custom_tool_call_output.rb b/lib/openai/models/responses/response_custom_tool_call_output.rb index 644997e7..756fd3b1 100644 --- a/lib/openai/models/responses/response_custom_tool_call_output.rb +++ b/lib/openai/models/responses/response_custom_tool_call_output.rb @@ -11,10 +11,11 @@ class ResponseCustomToolCallOutput < OpenAI::Internal::Type::BaseModel required :call_id, String # @!attribute output - # The output from the custom tool call generated by your code. + # The output from the custom tool call generated by your code. Can be a string or + # an list of output content. # - # @return [String] - required :output, String + # @return [String, Array] + required :output, union: -> { OpenAI::Responses::ResponseCustomToolCallOutput::Output } # @!attribute type # The type of the custom tool call output. Always `custom_tool_call_output`. @@ -36,11 +37,53 @@ class ResponseCustomToolCallOutput < OpenAI::Internal::Type::BaseModel # # @param call_id [String] The call ID, used to map this custom tool call output to a custom tool call. # - # @param output [String] The output from the custom tool call generated by your code. + # @param output [String, Array] The output from the custom tool call generated by your code. # # @param id [String] The unique ID of the custom tool call output in the OpenAI platform. # # @param type [Symbol, :custom_tool_call_output] The type of the custom tool call output. Always `custom_tool_call_output`. + + # The output from the custom tool call generated by your code. Can be a string or + # an list of output content. + # + # @see OpenAI::Models::Responses::ResponseCustomToolCallOutput#output + module Output + extend OpenAI::Internal::Type::Union + + # A string of the output of the custom tool call. + variant String + + # Text, image, or file output of the custom tool call. + variant -> { OpenAI::Models::Responses::ResponseCustomToolCallOutput::Output::OutputContentListArray } + + # A text input to the model. + module OutputContentList + extend OpenAI::Internal::Type::Union + + discriminator :type + + # A text input to the model. + variant :input_text, -> { OpenAI::Responses::ResponseInputText } + + # An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision). + variant :input_image, -> { OpenAI::Responses::ResponseInputImage } + + # A file input to the model. + variant :input_file, -> { OpenAI::Responses::ResponseInputFile } + + # @!method self.variants + # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile)] + end + + # @!method self.variants + # @return [Array(String, Array)] + + # @type [OpenAI::Internal::Type::Converter] + OutputContentListArray = + OpenAI::Internal::Type::ArrayOf[union: -> { + OpenAI::Responses::ResponseCustomToolCallOutput::Output::OutputContentList + }] + end end end end diff --git a/lib/openai/models/responses/response_function_call_arguments_done_event.rb b/lib/openai/models/responses/response_function_call_arguments_done_event.rb index a5b29f4b..9eec88de 100644 --- a/lib/openai/models/responses/response_function_call_arguments_done_event.rb +++ b/lib/openai/models/responses/response_function_call_arguments_done_event.rb @@ -16,6 +16,12 @@ class ResponseFunctionCallArgumentsDoneEvent < OpenAI::Internal::Type::BaseModel # @return [String] required :item_id, String + # @!attribute name + # The name of the function that was called. + # + # @return [String] + required :name, String + # @!attribute output_index # The index of the output item. # @@ -33,13 +39,15 @@ class ResponseFunctionCallArgumentsDoneEvent < OpenAI::Internal::Type::BaseModel # @return [Symbol, :"response.function_call_arguments.done"] required :type, const: :"response.function_call_arguments.done" - # @!method initialize(arguments:, item_id:, output_index:, sequence_number:, type: :"response.function_call_arguments.done") + # @!method initialize(arguments:, item_id:, name:, output_index:, sequence_number:, type: :"response.function_call_arguments.done") # Emitted when function-call arguments are finalized. # # @param arguments [String] The function-call arguments. # # @param item_id [String] The ID of the item. # + # @param name [String] The name of the function that was called. + # # @param output_index [Integer] The index of the output item. # # @param sequence_number [Integer] The sequence number of this event. diff --git a/lib/openai/models/responses/response_function_call_output_item.rb b/lib/openai/models/responses/response_function_call_output_item.rb new file mode 100644 index 00000000..ac915251 --- /dev/null +++ b/lib/openai/models/responses/response_function_call_output_item.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + # A text input to the model. + module ResponseFunctionCallOutputItem + extend OpenAI::Internal::Type::Union + + discriminator :type + + # A text input to the model. + variant :input_text, -> { OpenAI::Responses::ResponseInputTextContent } + + # An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision) + variant :input_image, -> { OpenAI::Responses::ResponseInputImageContent } + + # A file input to the model. + variant :input_file, -> { OpenAI::Responses::ResponseInputFileContent } + + # @!method self.variants + # @return [Array(OpenAI::Models::Responses::ResponseInputTextContent, OpenAI::Models::Responses::ResponseInputImageContent, OpenAI::Models::Responses::ResponseInputFileContent)] + end + end + end +end diff --git a/lib/openai/models/responses/response_function_call_output_item_list.rb b/lib/openai/models/responses/response_function_call_output_item_list.rb new file mode 100644 index 00000000..a39e748f --- /dev/null +++ b/lib/openai/models/responses/response_function_call_output_item_list.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + # @type [OpenAI::Internal::Type::Converter] + ResponseFunctionCallOutputItemList = + OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Responses::ResponseFunctionCallOutputItem }] + end + end +end diff --git a/lib/openai/models/responses/response_function_tool_call_output_item.rb b/lib/openai/models/responses/response_function_tool_call_output_item.rb index bae34c36..807a0b34 100644 --- a/lib/openai/models/responses/response_function_tool_call_output_item.rb +++ b/lib/openai/models/responses/response_function_tool_call_output_item.rb @@ -17,10 +17,11 @@ class ResponseFunctionToolCallOutputItem < OpenAI::Internal::Type::BaseModel required :call_id, String # @!attribute output - # A JSON string of the output of the function tool call. + # The output from the function call generated by your code. Can be a string or an + # list of output content. # - # @return [String] - required :output, String + # @return [String, Array] + required :output, union: -> { OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output } # @!attribute type # The type of the function tool call output. Always `function_call_output`. @@ -44,12 +45,54 @@ class ResponseFunctionToolCallOutputItem < OpenAI::Internal::Type::BaseModel # # @param call_id [String] The unique ID of the function tool call generated by the model. # - # @param output [String] A JSON string of the output of the function tool call. + # @param output [String, Array] The output from the function call generated by your code. # # @param status [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status] The status of the item. One of `in_progress`, `completed`, or # # @param type [Symbol, :function_call_output] The type of the function tool call output. Always `function_call_output`. + # The output from the function call generated by your code. Can be a string or an + # list of output content. + # + # @see OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem#output + module Output + extend OpenAI::Internal::Type::Union + + # A string of the output of the function call. + variant String + + # Text, image, or file output of the function call. + variant -> { OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentListArray } + + # A text input to the model. + module OutputContentList + extend OpenAI::Internal::Type::Union + + discriminator :type + + # A text input to the model. + variant :input_text, -> { OpenAI::Responses::ResponseInputText } + + # An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision). + variant :input_image, -> { OpenAI::Responses::ResponseInputImage } + + # A file input to the model. + variant :input_file, -> { OpenAI::Responses::ResponseInputFile } + + # @!method self.variants + # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile)] + end + + # @!method self.variants + # @return [Array(String, Array)] + + # @type [OpenAI::Internal::Type::Converter] + OutputContentListArray = + OpenAI::Internal::Type::ArrayOf[union: -> { + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentList + }] + end + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. # diff --git a/lib/openai/models/responses/response_input_file_content.rb b/lib/openai/models/responses/response_input_file_content.rb new file mode 100644 index 00000000..311ed24d --- /dev/null +++ b/lib/openai/models/responses/response_input_file_content.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseInputFileContent < OpenAI::Internal::Type::BaseModel + # @!attribute type + # The type of the input item. Always `input_file`. + # + # @return [Symbol, :input_file] + required :type, const: :input_file + + # @!attribute file_data + # The base64-encoded data of the file to be sent to the model. + # + # @return [String, nil] + optional :file_data, String, nil?: true + + # @!attribute file_id + # The ID of the file to be sent to the model. + # + # @return [String, nil] + optional :file_id, String, nil?: true + + # @!attribute file_url + # The URL of the file to be sent to the model. + # + # @return [String, nil] + optional :file_url, String, nil?: true + + # @!attribute filename + # The name of the file to be sent to the model. + # + # @return [String, nil] + optional :filename, String, nil?: true + + # @!method initialize(file_data: nil, file_id: nil, file_url: nil, filename: nil, type: :input_file) + # A file input to the model. + # + # @param file_data [String, nil] The base64-encoded data of the file to be sent to the model. + # + # @param file_id [String, nil] The ID of the file to be sent to the model. + # + # @param file_url [String, nil] The URL of the file to be sent to the model. + # + # @param filename [String, nil] The name of the file to be sent to the model. + # + # @param type [Symbol, :input_file] The type of the input item. Always `input_file`. + end + end + end +end diff --git a/lib/openai/models/responses/response_input_image_content.rb b/lib/openai/models/responses/response_input_image_content.rb new file mode 100644 index 00000000..5c383ed2 --- /dev/null +++ b/lib/openai/models/responses/response_input_image_content.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseInputImageContent < OpenAI::Internal::Type::BaseModel + # @!attribute type + # The type of the input item. Always `input_image`. + # + # @return [Symbol, :input_image] + required :type, const: :input_image + + # @!attribute detail + # The detail level of the image to be sent to the model. One of `high`, `low`, or + # `auto`. Defaults to `auto`. + # + # @return [Symbol, OpenAI::Models::Responses::ResponseInputImageContent::Detail, nil] + optional :detail, enum: -> { OpenAI::Responses::ResponseInputImageContent::Detail }, nil?: true + + # @!attribute file_id + # The ID of the file to be sent to the model. + # + # @return [String, nil] + optional :file_id, String, nil?: true + + # @!attribute image_url + # The URL of the image to be sent to the model. A fully qualified URL or base64 + # encoded image in a data URL. + # + # @return [String, nil] + optional :image_url, String, nil?: true + + # @!method initialize(detail: nil, file_id: nil, image_url: nil, type: :input_image) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Responses::ResponseInputImageContent} for more details. + # + # An image input to the model. Learn about + # [image inputs](https://platform.openai.com/docs/guides/vision) + # + # @param detail [Symbol, OpenAI::Models::Responses::ResponseInputImageContent::Detail, nil] The detail level of the image to be sent to the model. One of `high`, `low`, or + # + # @param file_id [String, nil] The ID of the file to be sent to the model. + # + # @param image_url [String, nil] The URL of the image to be sent to the model. A fully qualified URL or base64 en + # + # @param type [Symbol, :input_image] The type of the input item. Always `input_image`. + + # The detail level of the image to be sent to the model. One of `high`, `low`, or + # `auto`. Defaults to `auto`. + # + # @see OpenAI::Models::Responses::ResponseInputImageContent#detail + module Detail + extend OpenAI::Internal::Type::Enum + + LOW = :low + HIGH = :high + AUTO = :auto + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/openai/models/responses/response_input_item.rb b/lib/openai/models/responses/response_input_item.rb index be0d8821..eba98f97 100644 --- a/lib/openai/models/responses/response_input_item.rb +++ b/lib/openai/models/responses/response_input_item.rb @@ -291,10 +291,10 @@ class FunctionCallOutput < OpenAI::Internal::Type::BaseModel required :call_id, String # @!attribute output - # A JSON string of the output of the function tool call. + # Text, image, or file output of the function tool call. # - # @return [String] - required :output, String + # @return [String, Array] + required :output, union: -> { OpenAI::Responses::ResponseInputItem::FunctionCallOutput::Output } # @!attribute type # The type of the function tool call output. Always `function_call_output`. @@ -327,7 +327,7 @@ class FunctionCallOutput < OpenAI::Internal::Type::BaseModel # # @param call_id [String] The unique ID of the function tool call generated by the model. # - # @param output [String] A JSON string of the output of the function tool call. + # @param output [String, Array] Text, image, or file output of the function tool call. # # @param id [String, nil] The unique ID of the function tool call output. Populated when this item is retu # @@ -335,6 +335,21 @@ class FunctionCallOutput < OpenAI::Internal::Type::BaseModel # # @param type [Symbol, :function_call_output] The type of the function tool call output. Always `function_call_output`. + # Text, image, or file output of the function tool call. + # + # @see OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput#output + module Output + extend OpenAI::Internal::Type::Union + + # A JSON string of the output of the function tool call. + variant String + + variant -> { OpenAI::Responses::ResponseFunctionCallOutputItemList } + + # @!method self.variants + # @return [Array(String, Array)] + end + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. # diff --git a/lib/openai/models/responses/response_input_text_content.rb b/lib/openai/models/responses/response_input_text_content.rb new file mode 100644 index 00000000..51979a23 --- /dev/null +++ b/lib/openai/models/responses/response_input_text_content.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module OpenAI + module Models + module Responses + class ResponseInputTextContent < OpenAI::Internal::Type::BaseModel + # @!attribute text + # The text input to the model. + # + # @return [String] + required :text, String + + # @!attribute type + # The type of the input item. Always `input_text`. + # + # @return [Symbol, :input_text] + required :type, const: :input_text + + # @!method initialize(text:, type: :input_text) + # A text input to the model. + # + # @param text [String] The text input to the model. + # + # @param type [Symbol, :input_text] The type of the input item. Always `input_text`. + end + end + end +end diff --git a/lib/openai/version.rb b/lib/openai/version.rb index c1472d01..307a12b6 100644 --- a/lib/openai/version.rb +++ b/lib/openai/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module OpenAI - VERSION = "0.27.1" + VERSION = "0.28.0" end diff --git a/rbi/openai/internal/type/base_stream.rbi b/rbi/openai/internal/type/base_stream.rbi index 16a4cdf0..9225515d 100644 --- a/rbi/openai/internal/type/base_stream.rbi +++ b/rbi/openai/internal/type/base_stream.rbi @@ -12,21 +12,6 @@ module OpenAI Message = type_member(:in) Elem = type_member(:out) - class << self - # Attempt to close the underlying transport when the stream itself is garbage - # collected. - # - # This should not be relied upon for resource clean up, as the garbage collector - # is not guaranteed to run. - sig do - params(stream: T::Enumerable[T.anything]).returns( - T.proc.params(arg0: Integer).void - ) - end - def defer_closing(stream) - end - end - sig { returns(Integer) } attr_reader :status diff --git a/rbi/openai/models.rbi b/rbi/openai/models.rbi index 0c2dd6a1..2d6d93bd 100644 --- a/rbi/openai/models.rbi +++ b/rbi/openai/models.rbi @@ -25,6 +25,8 @@ module OpenAI BatchRetrieveParams = OpenAI::Models::BatchRetrieveParams + BatchUsage = OpenAI::Models::BatchUsage + Beta = OpenAI::Models::Beta Chat = OpenAI::Models::Chat diff --git a/rbi/openai/models/batch.rbi b/rbi/openai/models/batch.rbi index 3d6ce897..4268e273 100644 --- a/rbi/openai/models/batch.rbi +++ b/rbi/openai/models/batch.rbi @@ -110,6 +110,17 @@ module OpenAI sig { returns(T.nilable(T::Hash[Symbol, String])) } attr_accessor :metadata + # Model ID used to process the batch, like `gpt-5-2025-08-07`. 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. + sig { returns(T.nilable(String)) } + attr_reader :model + + sig { params(model: String).void } + attr_writer :model + # The ID of the file containing the outputs of successfully executed requests. sig { returns(T.nilable(String)) } attr_reader :output_file_id @@ -124,6 +135,15 @@ module OpenAI sig { params(request_counts: OpenAI::BatchRequestCounts::OrHash).void } attr_writer :request_counts + # Represents token usage details including input tokens, output tokens, a + # breakdown of output tokens, and the total tokens used. Only populated on batches + # created after September 7, 2025. + sig { returns(T.nilable(OpenAI::BatchUsage)) } + attr_reader :usage + + sig { params(usage: OpenAI::BatchUsage::OrHash).void } + attr_writer :usage + sig do params( id: String, @@ -143,8 +163,10 @@ module OpenAI finalizing_at: Integer, in_progress_at: Integer, metadata: T.nilable(T::Hash[Symbol, String]), + model: String, output_file_id: String, request_counts: OpenAI::BatchRequestCounts::OrHash, + usage: OpenAI::BatchUsage::OrHash, object: Symbol ).returns(T.attached_class) end @@ -186,10 +208,20 @@ module OpenAI # Keys are strings with a maximum length of 64 characters. Values are strings with # a maximum length of 512 characters. metadata: nil, + # Model ID used to process the batch, like `gpt-5-2025-08-07`. 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. + model: nil, # The ID of the file containing the outputs of successfully executed requests. output_file_id: nil, # The request counts for different statuses within the batch. request_counts: nil, + # Represents token usage details including input tokens, output tokens, a + # breakdown of output tokens, and the total tokens used. Only populated on batches + # created after September 7, 2025. + usage: nil, # The object type, which is always `batch`. object: :batch ) @@ -216,8 +248,10 @@ module OpenAI finalizing_at: Integer, in_progress_at: Integer, metadata: T.nilable(T::Hash[Symbol, String]), + model: String, output_file_id: String, - request_counts: OpenAI::BatchRequestCounts + request_counts: OpenAI::BatchRequestCounts, + usage: OpenAI::BatchUsage } ) end diff --git a/rbi/openai/models/batch_usage.rbi b/rbi/openai/models/batch_usage.rbi new file mode 100644 index 00000000..68cb6372 --- /dev/null +++ b/rbi/openai/models/batch_usage.rbi @@ -0,0 +1,139 @@ +# typed: strong + +module OpenAI + module Models + class BatchUsage < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias { T.any(OpenAI::BatchUsage, OpenAI::Internal::AnyHash) } + + # The number of input tokens. + sig { returns(Integer) } + attr_accessor :input_tokens + + # A detailed breakdown of the input tokens. + sig { returns(OpenAI::BatchUsage::InputTokensDetails) } + attr_reader :input_tokens_details + + sig do + params( + input_tokens_details: OpenAI::BatchUsage::InputTokensDetails::OrHash + ).void + end + attr_writer :input_tokens_details + + # The number of output tokens. + sig { returns(Integer) } + attr_accessor :output_tokens + + # A detailed breakdown of the output tokens. + sig { returns(OpenAI::BatchUsage::OutputTokensDetails) } + attr_reader :output_tokens_details + + sig do + params( + output_tokens_details: OpenAI::BatchUsage::OutputTokensDetails::OrHash + ).void + end + attr_writer :output_tokens_details + + # The total number of tokens used. + sig { returns(Integer) } + attr_accessor :total_tokens + + # Represents token usage details including input tokens, output tokens, a + # breakdown of output tokens, and the total tokens used. Only populated on batches + # created after September 7, 2025. + sig do + params( + input_tokens: Integer, + input_tokens_details: OpenAI::BatchUsage::InputTokensDetails::OrHash, + output_tokens: Integer, + output_tokens_details: + OpenAI::BatchUsage::OutputTokensDetails::OrHash, + total_tokens: Integer + ).returns(T.attached_class) + end + def self.new( + # The number of input tokens. + input_tokens:, + # A detailed breakdown of the input tokens. + input_tokens_details:, + # The number of output tokens. + output_tokens:, + # A detailed breakdown of the output tokens. + output_tokens_details:, + # The total number of tokens used. + total_tokens: + ) + end + + sig do + override.returns( + { + input_tokens: Integer, + input_tokens_details: OpenAI::BatchUsage::InputTokensDetails, + output_tokens: Integer, + output_tokens_details: OpenAI::BatchUsage::OutputTokensDetails, + total_tokens: Integer + } + ) + end + def to_hash + end + + class InputTokensDetails < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::BatchUsage::InputTokensDetails, + OpenAI::Internal::AnyHash + ) + end + + # The number of tokens that were retrieved from the cache. + # [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + sig { returns(Integer) } + attr_accessor :cached_tokens + + # A detailed breakdown of the input tokens. + sig { params(cached_tokens: Integer).returns(T.attached_class) } + def self.new( + # The number of tokens that were retrieved from the cache. + # [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + cached_tokens: + ) + end + + sig { override.returns({ cached_tokens: Integer }) } + def to_hash + end + end + + class OutputTokensDetails < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::BatchUsage::OutputTokensDetails, + OpenAI::Internal::AnyHash + ) + end + + # The number of reasoning tokens. + sig { returns(Integer) } + attr_accessor :reasoning_tokens + + # A detailed breakdown of the output tokens. + sig { params(reasoning_tokens: Integer).returns(T.attached_class) } + def self.new( + # The number of reasoning tokens. + reasoning_tokens: + ) + end + + sig { override.returns({ reasoning_tokens: Integer }) } + def to_hash + end + end + end + end +end diff --git a/rbi/openai/models/responses/response_custom_tool_call_output.rbi b/rbi/openai/models/responses/response_custom_tool_call_output.rbi index b18c6a16..39fa1df2 100644 --- a/rbi/openai/models/responses/response_custom_tool_call_output.rbi +++ b/rbi/openai/models/responses/response_custom_tool_call_output.rbi @@ -16,8 +16,13 @@ module OpenAI sig { returns(String) } attr_accessor :call_id - # The output from the custom tool call generated by your code. - sig { returns(String) } + # The output from the custom tool call generated by your code. Can be a string or + # an list of output content. + sig do + returns( + OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants + ) + end attr_accessor :output # The type of the custom tool call output. Always `custom_tool_call_output`. @@ -35,7 +40,8 @@ module OpenAI sig do params( call_id: String, - output: String, + output: + OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants, id: String, type: Symbol ).returns(T.attached_class) @@ -43,7 +49,8 @@ module OpenAI def self.new( # The call ID, used to map this custom tool call output to a custom tool call. call_id:, - # The output from the custom tool call generated by your code. + # The output from the custom tool call generated by your code. Can be a string or + # an list of output content. output:, # The unique ID of the custom tool call output in the OpenAI platform. id: nil, @@ -54,11 +61,76 @@ module OpenAI sig do override.returns( - { call_id: String, output: String, type: Symbol, id: String } + { + call_id: String, + output: + OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants, + type: Symbol, + id: String + } ) end def to_hash end + + # The output from the custom tool call generated by your code. Can be a string or + # an list of output content. + module Output + extend OpenAI::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + T::Array[ + OpenAI::Responses::ResponseCustomToolCallOutput::Output::OutputContentList::Variants + ] + ) + end + + # A text input to the model. + module OutputContentList + extend OpenAI::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + OpenAI::Responses::ResponseInputText, + OpenAI::Responses::ResponseInputImage, + OpenAI::Responses::ResponseInputFile + ) + end + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseCustomToolCallOutput::Output::OutputContentList::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseCustomToolCallOutput::Output::Variants + ] + ) + end + def self.variants + end + + OutputContentListArray = + T.let( + OpenAI::Internal::Type::ArrayOf[ + union: + OpenAI::Responses::ResponseCustomToolCallOutput::Output::OutputContentList + ], + OpenAI::Internal::Type::Converter + ) + end end end end diff --git a/rbi/openai/models/responses/response_function_call_arguments_done_event.rbi b/rbi/openai/models/responses/response_function_call_arguments_done_event.rbi index dac56326..fa7d8733 100644 --- a/rbi/openai/models/responses/response_function_call_arguments_done_event.rbi +++ b/rbi/openai/models/responses/response_function_call_arguments_done_event.rbi @@ -20,6 +20,10 @@ module OpenAI sig { returns(String) } attr_accessor :item_id + # The name of the function that was called. + sig { returns(String) } + attr_accessor :name + # The index of the output item. sig { returns(Integer) } attr_accessor :output_index @@ -36,6 +40,7 @@ module OpenAI params( arguments: String, item_id: String, + name: String, output_index: Integer, sequence_number: Integer, type: Symbol @@ -46,6 +51,8 @@ module OpenAI arguments:, # The ID of the item. item_id:, + # The name of the function that was called. + name:, # The index of the output item. output_index:, # The sequence number of this event. @@ -59,6 +66,7 @@ module OpenAI { arguments: String, item_id: String, + name: String, output_index: Integer, sequence_number: Integer, type: Symbol diff --git a/rbi/openai/models/responses/response_function_call_output_item.rbi b/rbi/openai/models/responses/response_function_call_output_item.rbi new file mode 100644 index 00000000..620c89a9 --- /dev/null +++ b/rbi/openai/models/responses/response_function_call_output_item.rbi @@ -0,0 +1,31 @@ +# typed: strong + +module OpenAI + module Models + module Responses + # A text input to the model. + module ResponseFunctionCallOutputItem + extend OpenAI::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + OpenAI::Responses::ResponseInputTextContent, + OpenAI::Responses::ResponseInputImageContent, + OpenAI::Responses::ResponseInputFileContent + ) + end + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseFunctionCallOutputItem::Variants + ] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/openai/models/responses/response_function_call_output_item_list.rbi b/rbi/openai/models/responses/response_function_call_output_item_list.rbi new file mode 100644 index 00000000..60b1bd02 --- /dev/null +++ b/rbi/openai/models/responses/response_function_call_output_item_list.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module OpenAI + module Models + module Responses + ResponseFunctionCallOutputItemList = + T.let( + OpenAI::Internal::Type::ArrayOf[ + union: OpenAI::Responses::ResponseFunctionCallOutputItem + ], + OpenAI::Internal::Type::Converter + ) + end + end +end diff --git a/rbi/openai/models/responses/response_function_tool_call_output_item.rbi b/rbi/openai/models/responses/response_function_tool_call_output_item.rbi index b3820b0d..bcf934e9 100644 --- a/rbi/openai/models/responses/response_function_tool_call_output_item.rbi +++ b/rbi/openai/models/responses/response_function_tool_call_output_item.rbi @@ -20,8 +20,13 @@ module OpenAI sig { returns(String) } attr_accessor :call_id - # A JSON string of the output of the function tool call. - sig { returns(String) } + # The output from the function call generated by your code. Can be a string or an + # list of output content. + sig do + returns( + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants + ) + end attr_accessor :output # The type of the function tool call output. Always `function_call_output`. @@ -51,7 +56,8 @@ module OpenAI params( id: String, call_id: String, - output: String, + output: + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants, status: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status::OrSymbol, type: Symbol @@ -62,7 +68,8 @@ module OpenAI id:, # The unique ID of the function tool call generated by the model. call_id:, - # A JSON string of the output of the function tool call. + # The output from the function call generated by your code. Can be a string or an + # list of output content. output:, # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. @@ -77,7 +84,8 @@ module OpenAI { id: String, call_id: String, - output: String, + output: + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants, type: Symbol, status: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status::TaggedSymbol @@ -87,6 +95,65 @@ module OpenAI def to_hash end + # The output from the function call generated by your code. Can be a string or an + # list of output content. + module Output + extend OpenAI::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + T::Array[ + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentList::Variants + ] + ) + end + + # A text input to the model. + module OutputContentList + extend OpenAI::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + OpenAI::Responses::ResponseInputText, + OpenAI::Responses::ResponseInputImage, + OpenAI::Responses::ResponseInputFile + ) + end + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentList::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::Variants + ] + ) + end + def self.variants + end + + OutputContentListArray = + T.let( + OpenAI::Internal::Type::ArrayOf[ + union: + OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output::OutputContentList + ], + OpenAI::Internal::Type::Converter + ) + end + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. module Status diff --git a/rbi/openai/models/responses/response_input_file_content.rbi b/rbi/openai/models/responses/response_input_file_content.rbi new file mode 100644 index 00000000..ae35f7a3 --- /dev/null +++ b/rbi/openai/models/responses/response_input_file_content.rbi @@ -0,0 +1,75 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseInputFileContent < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Responses::ResponseInputFileContent, + OpenAI::Internal::AnyHash + ) + end + + # The type of the input item. Always `input_file`. + sig { returns(Symbol) } + attr_accessor :type + + # The base64-encoded data of the file to be sent to the model. + sig { returns(T.nilable(String)) } + attr_accessor :file_data + + # The ID of the file to be sent to the model. + sig { returns(T.nilable(String)) } + attr_accessor :file_id + + # The URL of the file to be sent to the model. + sig { returns(T.nilable(String)) } + attr_accessor :file_url + + # The name of the file to be sent to the model. + sig { returns(T.nilable(String)) } + attr_accessor :filename + + # A file input to the model. + sig do + params( + file_data: T.nilable(String), + file_id: T.nilable(String), + file_url: T.nilable(String), + filename: T.nilable(String), + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # The base64-encoded data of the file to be sent to the model. + file_data: nil, + # The ID of the file to be sent to the model. + file_id: nil, + # The URL of the file to be sent to the model. + file_url: nil, + # The name of the file to be sent to the model. + filename: nil, + # The type of the input item. Always `input_file`. + type: :input_file + ) + end + + sig do + override.returns( + { + type: Symbol, + file_data: T.nilable(String), + file_id: T.nilable(String), + file_url: T.nilable(String), + filename: T.nilable(String) + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/openai/models/responses/response_input_image_content.rbi b/rbi/openai/models/responses/response_input_image_content.rbi new file mode 100644 index 00000000..b216f9fa --- /dev/null +++ b/rbi/openai/models/responses/response_input_image_content.rbi @@ -0,0 +1,125 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseInputImageContent < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Responses::ResponseInputImageContent, + OpenAI::Internal::AnyHash + ) + end + + # The type of the input item. Always `input_image`. + sig { returns(Symbol) } + attr_accessor :type + + # The detail level of the image to be sent to the model. One of `high`, `low`, or + # `auto`. Defaults to `auto`. + sig do + returns( + T.nilable( + OpenAI::Responses::ResponseInputImageContent::Detail::OrSymbol + ) + ) + end + attr_accessor :detail + + # The ID of the file to be sent to the model. + sig { returns(T.nilable(String)) } + attr_accessor :file_id + + # The URL of the image to be sent to the model. A fully qualified URL or base64 + # encoded image in a data URL. + sig { returns(T.nilable(String)) } + attr_accessor :image_url + + # An image input to the model. Learn about + # [image inputs](https://platform.openai.com/docs/guides/vision) + sig do + params( + detail: + T.nilable( + OpenAI::Responses::ResponseInputImageContent::Detail::OrSymbol + ), + file_id: T.nilable(String), + image_url: T.nilable(String), + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # The detail level of the image to be sent to the model. One of `high`, `low`, or + # `auto`. Defaults to `auto`. + detail: nil, + # The ID of the file to be sent to the model. + file_id: nil, + # The URL of the image to be sent to the model. A fully qualified URL or base64 + # encoded image in a data URL. + image_url: nil, + # The type of the input item. Always `input_image`. + type: :input_image + ) + end + + sig do + override.returns( + { + type: Symbol, + detail: + T.nilable( + OpenAI::Responses::ResponseInputImageContent::Detail::OrSymbol + ), + file_id: T.nilable(String), + image_url: T.nilable(String) + } + ) + end + def to_hash + end + + # The detail level of the image to be sent to the model. One of `high`, `low`, or + # `auto`. Defaults to `auto`. + module Detail + extend OpenAI::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + OpenAI::Responses::ResponseInputImageContent::Detail + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LOW = + T.let( + :low, + OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol + ) + HIGH = + T.let( + :high, + OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol + ) + AUTO = + T.let( + :auto, + OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseInputImageContent::Detail::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/openai/models/responses/response_input_item.rbi b/rbi/openai/models/responses/response_input_item.rbi index 8f131b3a..041e57cc 100644 --- a/rbi/openai/models/responses/response_input_item.rbi +++ b/rbi/openai/models/responses/response_input_item.rbi @@ -508,8 +508,12 @@ module OpenAI sig { returns(String) } attr_accessor :call_id - # A JSON string of the output of the function tool call. - sig { returns(String) } + # Text, image, or file output of the function tool call. + sig do + returns( + OpenAI::Responses::ResponseInputItem::FunctionCallOutput::Output::Variants + ) + end attr_accessor :output # The type of the function tool call output. Always `function_call_output`. @@ -536,7 +540,8 @@ module OpenAI sig do params( call_id: String, - output: String, + output: + OpenAI::Responses::ResponseInputItem::FunctionCallOutput::Output::Variants, id: T.nilable(String), status: T.nilable( @@ -548,7 +553,7 @@ module OpenAI def self.new( # The unique ID of the function tool call generated by the model. call_id:, - # A JSON string of the output of the function tool call. + # Text, image, or file output of the function tool call. output:, # The unique ID of the function tool call output. Populated when this item is # returned via API. @@ -565,7 +570,8 @@ module OpenAI override.returns( { call_id: String, - output: String, + output: + OpenAI::Responses::ResponseInputItem::FunctionCallOutput::Output::Variants, type: Symbol, id: T.nilable(String), status: @@ -578,6 +584,31 @@ module OpenAI def to_hash end + # Text, image, or file output of the function tool call. + module Output + extend OpenAI::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + T::Array[ + OpenAI::Responses::ResponseFunctionCallOutputItem::Variants + ] + ) + end + + sig do + override.returns( + T::Array[ + OpenAI::Responses::ResponseInputItem::FunctionCallOutput::Output::Variants + ] + ) + end + def self.variants + end + end + # The status of the item. One of `in_progress`, `completed`, or `incomplete`. # Populated when items are returned via API. module Status diff --git a/rbi/openai/models/responses/response_input_text_content.rbi b/rbi/openai/models/responses/response_input_text_content.rbi new file mode 100644 index 00000000..dec824c3 --- /dev/null +++ b/rbi/openai/models/responses/response_input_text_content.rbi @@ -0,0 +1,39 @@ +# typed: strong + +module OpenAI + module Models + module Responses + class ResponseInputTextContent < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Responses::ResponseInputTextContent, + OpenAI::Internal::AnyHash + ) + end + + # The text input to the model. + sig { returns(String) } + attr_accessor :text + + # The type of the input item. Always `input_text`. + sig { returns(Symbol) } + attr_accessor :type + + # A text input to the model. + sig { params(text: String, type: Symbol).returns(T.attached_class) } + def self.new( + # The text input to the model. + text:, + # The type of the input item. Always `input_text`. + type: :input_text + ) + end + + sig { override.returns({ text: String, type: Symbol }) } + def to_hash + end + end + end + end +end diff --git a/sig/openai/internal/type/base_stream.rbs b/sig/openai/internal/type/base_stream.rbs index e17cf86d..031b7982 100644 --- a/sig/openai/internal/type/base_stream.rbs +++ b/sig/openai/internal/type/base_stream.rbs @@ -4,10 +4,6 @@ module OpenAI module BaseStream[Message, Elem] include Enumerable[Elem] - def self.defer_closing: ( - Enumerable[top] stream - ) -> (^(Integer arg0) -> void) - attr_reader status: Integer attr_reader headers: ::Hash[String, String] diff --git a/sig/openai/models.rbs b/sig/openai/models.rbs index cdaabf11..022e367f 100644 --- a/sig/openai/models.rbs +++ b/sig/openai/models.rbs @@ -23,6 +23,8 @@ module OpenAI class BatchRetrieveParams = OpenAI::Models::BatchRetrieveParams + class BatchUsage = OpenAI::Models::BatchUsage + module Beta = OpenAI::Models::Beta module Chat = OpenAI::Models::Chat diff --git a/sig/openai/models/batch.rbs b/sig/openai/models/batch.rbs index cdba6cdc..d466d06d 100644 --- a/sig/openai/models/batch.rbs +++ b/sig/openai/models/batch.rbs @@ -20,8 +20,10 @@ module OpenAI finalizing_at: Integer, in_progress_at: Integer, metadata: OpenAI::Models::metadata?, + model: String, output_file_id: String, - request_counts: OpenAI::BatchRequestCounts + request_counts: OpenAI::BatchRequestCounts, + usage: OpenAI::BatchUsage } class Batch < OpenAI::Internal::Type::BaseModel @@ -81,6 +83,10 @@ module OpenAI attr_accessor metadata: OpenAI::Models::metadata? + attr_reader model: String? + + def model=: (String) -> String + attr_reader output_file_id: String? def output_file_id=: (String) -> String @@ -91,6 +97,10 @@ module OpenAI OpenAI::BatchRequestCounts ) -> OpenAI::BatchRequestCounts + attr_reader usage: OpenAI::BatchUsage? + + def usage=: (OpenAI::BatchUsage) -> OpenAI::BatchUsage + def initialize: ( id: String, completion_window: String, @@ -109,8 +119,10 @@ module OpenAI ?finalizing_at: Integer, ?in_progress_at: Integer, ?metadata: OpenAI::Models::metadata?, + ?model: String, ?output_file_id: String, ?request_counts: OpenAI::BatchRequestCounts, + ?usage: OpenAI::BatchUsage, ?object: :batch ) -> void @@ -133,8 +145,10 @@ module OpenAI finalizing_at: Integer, in_progress_at: Integer, metadata: OpenAI::Models::metadata?, + model: String, output_file_id: String, - request_counts: OpenAI::BatchRequestCounts + request_counts: OpenAI::BatchRequestCounts, + usage: OpenAI::BatchUsage } type status = diff --git a/sig/openai/models/batch_usage.rbs b/sig/openai/models/batch_usage.rbs new file mode 100644 index 00000000..8875147f --- /dev/null +++ b/sig/openai/models/batch_usage.rbs @@ -0,0 +1,60 @@ +module OpenAI + module Models + type batch_usage = + { + input_tokens: Integer, + input_tokens_details: OpenAI::BatchUsage::InputTokensDetails, + output_tokens: Integer, + output_tokens_details: OpenAI::BatchUsage::OutputTokensDetails, + total_tokens: Integer + } + + class BatchUsage < OpenAI::Internal::Type::BaseModel + attr_accessor input_tokens: Integer + + attr_accessor input_tokens_details: OpenAI::BatchUsage::InputTokensDetails + + attr_accessor output_tokens: Integer + + attr_accessor output_tokens_details: OpenAI::BatchUsage::OutputTokensDetails + + attr_accessor total_tokens: Integer + + def initialize: ( + input_tokens: Integer, + input_tokens_details: OpenAI::BatchUsage::InputTokensDetails, + output_tokens: Integer, + output_tokens_details: OpenAI::BatchUsage::OutputTokensDetails, + total_tokens: Integer + ) -> void + + def to_hash: -> { + input_tokens: Integer, + input_tokens_details: OpenAI::BatchUsage::InputTokensDetails, + output_tokens: Integer, + output_tokens_details: OpenAI::BatchUsage::OutputTokensDetails, + total_tokens: Integer + } + + type input_tokens_details = { cached_tokens: Integer } + + class InputTokensDetails < OpenAI::Internal::Type::BaseModel + attr_accessor cached_tokens: Integer + + def initialize: (cached_tokens: Integer) -> void + + def to_hash: -> { cached_tokens: Integer } + end + + type output_tokens_details = { reasoning_tokens: Integer } + + class OutputTokensDetails < OpenAI::Internal::Type::BaseModel + attr_accessor reasoning_tokens: Integer + + def initialize: (reasoning_tokens: Integer) -> void + + def to_hash: -> { reasoning_tokens: Integer } + end + end + end +end diff --git a/sig/openai/models/responses/response_custom_tool_call_output.rbs b/sig/openai/models/responses/response_custom_tool_call_output.rbs index d9c9486a..2b13985d 100644 --- a/sig/openai/models/responses/response_custom_tool_call_output.rbs +++ b/sig/openai/models/responses/response_custom_tool_call_output.rbs @@ -4,7 +4,7 @@ module OpenAI type response_custom_tool_call_output = { call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseCustomToolCallOutput::output, type: :custom_tool_call_output, id: String } @@ -12,7 +12,7 @@ module OpenAI class ResponseCustomToolCallOutput < OpenAI::Internal::Type::BaseModel attr_accessor call_id: String - attr_accessor output: String + attr_accessor output: OpenAI::Models::Responses::ResponseCustomToolCallOutput::output attr_accessor type: :custom_tool_call_output @@ -22,17 +22,40 @@ module OpenAI def initialize: ( call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseCustomToolCallOutput::output, ?id: String, ?type: :custom_tool_call_output ) -> void def to_hash: -> { call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseCustomToolCallOutput::output, type: :custom_tool_call_output, id: String } + + type output = + String + | ::Array[OpenAI::Models::Responses::ResponseCustomToolCallOutput::Output::output_content_list] + + module Output + extend OpenAI::Internal::Type::Union + + type output_content_list = + OpenAI::Responses::ResponseInputText + | OpenAI::Responses::ResponseInputImage + | OpenAI::Responses::ResponseInputFile + + module OutputContentList + extend OpenAI::Internal::Type::Union + + def self?.variants: -> ::Array[OpenAI::Models::Responses::ResponseCustomToolCallOutput::Output::output_content_list] + end + + def self?.variants: -> ::Array[OpenAI::Models::Responses::ResponseCustomToolCallOutput::output] + + OutputContentListArray: OpenAI::Internal::Type::Converter + end end end end diff --git a/sig/openai/models/responses/response_function_call_arguments_done_event.rbs b/sig/openai/models/responses/response_function_call_arguments_done_event.rbs index acedda9d..c70cd343 100644 --- a/sig/openai/models/responses/response_function_call_arguments_done_event.rbs +++ b/sig/openai/models/responses/response_function_call_arguments_done_event.rbs @@ -5,6 +5,7 @@ module OpenAI { arguments: String, item_id: String, + name: String, output_index: Integer, sequence_number: Integer, type: :"response.function_call_arguments.done" @@ -15,6 +16,8 @@ module OpenAI attr_accessor item_id: String + attr_accessor name: String + attr_accessor output_index: Integer attr_accessor sequence_number: Integer @@ -24,6 +27,7 @@ module OpenAI def initialize: ( arguments: String, item_id: String, + name: String, output_index: Integer, sequence_number: Integer, ?type: :"response.function_call_arguments.done" @@ -32,6 +36,7 @@ module OpenAI def to_hash: -> { arguments: String, item_id: String, + name: String, output_index: Integer, sequence_number: Integer, type: :"response.function_call_arguments.done" diff --git a/sig/openai/models/responses/response_function_call_output_item.rbs b/sig/openai/models/responses/response_function_call_output_item.rbs new file mode 100644 index 00000000..77b6dc57 --- /dev/null +++ b/sig/openai/models/responses/response_function_call_output_item.rbs @@ -0,0 +1,16 @@ +module OpenAI + module Models + module Responses + type response_function_call_output_item = + OpenAI::Responses::ResponseInputTextContent + | OpenAI::Responses::ResponseInputImageContent + | OpenAI::Responses::ResponseInputFileContent + + module ResponseFunctionCallOutputItem + extend OpenAI::Internal::Type::Union + + def self?.variants: -> ::Array[OpenAI::Models::Responses::response_function_call_output_item] + end + end + end +end diff --git a/sig/openai/models/responses/response_function_call_output_item_list.rbs b/sig/openai/models/responses/response_function_call_output_item_list.rbs new file mode 100644 index 00000000..cf19d42e --- /dev/null +++ b/sig/openai/models/responses/response_function_call_output_item_list.rbs @@ -0,0 +1,10 @@ +module OpenAI + module Models + module Responses + type response_function_call_output_item_list = + ::Array[OpenAI::Models::Responses::response_function_call_output_item] + + ResponseFunctionCallOutputItemList: OpenAI::Internal::Type::Converter + end + end +end diff --git a/sig/openai/models/responses/response_function_tool_call_output_item.rbs b/sig/openai/models/responses/response_function_tool_call_output_item.rbs index e9a67d83..fa9ba466 100644 --- a/sig/openai/models/responses/response_function_tool_call_output_item.rbs +++ b/sig/openai/models/responses/response_function_tool_call_output_item.rbs @@ -5,7 +5,7 @@ module OpenAI { id: String, call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::output, type: :function_call_output, status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status } @@ -15,7 +15,7 @@ module OpenAI attr_accessor call_id: String - attr_accessor output: String + attr_accessor output: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::output attr_accessor type: :function_call_output @@ -28,7 +28,7 @@ module OpenAI def initialize: ( id: String, call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::output, ?status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status, ?type: :function_call_output ) -> void @@ -36,11 +36,34 @@ module OpenAI def to_hash: -> { id: String, call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::output, type: :function_call_output, status: OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::status } + type output = + String + | ::Array[OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Output::output_content_list] + + module Output + extend OpenAI::Internal::Type::Union + + type output_content_list = + OpenAI::Responses::ResponseInputText + | OpenAI::Responses::ResponseInputImage + | OpenAI::Responses::ResponseInputFile + + module OutputContentList + extend OpenAI::Internal::Type::Union + + def self?.variants: -> ::Array[OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Output::output_content_list] + end + + def self?.variants: -> ::Array[OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::output] + + OutputContentListArray: OpenAI::Internal::Type::Converter + end + type status = :in_progress | :completed | :incomplete module Status diff --git a/sig/openai/models/responses/response_input_file_content.rbs b/sig/openai/models/responses/response_input_file_content.rbs new file mode 100644 index 00000000..7aaf5c9d --- /dev/null +++ b/sig/openai/models/responses/response_input_file_content.rbs @@ -0,0 +1,42 @@ +module OpenAI + module Models + module Responses + type response_input_file_content = + { + type: :input_file, + file_data: String?, + file_id: String?, + file_url: String?, + filename: String? + } + + class ResponseInputFileContent < OpenAI::Internal::Type::BaseModel + attr_accessor type: :input_file + + attr_accessor file_data: String? + + attr_accessor file_id: String? + + attr_accessor file_url: String? + + attr_accessor filename: String? + + def initialize: ( + ?file_data: String?, + ?file_id: String?, + ?file_url: String?, + ?filename: String?, + ?type: :input_file + ) -> void + + def to_hash: -> { + type: :input_file, + file_data: String?, + file_id: String?, + file_url: String?, + filename: String? + } + end + end + end +end diff --git a/sig/openai/models/responses/response_input_image_content.rbs b/sig/openai/models/responses/response_input_image_content.rbs new file mode 100644 index 00000000..2fd3f066 --- /dev/null +++ b/sig/openai/models/responses/response_input_image_content.rbs @@ -0,0 +1,49 @@ +module OpenAI + module Models + module Responses + type response_input_image_content = + { + type: :input_image, + detail: OpenAI::Models::Responses::ResponseInputImageContent::detail?, + file_id: String?, + image_url: String? + } + + class ResponseInputImageContent < OpenAI::Internal::Type::BaseModel + attr_accessor type: :input_image + + attr_accessor detail: OpenAI::Models::Responses::ResponseInputImageContent::detail? + + attr_accessor file_id: String? + + attr_accessor image_url: String? + + def initialize: ( + ?detail: OpenAI::Models::Responses::ResponseInputImageContent::detail?, + ?file_id: String?, + ?image_url: String?, + ?type: :input_image + ) -> void + + def to_hash: -> { + type: :input_image, + detail: OpenAI::Models::Responses::ResponseInputImageContent::detail?, + file_id: String?, + image_url: String? + } + + type detail = :low | :high | :auto + + module Detail + extend OpenAI::Internal::Type::Enum + + LOW: :low + HIGH: :high + AUTO: :auto + + def self?.values: -> ::Array[OpenAI::Models::Responses::ResponseInputImageContent::detail] + end + end + end + end +end diff --git a/sig/openai/models/responses/response_input_item.rbs b/sig/openai/models/responses/response_input_item.rbs index 08461d42..484675bd 100644 --- a/sig/openai/models/responses/response_input_item.rbs +++ b/sig/openai/models/responses/response_input_item.rbs @@ -177,7 +177,7 @@ module OpenAI type function_call_output = { call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::output, type: :function_call_output, id: String?, status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status? @@ -186,7 +186,7 @@ module OpenAI class FunctionCallOutput < OpenAI::Internal::Type::BaseModel attr_accessor call_id: String - attr_accessor output: String + attr_accessor output: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::output attr_accessor type: :function_call_output @@ -196,7 +196,7 @@ module OpenAI def initialize: ( call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::output, ?id: String?, ?status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status?, ?type: :function_call_output @@ -204,12 +204,22 @@ module OpenAI def to_hash: -> { call_id: String, - output: String, + output: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::output, type: :function_call_output, id: String?, status: OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::status? } + type output = + String + | OpenAI::Models::Responses::response_function_call_output_item_list + + module Output + extend OpenAI::Internal::Type::Union + + def self?.variants: -> ::Array[OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::output] + end + type status = :in_progress | :completed | :incomplete module Status diff --git a/sig/openai/models/responses/response_input_text_content.rbs b/sig/openai/models/responses/response_input_text_content.rbs new file mode 100644 index 00000000..f3ddba54 --- /dev/null +++ b/sig/openai/models/responses/response_input_text_content.rbs @@ -0,0 +1,17 @@ +module OpenAI + module Models + module Responses + type response_input_text_content = { text: String, type: :input_text } + + class ResponseInputTextContent < OpenAI::Internal::Type::BaseModel + attr_accessor text: String + + attr_accessor type: :input_text + + def initialize: (text: String, ?type: :input_text) -> void + + def to_hash: -> { text: String, type: :input_text } + end + end + end +end diff --git a/test/openai/internal/util_test.rb b/test/openai/internal/util_test.rb index 786e7c45..2ffe5242 100644 --- a/test/openai/internal/util_test.rb +++ b/test/openai/internal/util_test.rb @@ -310,6 +310,31 @@ def test_copy_write end class OpenAI::Test::UtilFusedEnumTest < Minitest::Test + def test_rewind_closing + touched = false + once = 0 + steps = 0 + enum = Enumerator.new do |y| + next if touched + + 10.times do + steps = _1 + y << _1 + end + ensure + once = once.succ + end + + fused = OpenAI::Internal::Util.fused_enum(enum, external: true) do + touched = true + loop { enum.next } + end + OpenAI::Internal::Util.close_fused!(fused) + + assert_equal(1, once) + assert_equal(0, steps) + end + def test_closing arr = [1, 2, 3] once = 0 diff --git a/test/openai/resources/batches_test.rb b/test/openai/resources/batches_test.rb index 37bc1861..b2094e1c 100644 --- a/test/openai/resources/batches_test.rb +++ b/test/openai/resources/batches_test.rb @@ -35,8 +35,10 @@ def test_create_required_params finalizing_at: Integer | nil, in_progress_at: Integer | nil, metadata: ^(OpenAI::Internal::Type::HashOf[String]) | nil, + model: String | nil, output_file_id: String | nil, - request_counts: OpenAI::BatchRequestCounts | nil + request_counts: OpenAI::BatchRequestCounts | nil, + usage: OpenAI::BatchUsage | nil } end end @@ -68,8 +70,10 @@ def test_retrieve finalizing_at: Integer | nil, in_progress_at: Integer | nil, metadata: ^(OpenAI::Internal::Type::HashOf[String]) | nil, + model: String | nil, output_file_id: String | nil, - request_counts: OpenAI::BatchRequestCounts | nil + request_counts: OpenAI::BatchRequestCounts | nil, + usage: OpenAI::BatchUsage | nil } end end @@ -108,8 +112,10 @@ def test_list finalizing_at: Integer | nil, in_progress_at: Integer | nil, metadata: ^(OpenAI::Internal::Type::HashOf[String]) | nil, + model: String | nil, output_file_id: String | nil, - request_counts: OpenAI::BatchRequestCounts | nil + request_counts: OpenAI::BatchRequestCounts | nil, + usage: OpenAI::BatchUsage | nil } end end @@ -141,8 +147,10 @@ def test_cancel finalizing_at: Integer | nil, in_progress_at: Integer | nil, metadata: ^(OpenAI::Internal::Type::HashOf[String]) | nil, + model: String | nil, output_file_id: String | nil, - request_counts: OpenAI::BatchRequestCounts | nil + request_counts: OpenAI::BatchRequestCounts | nil, + usage: OpenAI::BatchUsage | nil } end end diff --git a/test/openai/resources/conversations/items_test.rb b/test/openai/resources/conversations/items_test.rb index 58973cb8..9bc1c90a 100644 --- a/test/openai/resources/conversations/items_test.rb +++ b/test/openai/resources/conversations/items_test.rb @@ -68,7 +68,7 @@ def test_retrieve_required_params type: :function_call_output, id: String, call_id: String, - output: String, + output: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output, status: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status | nil } in { @@ -160,7 +160,12 @@ def test_retrieve_required_params output: String | nil } in {type: :custom_tool_call, call_id: String, input: String, name: String, id: String | nil} - in {type: :custom_tool_call_output, call_id: String, output: String, id: String | nil} + in { + type: :custom_tool_call_output, + call_id: String, + output: OpenAI::Responses::ResponseCustomToolCallOutput::Output, + id: String | nil + } end end end @@ -215,7 +220,7 @@ def test_list type: :function_call_output, id: String, call_id: String, - output: String, + output: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output, status: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status | nil } in { @@ -307,7 +312,12 @@ def test_list output: String | nil } in {type: :custom_tool_call, call_id: String, input: String, name: String, id: String | nil} - in {type: :custom_tool_call_output, call_id: String, output: String, id: String | nil} + in { + type: :custom_tool_call_output, + call_id: String, + output: OpenAI::Responses::ResponseCustomToolCallOutput::Output, + id: String | nil + } end end end diff --git a/test/openai/resources/responses/input_items_test.rb b/test/openai/resources/responses/input_items_test.rb index dc76d567..9341c54c 100644 --- a/test/openai/resources/responses/input_items_test.rb +++ b/test/openai/resources/responses/input_items_test.rb @@ -87,7 +87,7 @@ def test_list type: :function_call_output, id: String, call_id: String, - output: String, + output: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Output, status: OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status | nil } in {