Skip to content

Commit e1c4792

Browse files
chore: document union variants in yard doc (#16)
1 parent db3b667 commit e1c4792

File tree

240 files changed

+1140
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+1140
-610
lines changed

lib/openai/base_model.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,18 @@ class << self
443443

444444
# @api private
445445
#
446-
# All of the specified variants for this union.
447-
#
448446
# @return [Array<Array(Symbol, Object)>]
449-
protected def variants
447+
protected def derefed_variants
450448
@known_variants.map { |key, variant_fn| [key, variant_fn.call] }
451449
end
452450

451+
# All of the specified variants for this union.
452+
#
453+
# @return [Array<Object>]
454+
def variants
455+
derefed_variants.map(&:last)
456+
end
457+
453458
# @api private
454459
#
455460
# @param property [Symbol]
@@ -529,7 +534,7 @@ def self.===(other)
529534
#
530535
# @return [Boolean]
531536
def self.==(other)
532-
other.is_a?(Class) && other <= OpenAI::Union && other.variants == variants
537+
other.is_a?(Class) && other <= OpenAI::Union && other.derefed_variants == derefed_variants
533538
end
534539

535540
class << self

lib/openai/models/audio/speech_create_params.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class Model < OpenAI::Union
7373

7474
# One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1` or `tts-1-hd`
7575
variant enum: -> { OpenAI::Models::Audio::SpeechModel }
76+
77+
# @!parse
78+
# class << self
79+
# # @return [Array(String, Symbol, OpenAI::Models::Audio::SpeechModel)]
80+
# def variants; end
81+
# end
7682
end
7783

7884
# @abstract

lib/openai/models/audio/transcription_create_params.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ class Model < OpenAI::Union
122122

123123
# ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
124124
variant enum: -> { OpenAI::Models::AudioModel }
125+
126+
# @!parse
127+
# class << self
128+
# # @return [Array(String, Symbol, OpenAI::Models::AudioModel)]
129+
# def variants; end
130+
# end
125131
end
126132

127133
# @abstract

lib/openai/models/audio/transcription_create_response.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ class TranscriptionCreateResponse < OpenAI::Union
1313

1414
# Represents a verbose json transcription response returned by model, based on the provided input.
1515
variant -> { OpenAI::Models::Audio::TranscriptionVerbose }
16+
17+
# @!parse
18+
# class << self
19+
# # @return [Array(OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose)]
20+
# def variants; end
21+
# end
1622
end
1723
end
1824
end

lib/openai/models/audio/translation_create_params.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class Model < OpenAI::Union
8181

8282
# ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
8383
variant enum: -> { OpenAI::Models::AudioModel }
84+
85+
# @!parse
86+
# class << self
87+
# # @return [Array(String, Symbol, OpenAI::Models::AudioModel)]
88+
# def variants; end
89+
# end
8490
end
8591
end
8692
end

lib/openai/models/audio/translation_create_response.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ class TranslationCreateResponse < OpenAI::Union
88
variant -> { OpenAI::Models::Audio::Translation }
99

1010
variant -> { OpenAI::Models::Audio::TranslationVerbose }
11+
12+
# @!parse
13+
# class << self
14+
# # @return [Array(OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose)]
15+
# def variants; end
16+
# end
1117
end
1218
end
1319
end

lib/openai/models/beta/assistant_create_params.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ class Model < OpenAI::Union
169169

170170
# ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.
171171
variant enum: -> { OpenAI::Models::ChatModel }
172+
173+
# @!parse
174+
# class << self
175+
# # @return [Array(String, Symbol, OpenAI::Models::ChatModel)]
176+
# def variants; end
177+
# end
172178
end
173179

174180
class ToolResources < OpenAI::BaseModel
@@ -384,6 +390,12 @@ class Static < OpenAI::BaseModel
384390
# def initialize: (Hash | OpenAI::BaseModel) -> void
385391
end
386392
end
393+
394+
# @!parse
395+
# class << self
396+
# # @return [Array(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)]
397+
# def variants; end
398+
# end
387399
end
388400
end
389401
end

lib/openai/models/beta/assistant_response_format_option.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ class AssistantResponseFormatOption < OpenAI::Union
4141
# JSON Schema response format. Used to generate structured JSON responses.
4242
# Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
4343
variant -> { OpenAI::Models::ResponseFormatJSONSchema }
44+
45+
# @!parse
46+
# class << self
47+
# # @return [Array(Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema)]
48+
# def variants; end
49+
# end
4450
end
4551
end
4652
end

lib/openai/models/beta/assistant_stream_event.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,12 @@ class ErrorEvent < OpenAI::BaseModel
725725

726726
# def initialize: (Hash | OpenAI::BaseModel) -> void
727727
end
728+
729+
# @!parse
730+
# class << self
731+
# # @return [Array(OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent)]
732+
# def variants; end
733+
# end
728734
end
729735
end
730736
end

lib/openai/models/beta/assistant_tool.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ class AssistantTool < OpenAI::Union
1212
variant :file_search, -> { OpenAI::Models::Beta::FileSearchTool }
1313

1414
variant :function, -> { OpenAI::Models::Beta::FunctionTool }
15+
16+
# @!parse
17+
# class << self
18+
# # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool)]
19+
# def variants; end
20+
# end
1521
end
1622
end
1723
end

0 commit comments

Comments
 (0)