diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4208b5cb..1b77f506 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.6.0" + ".": "0.7.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 96c16369..8507b6ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 109 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-0205acb1015d29b2312a48526734c0399f93026d4fe2dff5c7768f566e333fd2.yml -openapi_spec_hash: 1772cc9056c2f6dfb2a4e9cb77ee6343 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-4865dda2b62927bd141cbc85f81be3d88602f103e2c581e15eb1caded3e3aaa2.yml +openapi_spec_hash: 7d14a9b23ef4ac93ea46d629601b6f6b config_hash: ed1e6b3c5f93d12b80d31167f55c557c diff --git a/CHANGELOG.md b/CHANGELOG.md index faefc38f..199988a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 0.7.0 (2025-06-09) + +Full Changelog: [v0.6.0...v0.7.0](https://github.com/openai/openai-ruby/compare/v0.6.0...v0.7.0) + +### Features + +* **api:** Add tools and structured outputs to evals ([6ee3392](https://github.com/openai/openai-ruby/commit/6ee33924e9146e2450e9c43d052886ed3214cbde)) + + +### Bug Fixes + +* default content-type for text in multi-part formdata uploads should be text/plain ([105cf47](https://github.com/openai/openai-ruby/commit/105cf4717993c744ee6c453d2a99ae03f51035d4)) +* tool parameter mapping for chat completions ([#156](https://github.com/openai/openai-ruby/issues/156)) ([5999b9f](https://github.com/openai/openai-ruby/commit/5999b9f6ad6dc73a290a8ef7b1b52bd89897039c)) +* tool parameter mapping for responses ([#704](https://github.com/openai/openai-ruby/issues/704)) ([ac8bf11](https://github.com/openai/openai-ruby/commit/ac8bf11cf59fcc778f1658429a1fc06eaca79bba)) + ## 0.6.0 (2025-06-03) Full Changelog: [v0.5.1...v0.6.0](https://github.com/openai/openai-ruby/compare/v0.5.1...v0.6.0) diff --git a/Gemfile.lock b/Gemfile.lock index 734dc4e3..6bff8bd1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - openai (0.6.0) + openai (0.7.0) connection_pool GEM diff --git a/README.md b/README.md index 44d6e015..2f63cfba 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.6.0" +gem "openai", "~> 0.7.0" ``` diff --git a/lib/openai/internal/util.rb b/lib/openai/internal/util.rb index eb5d1ffc..00653aa3 100644 --- a/lib/openai/internal/util.rb +++ b/lib/openai/internal/util.rb @@ -497,7 +497,7 @@ class << self # @param closing [Array] # @param content_type [String, nil] private def write_multipart_content(y, val:, closing:, content_type: nil) - content_type ||= "application/octet-stream" + content_line = "Content-Type: %s\r\n\r\n" case val in OpenAI::FilePart @@ -508,24 +508,21 @@ class << self content_type: val.content_type ) in Pathname - y << "Content-Type: #{content_type}\r\n\r\n" + y << format(content_line, content_type || "application/octet-stream") io = val.open(binmode: true) closing << io.method(:close) IO.copy_stream(io, y) in IO - y << "Content-Type: #{content_type}\r\n\r\n" + y << format(content_line, content_type || "application/octet-stream") IO.copy_stream(val, y) in StringIO - y << "Content-Type: #{content_type}\r\n\r\n" + y << format(content_line, content_type || "application/octet-stream") y << val.string - in String - y << "Content-Type: #{content_type}\r\n\r\n" - y << val.to_s in -> { primitive?(_1) } - y << "Content-Type: text/plain\r\n\r\n" + y << format(content_line, content_type || "text/plain") y << val.to_s else - y << "Content-Type: application/json\r\n\r\n" + y << format(content_line, content_type || "application/json") y << JSON.generate(val) end y << "\r\n" @@ -563,6 +560,8 @@ class << self # @api private # + # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content + # # @param body [Object] # # @return [Array(String, Enumerable)] diff --git a/lib/openai/models/evals/create_eval_completions_run_data_source.rb b/lib/openai/models/evals/create_eval_completions_run_data_source.rb index 28f9e688..6521c8f7 100644 --- a/lib/openai/models/evals/create_eval_completions_run_data_source.rb +++ b/lib/openai/models/evals/create_eval_completions_run_data_source.rb @@ -432,6 +432,24 @@ class SamplingParams < OpenAI::Internal::Type::BaseModel # @return [Integer, nil] optional :max_completion_tokens, Integer + # @!attribute response_format + # An object specifying the format that the model must output. + # + # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured + # Outputs which ensures the model will match your supplied JSON schema. Learn more + # in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :response_format, + union: -> { + OpenAI::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::ResponseFormat + } + # @!attribute seed # A seed value to initialize the randomness, during sampling. # @@ -444,20 +462,68 @@ class SamplingParams < OpenAI::Internal::Type::BaseModel # @return [Float, nil] optional :temperature, Float + # @!attribute tools + # A list of tools the model may call. Currently, only functions are supported as a + # tool. Use this to provide a list of functions the model may generate JSON inputs + # for. A max of 128 functions are supported. + # + # @return [Array, nil] + optional :tools, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTool] } + # @!attribute top_p # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. # # @return [Float, nil] optional :top_p, Float - # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, top_p: nil) + # @!method initialize(max_completion_tokens: nil, response_format: nil, seed: nil, temperature: nil, tools: nil, top_p: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams} for + # more details. + # # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output. # + # @param response_format [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + # # @param seed [Integer] A seed value to initialize the randomness, during sampling. # # @param temperature [Float] A higher temperature increases randomness in the outputs. # + # @param tools [Array] A list of tools the model may call. Currently, only functions are supported as a + # # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens. + + # An object specifying the format that the model must output. + # + # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured + # Outputs which ensures the model will match your supplied JSON schema. Learn more + # in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams#response_format + module ResponseFormat + extend OpenAI::Internal::Type::Union + + # Default response format. Used to generate text responses. + variant -> { OpenAI::ResponseFormatText } + + # JSON Schema response format. Used to generate structured JSON responses. + # Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs). + variant -> { OpenAI::ResponseFormatJSONSchema } + + # JSON object response format. An older method of generating JSON responses. + # Using `json_schema` is recommended for models that support it. Note that the + # model will not generate JSON without a system or user message instructing it + # to do so. + variant -> { OpenAI::ResponseFormatJSONObject } + + # @!method self.variants + # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject)] + end end end end diff --git a/lib/openai/models/evals/run_cancel_response.rb b/lib/openai/models/evals/run_cancel_response.rb index fd8642a6..74608cb9 100644 --- a/lib/openai/models/evals/run_cancel_response.rb +++ b/lib/openai/models/evals/run_cancel_response.rb @@ -616,20 +616,96 @@ class SamplingParams < OpenAI::Internal::Type::BaseModel # @return [Float, nil] optional :temperature, Float + # @!attribute 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) + # + # @return [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text, nil] + optional :text, + -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text } + + # @!attribute tools + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + # + # @return [Array, nil] + optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] } + # @!attribute top_p # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. # # @return [Float, nil] optional :top_p, Float - # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, top_p: nil) + # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams} + # for more details. + # # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output. # # @param seed [Integer] A seed value to initialize the randomness, during sampling. # # @param temperature [Float] A higher temperature increases randomness in the outputs. # + # @param text [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain + # + # @param tools [Array] An array of tools the model may call while generating a response. You + # # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens. + + # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams#text + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute format_ + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :format_, + union: -> { + OpenAI::Responses::ResponseFormatTextConfig + }, + api_name: :format + + # @!method initialize(format_: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text} + # for more details. + # + # 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) + # + # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + end end end diff --git a/lib/openai/models/evals/run_create_params.rb b/lib/openai/models/evals/run_create_params.rb index bc703e7f..8b84487a 100644 --- a/lib/openai/models/evals/run_create_params.rb +++ b/lib/openai/models/evals/run_create_params.rb @@ -576,20 +576,98 @@ class SamplingParams < OpenAI::Internal::Type::BaseModel # @return [Float, nil] optional :temperature, Float + # @!attribute 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) + # + # @return [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text, nil] + optional :text, + -> { + OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text + } + + # @!attribute tools + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + # + # @return [Array, nil] + optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] } + # @!attribute top_p # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. # # @return [Float, nil] optional :top_p, Float - # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, top_p: nil) + # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams} + # for more details. + # # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output. # # @param seed [Integer] A seed value to initialize the randomness, during sampling. # # @param temperature [Float] A higher temperature increases randomness in the outputs. # + # @param text [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text] Configuration options for a text response from the model. Can be plain + # + # @param tools [Array] An array of tools the model may call while generating a response. You + # # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens. + + # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams#text + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute format_ + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :format_, + union: -> { + OpenAI::Responses::ResponseFormatTextConfig + }, + api_name: :format + + # @!method initialize(format_: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text} + # for more details. + # + # 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) + # + # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + end end end diff --git a/lib/openai/models/evals/run_create_response.rb b/lib/openai/models/evals/run_create_response.rb index 3a110d09..73327ea2 100644 --- a/lib/openai/models/evals/run_create_response.rb +++ b/lib/openai/models/evals/run_create_response.rb @@ -616,20 +616,96 @@ class SamplingParams < OpenAI::Internal::Type::BaseModel # @return [Float, nil] optional :temperature, Float + # @!attribute 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) + # + # @return [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text, nil] + optional :text, + -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text } + + # @!attribute tools + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + # + # @return [Array, nil] + optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] } + # @!attribute top_p # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. # # @return [Float, nil] optional :top_p, Float - # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, top_p: nil) + # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams} + # for more details. + # # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output. # # @param seed [Integer] A seed value to initialize the randomness, during sampling. # # @param temperature [Float] A higher temperature increases randomness in the outputs. # + # @param text [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain + # + # @param tools [Array] An array of tools the model may call while generating a response. You + # # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens. + + # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams#text + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute format_ + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :format_, + union: -> { + OpenAI::Responses::ResponseFormatTextConfig + }, + api_name: :format + + # @!method initialize(format_: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text} + # for more details. + # + # 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) + # + # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + end end end diff --git a/lib/openai/models/evals/run_list_response.rb b/lib/openai/models/evals/run_list_response.rb index 83907899..0f8abfad 100644 --- a/lib/openai/models/evals/run_list_response.rb +++ b/lib/openai/models/evals/run_list_response.rb @@ -616,20 +616,95 @@ class SamplingParams < OpenAI::Internal::Type::BaseModel # @return [Float, nil] optional :temperature, Float + # @!attribute 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) + # + # @return [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text, nil] + optional :text, -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text } + + # @!attribute tools + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + # + # @return [Array, nil] + optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] } + # @!attribute top_p # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. # # @return [Float, nil] optional :top_p, Float - # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, top_p: nil) + # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams} + # for more details. + # # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output. # # @param seed [Integer] A seed value to initialize the randomness, during sampling. # # @param temperature [Float] A higher temperature increases randomness in the outputs. # + # @param text [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain + # + # @param tools [Array] An array of tools the model may call while generating a response. You + # # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens. + + # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams#text + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute format_ + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :format_, + union: -> { + OpenAI::Responses::ResponseFormatTextConfig + }, + api_name: :format + + # @!method initialize(format_: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text} + # for more details. + # + # 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) + # + # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + end end end diff --git a/lib/openai/models/evals/run_retrieve_response.rb b/lib/openai/models/evals/run_retrieve_response.rb index 9db0bb26..20526587 100644 --- a/lib/openai/models/evals/run_retrieve_response.rb +++ b/lib/openai/models/evals/run_retrieve_response.rb @@ -620,20 +620,96 @@ class SamplingParams < OpenAI::Internal::Type::BaseModel # @return [Float, nil] optional :temperature, Float + # @!attribute 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) + # + # @return [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text, nil] + optional :text, + -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text } + + # @!attribute tools + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + # + # @return [Array, nil] + optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] } + # @!attribute top_p # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. # # @return [Float, nil] optional :top_p, Float - # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, top_p: nil) + # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams} + # for more details. + # # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output. # # @param seed [Integer] A seed value to initialize the randomness, during sampling. # # @param temperature [Float] A higher temperature increases randomness in the outputs. # + # @param text [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain + # + # @param tools [Array] An array of tools the model may call while generating a response. You + # # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens. + + # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams#text + class Text < OpenAI::Internal::Type::BaseModel + # @!attribute format_ + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + # + # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil] + optional :format_, + union: -> { + OpenAI::Responses::ResponseFormatTextConfig + }, + api_name: :format + + # @!method initialize(format_: nil) + # Some parameter documentations has been truncated, see + # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text} + # for more details. + # + # 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) + # + # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output. + end end end diff --git a/lib/openai/resources/chat/completions.rb b/lib/openai/resources/chat/completions.rb index 9d3ee4d9..16c8d711 100644 --- a/lib/openai/resources/chat/completions.rb +++ b/lib/openai/resources/chat/completions.rb @@ -140,7 +140,9 @@ def create(params) name = func[:name] ||= params.name.split("::").last tool_models.store(name, params) func.update(parameters: params.to_json_schema) + tool else + tool end end tools.replace(mapped) diff --git a/lib/openai/resources/responses.rb b/lib/openai/resources/responses.rb index 2a837bab..64f9f674 100644 --- a/lib/openai/resources/responses.rb +++ b/lib/openai/resources/responses.rb @@ -117,7 +117,9 @@ def create(params) name = func[:name] ||= params.name.split("::").last tool_models.store(name, params) func.update(parameters: params.to_json_schema) + tool else + tool end end tools.replace(mapped) diff --git a/lib/openai/version.rb b/lib/openai/version.rb index 1e8185cd..c2177e7b 100644 --- a/lib/openai/version.rb +++ b/lib/openai/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module OpenAI - VERSION = "0.6.0" + VERSION = "0.7.0" end diff --git a/rbi/openai/internal/util.rbi b/rbi/openai/internal/util.rbi index ddce5834..69ba15c5 100644 --- a/rbi/openai/internal/util.rbi +++ b/rbi/openai/internal/util.rbi @@ -332,6 +332,8 @@ module OpenAI end # @api private + # + # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content sig do params(body: T.anything).returns([String, T::Enumerable[String]]) end diff --git a/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi b/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi index 3b8ebdb7..8298b14c 100644 --- a/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi +++ b/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi @@ -814,6 +814,41 @@ module OpenAI sig { params(max_completion_tokens: Integer).void } attr_writer :max_completion_tokens + # An object specifying the format that the model must output. + # + # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured + # Outputs which ensures the model will match your supplied JSON schema. Learn more + # in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable( + T.any( + OpenAI::ResponseFormatText, + OpenAI::ResponseFormatJSONSchema, + OpenAI::ResponseFormatJSONObject + ) + ) + ) + end + attr_reader :response_format + + sig do + params( + response_format: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::ResponseFormatJSONSchema::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :response_format + # A seed value to initialize the randomness, during sampling. sig { returns(T.nilable(Integer)) } attr_reader :seed @@ -828,6 +863,19 @@ module OpenAI sig { params(temperature: Float).void } attr_writer :temperature + # A list of tools the model may call. Currently, only functions are supported as a + # tool. Use this to provide a list of functions the model may generate JSON inputs + # for. A max of 128 functions are supported. + sig { returns(T.nilable(T::Array[OpenAI::Chat::ChatCompletionTool])) } + attr_reader :tools + + sig do + params( + tools: T::Array[OpenAI::Chat::ChatCompletionTool::OrHash] + ).void + end + attr_writer :tools + # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. sig { returns(T.nilable(Float)) } attr_reader :top_p @@ -838,18 +886,40 @@ module OpenAI sig do params( max_completion_tokens: Integer, + response_format: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::ResponseFormatJSONSchema::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ), seed: Integer, temperature: Float, + tools: T::Array[OpenAI::Chat::ChatCompletionTool::OrHash], top_p: Float ).returns(T.attached_class) end def self.new( # The maximum number of tokens in the generated output. max_completion_tokens: nil, + # An object specifying the format that the model must output. + # + # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured + # Outputs which ensures the model will match your supplied JSON schema. Learn more + # in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + response_format: nil, # A seed value to initialize the randomness, during sampling. seed: nil, # A higher temperature increases randomness in the outputs. temperature: nil, + # A list of tools the model may call. Currently, only functions are supported as a + # tool. Use this to provide a list of functions the model may generate JSON inputs + # for. A max of 128 functions are supported. + tools: nil, # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. top_p: nil ) @@ -859,14 +929,54 @@ module OpenAI override.returns( { max_completion_tokens: Integer, + response_format: + T.any( + OpenAI::ResponseFormatText, + OpenAI::ResponseFormatJSONSchema, + OpenAI::ResponseFormatJSONObject + ), seed: Integer, temperature: Float, + tools: T::Array[OpenAI::Chat::ChatCompletionTool], top_p: Float } ) end def to_hash end + + # An object specifying the format that the model must output. + # + # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured + # Outputs which ensures the model will match your supplied JSON schema. Learn more + # in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + module ResponseFormat + extend OpenAI::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + OpenAI::ResponseFormatText, + OpenAI::ResponseFormatJSONSchema, + OpenAI::ResponseFormatJSONObject + ) + end + + sig do + override.returns( + T::Array[ + OpenAI::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::ResponseFormat::Variants + ] + ) + end + def self.variants + end + end end end end diff --git a/rbi/openai/models/evals/run_cancel_response.rbi b/rbi/openai/models/evals/run_cancel_response.rbi index d6f3d390..9ac8bf15 100644 --- a/rbi/openai/models/evals/run_cancel_response.rbi +++ b/rbi/openai/models/evals/run_cancel_response.rbi @@ -1056,6 +1056,66 @@ module OpenAI sig { params(temperature: Float).void } attr_writer :temperature + # 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) + sig do + returns( + T.nilable( + OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text + ) + ) + end + attr_reader :text + + sig do + params( + text: + OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text::OrHash + ).void + end + attr_writer :text + + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + sig do + returns(T.nilable(T::Array[OpenAI::Responses::Tool::Variants])) + end + attr_reader :tools + + sig do + params( + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ] + ).void + end + attr_writer :tools + # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. sig { returns(T.nilable(Float)) } attr_reader :top_p @@ -1068,6 +1128,21 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text::OrHash, + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ], top_p: Float ).returns(T.attached_class) end @@ -1078,6 +1153,27 @@ module OpenAI seed: nil, # A higher temperature increases randomness in the outputs. temperature: nil, + # 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) + text: nil, + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + tools: nil, # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. top_p: nil ) @@ -1089,12 +1185,103 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text, + tools: T::Array[OpenAI::Responses::Tool::Variants], top_p: Float } ) end def to_hash end + + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text, + OpenAI::Internal::AnyHash + ) + end + + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable( + OpenAI::Responses::ResponseFormatTextConfig::Variants + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :format_ + + # 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) + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + format_: nil + ) + end + + sig do + override.returns( + { + format_: + OpenAI::Responses::ResponseFormatTextConfig::Variants + } + ) + end + def to_hash + end + end end end diff --git a/rbi/openai/models/evals/run_create_params.rbi b/rbi/openai/models/evals/run_create_params.rbi index eba90132..32ad2f72 100644 --- a/rbi/openai/models/evals/run_create_params.rbi +++ b/rbi/openai/models/evals/run_create_params.rbi @@ -1008,6 +1008,81 @@ module OpenAI sig { params(temperature: Float).void } attr_writer :temperature + # 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) + sig do + returns( + T.nilable( + OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text + ) + ) + end + attr_reader :text + + sig do + params( + text: + OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text::OrHash + ).void + end + attr_writer :text + + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + sig do + returns( + T.nilable( + T::Array[ + T.any( + OpenAI::Responses::FunctionTool, + OpenAI::Responses::FileSearchTool, + OpenAI::Responses::ComputerTool, + OpenAI::Responses::Tool::Mcp, + OpenAI::Responses::Tool::CodeInterpreter, + OpenAI::Responses::Tool::ImageGeneration, + OpenAI::Responses::Tool::LocalShell, + OpenAI::Responses::WebSearchTool + ) + ] + ) + ) + end + attr_reader :tools + + sig do + params( + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ] + ).void + end + attr_writer :tools + # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. sig { returns(T.nilable(Float)) } attr_reader :top_p @@ -1020,6 +1095,21 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text::OrHash, + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ], top_p: Float ).returns(T.attached_class) end @@ -1030,6 +1120,27 @@ module OpenAI seed: nil, # A higher temperature increases randomness in the outputs. temperature: nil, + # 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) + text: nil, + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + tools: nil, # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. top_p: nil ) @@ -1041,12 +1152,123 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text, + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool, + OpenAI::Responses::FileSearchTool, + OpenAI::Responses::ComputerTool, + OpenAI::Responses::Tool::Mcp, + OpenAI::Responses::Tool::CodeInterpreter, + OpenAI::Responses::Tool::ImageGeneration, + OpenAI::Responses::Tool::LocalShell, + OpenAI::Responses::WebSearchTool + ) + ], top_p: Float } ) end def to_hash end + + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text, + OpenAI::Internal::AnyHash + ) + end + + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable( + T.any( + OpenAI::ResponseFormatText, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig, + OpenAI::ResponseFormatJSONObject + ) + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :format_ + + # 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) + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + format_: nil + ) + end + + sig do + override.returns( + { + format_: + T.any( + OpenAI::ResponseFormatText, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig, + OpenAI::ResponseFormatJSONObject + ) + } + ) + end + def to_hash + end + end end end diff --git a/rbi/openai/models/evals/run_create_response.rbi b/rbi/openai/models/evals/run_create_response.rbi index 32cae98d..ae40fb83 100644 --- a/rbi/openai/models/evals/run_create_response.rbi +++ b/rbi/openai/models/evals/run_create_response.rbi @@ -1056,6 +1056,66 @@ module OpenAI sig { params(temperature: Float).void } attr_writer :temperature + # 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) + sig do + returns( + T.nilable( + OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text + ) + ) + end + attr_reader :text + + sig do + params( + text: + OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text::OrHash + ).void + end + attr_writer :text + + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + sig do + returns(T.nilable(T::Array[OpenAI::Responses::Tool::Variants])) + end + attr_reader :tools + + sig do + params( + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ] + ).void + end + attr_writer :tools + # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. sig { returns(T.nilable(Float)) } attr_reader :top_p @@ -1068,6 +1128,21 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text::OrHash, + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ], top_p: Float ).returns(T.attached_class) end @@ -1078,6 +1153,27 @@ module OpenAI seed: nil, # A higher temperature increases randomness in the outputs. temperature: nil, + # 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) + text: nil, + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + tools: nil, # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. top_p: nil ) @@ -1089,12 +1185,103 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text, + tools: T::Array[OpenAI::Responses::Tool::Variants], top_p: Float } ) end def to_hash end + + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text, + OpenAI::Internal::AnyHash + ) + end + + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable( + OpenAI::Responses::ResponseFormatTextConfig::Variants + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :format_ + + # 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) + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + format_: nil + ) + end + + sig do + override.returns( + { + format_: + OpenAI::Responses::ResponseFormatTextConfig::Variants + } + ) + end + def to_hash + end + end end end diff --git a/rbi/openai/models/evals/run_list_response.rbi b/rbi/openai/models/evals/run_list_response.rbi index 272e7bb7..9d45d00b 100644 --- a/rbi/openai/models/evals/run_list_response.rbi +++ b/rbi/openai/models/evals/run_list_response.rbi @@ -1052,6 +1052,66 @@ module OpenAI sig { params(temperature: Float).void } attr_writer :temperature + # 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) + sig do + returns( + T.nilable( + OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text + ) + ) + end + attr_reader :text + + sig do + params( + text: + OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text::OrHash + ).void + end + attr_writer :text + + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + sig do + returns(T.nilable(T::Array[OpenAI::Responses::Tool::Variants])) + end + attr_reader :tools + + sig do + params( + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ] + ).void + end + attr_writer :tools + # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. sig { returns(T.nilable(Float)) } attr_reader :top_p @@ -1064,6 +1124,21 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text::OrHash, + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ], top_p: Float ).returns(T.attached_class) end @@ -1074,6 +1149,27 @@ module OpenAI seed: nil, # A higher temperature increases randomness in the outputs. temperature: nil, + # 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) + text: nil, + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + tools: nil, # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. top_p: nil ) @@ -1085,12 +1181,103 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text, + tools: T::Array[OpenAI::Responses::Tool::Variants], top_p: Float } ) end def to_hash end + + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text, + OpenAI::Internal::AnyHash + ) + end + + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable( + OpenAI::Responses::ResponseFormatTextConfig::Variants + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :format_ + + # 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) + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + format_: nil + ) + end + + sig do + override.returns( + { + format_: + OpenAI::Responses::ResponseFormatTextConfig::Variants + } + ) + end + def to_hash + end + end end end diff --git a/rbi/openai/models/evals/run_retrieve_response.rbi b/rbi/openai/models/evals/run_retrieve_response.rbi index a51ecb78..3a1d9ea8 100644 --- a/rbi/openai/models/evals/run_retrieve_response.rbi +++ b/rbi/openai/models/evals/run_retrieve_response.rbi @@ -1058,6 +1058,66 @@ module OpenAI sig { params(temperature: Float).void } attr_writer :temperature + # 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) + sig do + returns( + T.nilable( + OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text + ) + ) + end + attr_reader :text + + sig do + params( + text: + OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text::OrHash + ).void + end + attr_writer :text + + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + sig do + returns(T.nilable(T::Array[OpenAI::Responses::Tool::Variants])) + end + attr_reader :tools + + sig do + params( + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ] + ).void + end + attr_writer :tools + # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. sig { returns(T.nilable(Float)) } attr_reader :top_p @@ -1070,6 +1130,21 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text::OrHash, + tools: + T::Array[ + T.any( + OpenAI::Responses::FunctionTool::OrHash, + OpenAI::Responses::FileSearchTool::OrHash, + OpenAI::Responses::ComputerTool::OrHash, + OpenAI::Responses::Tool::Mcp::OrHash, + OpenAI::Responses::Tool::CodeInterpreter::OrHash, + OpenAI::Responses::Tool::ImageGeneration::OrHash, + OpenAI::Responses::Tool::LocalShell::OrHash, + OpenAI::Responses::WebSearchTool::OrHash + ) + ], top_p: Float ).returns(T.attached_class) end @@ -1080,6 +1155,27 @@ module OpenAI seed: nil, # A higher temperature increases randomness in the outputs. temperature: nil, + # 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) + text: nil, + # An array of tools the model may call while generating a response. You can + # specify which tool to use by setting the `tool_choice` parameter. + # + # The two categories of tools you can provide the model are: + # + # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's + # capabilities, like + # [web search](https://platform.openai.com/docs/guides/tools-web-search) or + # [file search](https://platform.openai.com/docs/guides/tools-file-search). + # Learn more about + # [built-in tools](https://platform.openai.com/docs/guides/tools). + # - **Function calls (custom tools)**: Functions that are defined by you, enabling + # the model to call your own code. Learn more about + # [function calling](https://platform.openai.com/docs/guides/function-calling). + tools: nil, # An alternative to temperature for nucleus sampling; 1.0 includes all tokens. top_p: nil ) @@ -1091,12 +1187,103 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: + OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text, + tools: T::Array[OpenAI::Responses::Tool::Variants], top_p: Float } ) end def to_hash end + + class Text < OpenAI::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text, + OpenAI::Internal::AnyHash + ) + end + + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + sig do + returns( + T.nilable( + OpenAI::Responses::ResponseFormatTextConfig::Variants + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).void + end + attr_writer :format_ + + # 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) + sig do + params( + format_: + T.any( + OpenAI::ResponseFormatText::OrHash, + OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash, + OpenAI::ResponseFormatJSONObject::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # An object specifying the format that the model must output. + # + # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which + # ensures the model will match your supplied JSON schema. Learn more in the + # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + # + # The default format is `{ "type": "text" }` with no additional options. + # + # **Not recommended for gpt-4o and newer models:** + # + # Setting to `{ "type": "json_object" }` enables the older JSON mode, which + # ensures the message the model generates is valid JSON. Using `json_schema` is + # preferred for models that support it. + format_: nil + ) + end + + sig do + override.returns( + { + format_: + OpenAI::Responses::ResponseFormatTextConfig::Variants + } + ) + end + def to_hash + end + end end end diff --git a/sig/openai/models/evals/create_eval_completions_run_data_source.rbs b/sig/openai/models/evals/create_eval_completions_run_data_source.rbs index 181d516b..8c12eed5 100644 --- a/sig/openai/models/evals/create_eval_completions_run_data_source.rbs +++ b/sig/openai/models/evals/create_eval_completions_run_data_source.rbs @@ -303,8 +303,10 @@ module OpenAI type sampling_params = { max_completion_tokens: Integer, + response_format: OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::response_format, seed: Integer, temperature: Float, + tools: ::Array[OpenAI::Chat::ChatCompletionTool], top_p: Float } @@ -313,6 +315,12 @@ module OpenAI def max_completion_tokens=: (Integer) -> Integer + attr_reader response_format: OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::response_format? + + def response_format=: ( + OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::response_format + ) -> OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::response_format + attr_reader seed: Integer? def seed=: (Integer) -> Integer @@ -321,23 +329,44 @@ module OpenAI def temperature=: (Float) -> Float + attr_reader tools: ::Array[OpenAI::Chat::ChatCompletionTool]? + + def tools=: ( + ::Array[OpenAI::Chat::ChatCompletionTool] + ) -> ::Array[OpenAI::Chat::ChatCompletionTool] + attr_reader top_p: Float? def top_p=: (Float) -> Float def initialize: ( ?max_completion_tokens: Integer, + ?response_format: OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::response_format, ?seed: Integer, ?temperature: Float, + ?tools: ::Array[OpenAI::Chat::ChatCompletionTool], ?top_p: Float ) -> void def to_hash: -> { max_completion_tokens: Integer, + response_format: OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::response_format, seed: Integer, temperature: Float, + tools: ::Array[OpenAI::Chat::ChatCompletionTool], top_p: Float } + + type response_format = + OpenAI::ResponseFormatText + | OpenAI::ResponseFormatJSONSchema + | OpenAI::ResponseFormatJSONObject + + module ResponseFormat + extend OpenAI::Internal::Type::Union + + def self?.variants: -> ::Array[OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::response_format] + end end end end diff --git a/sig/openai/models/evals/run_cancel_response.rbs b/sig/openai/models/evals/run_cancel_response.rbs index 53408038..b9897b66 100644 --- a/sig/openai/models/evals/run_cancel_response.rbs +++ b/sig/openai/models/evals/run_cancel_response.rbs @@ -427,6 +427,8 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } @@ -443,6 +445,18 @@ module OpenAI def temperature=: (Float) -> Float + attr_reader text: OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text? + + def text=: ( + OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text + ) -> OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text + + attr_reader tools: ::Array[OpenAI::Models::Responses::tool]? + + def tools=: ( + ::Array[OpenAI::Models::Responses::tool] + ) -> ::Array[OpenAI::Models::Responses::tool] + attr_reader top_p: Float? def top_p=: (Float) -> Float @@ -451,6 +465,8 @@ module OpenAI ?max_completion_tokens: Integer, ?seed: Integer, ?temperature: Float, + ?text: OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text, + ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_p: Float ) -> void @@ -458,8 +474,31 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } + + type text = + { + format_: OpenAI::Models::Responses::response_format_text_config + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_reader format_: OpenAI::Models::Responses::response_format_text_config? + + def format_=: ( + OpenAI::Models::Responses::response_format_text_config + ) -> OpenAI::Models::Responses::response_format_text_config + + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config + ) -> void + + def to_hash: -> { + format_: OpenAI::Models::Responses::response_format_text_config + } + end end end diff --git a/sig/openai/models/evals/run_create_params.rbs b/sig/openai/models/evals/run_create_params.rbs index 7c36c313..1d4e8ac2 100644 --- a/sig/openai/models/evals/run_create_params.rbs +++ b/sig/openai/models/evals/run_create_params.rbs @@ -390,6 +390,8 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } @@ -406,6 +408,18 @@ module OpenAI def temperature=: (Float) -> Float + attr_reader text: OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text? + + def text=: ( + OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text + ) -> OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text + + attr_reader tools: ::Array[OpenAI::Models::Responses::tool]? + + def tools=: ( + ::Array[OpenAI::Models::Responses::tool] + ) -> ::Array[OpenAI::Models::Responses::tool] + attr_reader top_p: Float? def top_p=: (Float) -> Float @@ -414,6 +428,8 @@ module OpenAI ?max_completion_tokens: Integer, ?seed: Integer, ?temperature: Float, + ?text: OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text, + ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_p: Float ) -> void @@ -421,8 +437,31 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } + + type text = + { + format_: OpenAI::Models::Responses::response_format_text_config + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_reader format_: OpenAI::Models::Responses::response_format_text_config? + + def format_=: ( + OpenAI::Models::Responses::response_format_text_config + ) -> OpenAI::Models::Responses::response_format_text_config + + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config + ) -> void + + def to_hash: -> { + format_: OpenAI::Models::Responses::response_format_text_config + } + end end end diff --git a/sig/openai/models/evals/run_create_response.rbs b/sig/openai/models/evals/run_create_response.rbs index 6076ce25..97e64211 100644 --- a/sig/openai/models/evals/run_create_response.rbs +++ b/sig/openai/models/evals/run_create_response.rbs @@ -427,6 +427,8 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } @@ -443,6 +445,18 @@ module OpenAI def temperature=: (Float) -> Float + attr_reader text: OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text? + + def text=: ( + OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text + ) -> OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text + + attr_reader tools: ::Array[OpenAI::Models::Responses::tool]? + + def tools=: ( + ::Array[OpenAI::Models::Responses::tool] + ) -> ::Array[OpenAI::Models::Responses::tool] + attr_reader top_p: Float? def top_p=: (Float) -> Float @@ -451,6 +465,8 @@ module OpenAI ?max_completion_tokens: Integer, ?seed: Integer, ?temperature: Float, + ?text: OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text, + ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_p: Float ) -> void @@ -458,8 +474,31 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } + + type text = + { + format_: OpenAI::Models::Responses::response_format_text_config + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_reader format_: OpenAI::Models::Responses::response_format_text_config? + + def format_=: ( + OpenAI::Models::Responses::response_format_text_config + ) -> OpenAI::Models::Responses::response_format_text_config + + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config + ) -> void + + def to_hash: -> { + format_: OpenAI::Models::Responses::response_format_text_config + } + end end end diff --git a/sig/openai/models/evals/run_list_response.rbs b/sig/openai/models/evals/run_list_response.rbs index b87620d8..be5a46e1 100644 --- a/sig/openai/models/evals/run_list_response.rbs +++ b/sig/openai/models/evals/run_list_response.rbs @@ -427,6 +427,8 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } @@ -443,6 +445,18 @@ module OpenAI def temperature=: (Float) -> Float + attr_reader text: OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text? + + def text=: ( + OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text + ) -> OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text + + attr_reader tools: ::Array[OpenAI::Models::Responses::tool]? + + def tools=: ( + ::Array[OpenAI::Models::Responses::tool] + ) -> ::Array[OpenAI::Models::Responses::tool] + attr_reader top_p: Float? def top_p=: (Float) -> Float @@ -451,6 +465,8 @@ module OpenAI ?max_completion_tokens: Integer, ?seed: Integer, ?temperature: Float, + ?text: OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text, + ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_p: Float ) -> void @@ -458,8 +474,31 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } + + type text = + { + format_: OpenAI::Models::Responses::response_format_text_config + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_reader format_: OpenAI::Models::Responses::response_format_text_config? + + def format_=: ( + OpenAI::Models::Responses::response_format_text_config + ) -> OpenAI::Models::Responses::response_format_text_config + + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config + ) -> void + + def to_hash: -> { + format_: OpenAI::Models::Responses::response_format_text_config + } + end end end diff --git a/sig/openai/models/evals/run_retrieve_response.rbs b/sig/openai/models/evals/run_retrieve_response.rbs index 97d98b20..63418be1 100644 --- a/sig/openai/models/evals/run_retrieve_response.rbs +++ b/sig/openai/models/evals/run_retrieve_response.rbs @@ -427,6 +427,8 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } @@ -443,6 +445,18 @@ module OpenAI def temperature=: (Float) -> Float + attr_reader text: OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text? + + def text=: ( + OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text + ) -> OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text + + attr_reader tools: ::Array[OpenAI::Models::Responses::tool]? + + def tools=: ( + ::Array[OpenAI::Models::Responses::tool] + ) -> ::Array[OpenAI::Models::Responses::tool] + attr_reader top_p: Float? def top_p=: (Float) -> Float @@ -451,6 +465,8 @@ module OpenAI ?max_completion_tokens: Integer, ?seed: Integer, ?temperature: Float, + ?text: OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text, + ?tools: ::Array[OpenAI::Models::Responses::tool], ?top_p: Float ) -> void @@ -458,8 +474,31 @@ module OpenAI max_completion_tokens: Integer, seed: Integer, temperature: Float, + text: OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text, + tools: ::Array[OpenAI::Models::Responses::tool], top_p: Float } + + type text = + { + format_: OpenAI::Models::Responses::response_format_text_config + } + + class Text < OpenAI::Internal::Type::BaseModel + attr_reader format_: OpenAI::Models::Responses::response_format_text_config? + + def format_=: ( + OpenAI::Models::Responses::response_format_text_config + ) -> OpenAI::Models::Responses::response_format_text_config + + def initialize: ( + ?format_: OpenAI::Models::Responses::response_format_text_config + ) -> void + + def to_hash: -> { + format_: OpenAI::Models::Responses::response_format_text_config + } + end end end