Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .solargraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include:
- 'Rakefile'
- 'examples/**/*.rb'
- 'lib/**/*.rb'
- 'test/openai/resource_namespaces.rb'
- 'test/openai/test_helper.rb'
exclude:
- 'rbi/**/*'
2 changes: 1 addition & 1 deletion lib/openai/internal/transport/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def initialize(
end

# Execute the request specified by `req`. This is the method that all resource
# methods call into.
# methods call into.
#
# @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: OpenAI::Internal::Type::Unknown, options: {})
#
Expand Down
2 changes: 1 addition & 1 deletion lib/openai/internal/transport/pooled_net_requester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Transport
# @api private
class PooledNetRequester
# from the golang stdlib
# https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
# https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
KEEP_ALIVE_TIMEOUT = 30

class << self
Expand Down
22 changes: 11 additions & 11 deletions lib/openai/internal/type/base_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class << self
# @api private
#
# Assumes superclass fields are totally defined before fields are accessed /
# defined on subclasses.
# defined on subclasses.
#
# @return [Hash{Symbol=>Hash{Symbol=>Object}}]
def known_fields
Expand Down Expand Up @@ -143,7 +143,7 @@ def optional(name_sym, type_info, spec = {})
# @api private
#
# `request_only` attributes not excluded from `.#coerce` when receiving responses
# even if well behaved servers should not send them
# even if well behaved servers should not send them
#
# @param blk [Proc]
private def request_only(&blk)
Expand Down Expand Up @@ -291,11 +291,11 @@ def dump(value)
end

# Returns the raw value associated with the given key, if found. Otherwise, nil is
# returned.
# returned.
#
# It is valid to lookup keys that are not in the API spec, for example to access
# undocumented features. This method does not parse response data into
# higher-level types. Lookup by anything other than a Symbol is an ArgumentError.
# It is valid to lookup keys that are not in the API spec, for example to access
# undocumented features. This method does not parse response data into
# higher-level types. Lookup by anything other than a Symbol is an ArgumentError.
#
# @param key [Symbol]
#
Expand All @@ -310,12 +310,12 @@ def [](key)

# Returns a Hash of the data underlying this object. O(1)
#
# Keys are Symbols and values are the raw values from the response. The return
# value indicates which values were ever set on the object. i.e. there will be a
# key in this hash if they ever were, even if the set value was nil.
# Keys are Symbols and values are the raw values from the response. The return
# value indicates which values were ever set on the object. i.e. there will be a
# key in this hash if they ever were, even if the set value was nil.
#
# This method is not recursive. The returned value is shared by the object, so it
# should not be mutated.
# This method is not recursive. The returned value is shared by the object, so it
# should not be mutated.
#
# @return [Hash{Symbol=>Object}]
def to_h = @data
Expand Down
40 changes: 20 additions & 20 deletions lib/openai/internal/type/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,37 @@ def type_info(spec)
#
# Based on `target`, transform `value` into `target`, to the extent possible:
#
# 1. if the given `value` conforms to `target` already, return the given `value`
# 2. if it's possible and safe to convert the given `value` to `target`, then the
# converted value
# 3. otherwise, the given `value` unaltered
# 1. if the given `value` conforms to `target` already, return the given `value`
# 2. if it's possible and safe to convert the given `value` to `target`, then the
# converted value
# 3. otherwise, the given `value` unaltered
#
# The coercion process is subject to improvement between minor release versions.
# See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode
# The coercion process is subject to improvement between minor release versions.
# See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode
#
# @param target [OpenAI::Internal::Type::Converter, Class]
#
# @param value [Object]
#
# @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`, or `:strong`. This informs the
# coercion strategy when we have to decide between multiple possible conversion
# targets:
# coercion strategy when we have to decide between multiple possible conversion
# targets:
#
# - `true`: the conversion must be exact, with minimum coercion.
# - `false`: the conversion can be approximate, with some coercion.
# - `:strong`: the conversion must be exact, with no coercion, and raise an error
# if not possible.
# - `true`: the conversion must be exact, with minimum coercion.
# - `false`: the conversion can be approximate, with some coercion.
# - `:strong`: the conversion must be exact, with no coercion, and raise an error
# if not possible.
#
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
# any given conversion attempt, the exactness will be updated based on how closely
# the value recursively matches the target type:
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
# any given conversion attempt, the exactness will be updated based on how closely
# the value recursively matches the target type:
#
# - `yes`: the value can be converted to the target type with minimum coercion.
# - `maybe`: the value can be converted to the target type with some reasonable
# coercion.
# - `no`: the value cannot be converted to the target type.
# - `yes`: the value can be converted to the target type with minimum coercion.
# - `maybe`: the value can be converted to the target type with some reasonable
# coercion.
# - `no`: the value cannot be converted to the target type.
#
# See implementation below for more details.
# See implementation below for more details.
#
# @option state [Boolean, :strong] :strictness
#
Expand Down
16 changes: 8 additions & 8 deletions lib/openai/internal/type/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ module Type
# @api private
#
# A value from among a specified list of options. OpenAPI enum values map to Ruby
# values in the SDK as follows:
# values in the SDK as follows:
#
# 1. boolean => true | false
# 2. integer => Integer
# 3. float => Float
# 4. string => Symbol
# 1. boolean => true | false
# 2. integer => Integer
# 3. float => Float
# 4. string => Symbol
#
# We can therefore convert string values to Symbols, but can't convert other
# values safely.
# We can therefore convert string values to Symbols, but can't convert other
# values safely.
#
# @example
# # `chat_model` is a `OpenAI::Models::ChatModel`
Expand Down Expand Up @@ -70,7 +70,7 @@ def ==(other)
# @api private
#
# Unlike with primitives, `Enum` additionally validates that the value is a member
# of the enum.
# of the enum.
#
# @param value [String, Symbol, Object]
#
Expand Down
2 changes: 1 addition & 1 deletion lib/openai/internal/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class << self
# @api private
#
# Recursively merge one hash with another. If the values at a given key are not
# both hashes, just take the new value.
# both hashes, just take the new value.
#
# @param values [Array<Object>]
#
Expand Down
24 changes: 12 additions & 12 deletions lib/openai/models/audio/speech_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ class SpeechCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute model
# One of the available [TTS models](https://platform.openai.com/docs/models#tts):
# `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
# `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
#
# @return [String, Symbol, OpenAI::Models::Audio::SpeechModel]
required :model, union: -> { OpenAI::Models::Audio::SpeechCreateParams::Model }

# @!attribute voice
# The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
# `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
# `verse`. Previews of the voices are available in the
# [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
# `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
# `verse`. Previews of the voices are available in the
# [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
#
# @return [String, Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice]
required :voice, union: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice }

# @!attribute [r] instructions
# Control the voice of your generated audio with additional instructions. Does not
# work with `tts-1` or `tts-1-hd`.
# work with `tts-1` or `tts-1-hd`.
#
# @return [String, nil]
optional :instructions, String
Expand All @@ -44,7 +44,7 @@ class SpeechCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute [r] response_format
# The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
# `wav`, and `pcm`.
# `wav`, and `pcm`.
#
# @return [Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat, nil]
optional :response_format, enum: -> { OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat }
Expand All @@ -55,7 +55,7 @@ class SpeechCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute [r] speed
# The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
# the default.
# the default.
#
# @return [Float, nil]
optional :speed, Float
Expand All @@ -78,7 +78,7 @@ class SpeechCreateParams < OpenAI::Internal::Type::BaseModel
# def initialize: (Hash | OpenAI::Internal::Type::BaseModel) -> void

# One of the available [TTS models](https://platform.openai.com/docs/models#tts):
# `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
# `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
module Model
extend OpenAI::Internal::Type::Union

Expand All @@ -93,9 +93,9 @@ module Model
end

# The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
# `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
# `verse`. Previews of the voices are available in the
# [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
# `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
# `verse`. Previews of the voices are available in the
# [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
module Voice
extend OpenAI::Internal::Type::Union

Expand Down Expand Up @@ -145,7 +145,7 @@ module Voice
end

# The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
# `wav`, and `pcm`.
# `wav`, and `pcm`.
module ResponseFormat
extend OpenAI::Internal::Type::Enum

Expand Down
6 changes: 3 additions & 3 deletions lib/openai/models/audio/transcription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Transcription < OpenAI::Internal::Type::BaseModel

# @!attribute [r] logprobs
# The log probabilities of the tokens in the transcription. Only returned with the
# models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
# to the `include` array.
# models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
# to the `include` array.
#
# @return [Array<OpenAI::Models::Audio::Transcription::Logprob>, nil]
optional :logprobs, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Audio::Transcription::Logprob] }
Expand All @@ -24,7 +24,7 @@ class Transcription < OpenAI::Internal::Type::BaseModel

# @!parse
# # Represents a transcription response returned by model, based on the provided
# # input.
# # input.
# #
# # @param text [String]
# # @param logprobs [Array<OpenAI::Models::Audio::Transcription::Logprob>]
Expand Down
48 changes: 24 additions & 24 deletions lib/openai/models/audio/transcription_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute file
# The audio file object (not file name) to transcribe, in one of these formats:
# flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
# flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
#
# @return [IO, StringIO]
required :file, IO

# @!attribute model
# ID of the model to use. The options are `gpt-4o-transcribe`,
# `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
# Whisper V2 model).
# `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
# Whisper V2 model).
#
# @return [String, Symbol, OpenAI::Models::AudioModel]
required :model, union: -> { OpenAI::Models::Audio::TranscriptionCreateParams::Model }

# @!attribute [r] include
# Additional information to include in the transcription response. `logprobs` will
# return the log probabilities of the tokens in the response to understand the
# model's confidence in the transcription. `logprobs` only works with
# response_format set to `json` and only with the models `gpt-4o-transcribe` and
# `gpt-4o-mini-transcribe`.
# return the log probabilities of the tokens in the response to understand the
# model's confidence in the transcription. `logprobs` only works with
# response_format set to `json` and only with the models `gpt-4o-transcribe` and
# `gpt-4o-mini-transcribe`.
#
# @return [Array<Symbol, OpenAI::Models::Audio::TranscriptionInclude>, nil]
optional :include,
Expand All @@ -43,8 +43,8 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute [r] language
# The language of the input audio. Supplying the input language in
# [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
# format will improve accuracy and latency.
# [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
# format will improve accuracy and latency.
#
# @return [String, nil]
optional :language, String
Expand All @@ -55,9 +55,9 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute [r] prompt
# An optional text to guide the model's style or continue a previous audio
# segment. The
# [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
# should match the audio language.
# segment. The
# [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
# should match the audio language.
#
# @return [String, nil]
optional :prompt, String
Expand All @@ -68,8 +68,8 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute [r] response_format
# The format of the output, in one of these options: `json`, `text`, `srt`,
# `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
# the only supported format is `json`.
# `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
# the only supported format is `json`.
#
# @return [Symbol, OpenAI::Models::AudioResponseFormat, nil]
optional :response_format, enum: -> { OpenAI::Models::AudioResponseFormat }
Expand All @@ -80,10 +80,10 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute [r] temperature
# The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
# output more random, while lower values like 0.2 will make it more focused and
# deterministic. If set to 0, the model will use
# [log probability](https://en.wikipedia.org/wiki/Log_probability) to
# automatically increase the temperature until certain thresholds are hit.
# output more random, while lower values like 0.2 will make it more focused and
# deterministic. If set to 0, the model will use
# [log probability](https://en.wikipedia.org/wiki/Log_probability) to
# automatically increase the temperature until certain thresholds are hit.
#
# @return [Float, nil]
optional :temperature, Float
Expand All @@ -94,10 +94,10 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel

# @!attribute [r] timestamp_granularities
# The timestamp granularities to populate for this transcription.
# `response_format` must be set `verbose_json` to use timestamp granularities.
# Either or both of these options are supported: `word`, or `segment`. Note: There
# is no additional latency for segment timestamps, but generating word timestamps
# incurs additional latency.
# `response_format` must be set `verbose_json` to use timestamp granularities.
# Either or both of these options are supported: `word`, or `segment`. Note: There
# is no additional latency for segment timestamps, but generating word timestamps
# incurs additional latency.
#
# @return [Array<Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity>, nil]
optional :timestamp_granularities,
Expand Down Expand Up @@ -136,8 +136,8 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel
# def initialize: (Hash | OpenAI::Internal::Type::BaseModel) -> void

# ID of the model to use. The options are `gpt-4o-transcribe`,
# `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
# Whisper V2 model).
# `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
# Whisper V2 model).
module Model
extend OpenAI::Internal::Type::Union

Expand Down
2 changes: 1 addition & 1 deletion lib/openai/models/audio/transcription_create_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module OpenAI
module Models
module Audio
# Represents a transcription response returned by model, based on the provided
# input.
# input.
#
# @see OpenAI::Resources::Audio::Transcriptions#create
#
Expand Down
Loading