Skip to content

Commit a16dd00

Browse files
chore: refine Yard and Sorbet types and ensure linting is turned on for examples
1 parent 600f499 commit a16dd00

File tree

67 files changed

+340
-489
lines changed

Some content is hidden

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

67 files changed

+340
-489
lines changed

Rakefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require "rake/clean"
99
require "rubocop/rake_task"
1010

1111
tapioca = "sorbet/tapioca"
12+
examples = "examples"
1213
ignore_file = ".ignore"
1314

1415
CLEAN.push(*%w[.idea/ .ruby-lsp/ .yardoc/ doc/], *FileList["*.gem"], ignore_file)
@@ -39,7 +40,7 @@ locale = {"LC_ALL" => "C.UTF-8"}
3940

4041
desc("Lint `*.rb(i)`")
4142
multitask(:"lint:rubocop") do
42-
find = %w[find ./lib ./test ./rbi -type f -and ( -name *.rb -or -name *.rbi ) -print0]
43+
find = %w[find ./lib ./test ./rbi ./examples -type f -and ( -name *.rb -or -name *.rbi ) -print0]
4344

4445
rubocop = %w[rubocop]
4546
rubocop += %w[--format github] if ENV.key?("CI")
@@ -54,7 +55,7 @@ end
5455
desc("Format `*.rb`")
5556
multitask(:"format:rb") do
5657
# while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support
57-
find = %w[find ./lib ./test -type f -and -name *.rb -print0]
58+
find = %w[find ./lib ./test ./examples -type f -and -name *.rb -print0]
5859
fmt = xargs + %w[rubocop --fail-level F --autocorrect --format simple --]
5960
sh("#{find.shelljoin} | #{fmt.shelljoin}")
6061
end
@@ -117,12 +118,14 @@ multitask(:"typecheck:steep") do
117118
sh(*%w[steep check])
118119
end
119120

121+
directory(examples)
122+
120123
desc("Typecheck `*.rbi`")
121-
multitask(:"typecheck:sorbet") do
122-
sh(*%w[srb typecheck])
124+
multitask("typecheck:sorbet": examples) do
125+
sh(*%w[srb typecheck --dir], examples)
123126
end
124127

125-
file(tapioca) do
128+
directory(tapioca) do
126129
sh(*%w[tapioca init])
127130
end
128131

lib/openai/internal.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ module Internal
1313
define_sorbet_constant!(:AnyHash) do
1414
T.type_alias { T::Hash[Symbol, T.anything] }
1515
end
16+
define_sorbet_constant!(:FileInput) do
17+
T.type_alias { T.any(Pathname, StringIO, IO, String, OpenAI::FilePart) }
18+
end
1619
end
1720
end

lib/openai/models/audio/transcription_create_params.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel
1414
# The audio file object (not file name) to transcribe, in one of these formats:
1515
# flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
1616
#
17-
# @return [Pathname, StringIO, IO, OpenAI::FilePart]
17+
# @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
1818
required :file, OpenAI::Internal::Type::FileInput
1919

2020
# @!attribute model
@@ -98,7 +98,7 @@ class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel
9898
# Some parameter documentations has been truncated, see
9999
# {OpenAI::Models::Audio::TranscriptionCreateParams} for more details.
100100
#
101-
# @param file [Pathname, StringIO, IO, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
101+
# @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
102102
#
103103
# @param model [String, Symbol, OpenAI::AudioModel] ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transc
104104
#

lib/openai/models/audio/translation_create_params.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TranslationCreateParams < OpenAI::Internal::Type::BaseModel
1212
# The audio file object (not file name) translate, in one of these formats: flac,
1313
# mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
1414
#
15-
# @return [Pathname, StringIO, IO, OpenAI::FilePart]
15+
# @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
1616
required :file, OpenAI::Internal::Type::FileInput
1717

1818
# @!attribute model
@@ -52,7 +52,7 @@ class TranslationCreateParams < OpenAI::Internal::Type::BaseModel
5252
# Some parameter documentations has been truncated, see
5353
# {OpenAI::Models::Audio::TranslationCreateParams} for more details.
5454
#
55-
# @param file [Pathname, StringIO, IO, OpenAI::FilePart] The audio file object (not file name) translate, in one of these formats: flac,
55+
# @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) translate, in one of these formats: flac,
5656
#
5757
# @param model [String, Symbol, OpenAI::AudioModel] ID of the model to use. Only `whisper-1` (which is powered by our open source Wh
5858
#

lib/openai/models/file_create_params.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class FileCreateParams < OpenAI::Internal::Type::BaseModel
1010
# @!attribute file
1111
# The File object (not file name) to be uploaded.
1212
#
13-
# @return [Pathname, StringIO, IO, OpenAI::FilePart]
13+
# @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
1414
required :file, OpenAI::Internal::Type::FileInput
1515

1616
# @!attribute purpose
@@ -26,7 +26,7 @@ class FileCreateParams < OpenAI::Internal::Type::BaseModel
2626
# Some parameter documentations has been truncated, see
2727
# {OpenAI::Models::FileCreateParams} for more details.
2828
#
29-
# @param file [Pathname, StringIO, IO, OpenAI::FilePart] The File object (not file name) to be uploaded.
29+
# @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The File object (not file name) to be uploaded.
3030
#
3131
# @param purpose [Symbol, OpenAI::FilePurpose] The intended purpose of the uploaded file. One of: - `assistants`: Used in the A
3232
#

lib/openai/models/image_create_variation_params.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ImageCreateVariationParams < OpenAI::Internal::Type::BaseModel
1111
# The image to use as the basis for the variation(s). Must be a valid PNG file,
1212
# less than 4MB, and square.
1313
#
14-
# @return [Pathname, StringIO, IO, OpenAI::FilePart]
14+
# @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
1515
required :image, OpenAI::Internal::Type::FileInput
1616

1717
# @!attribute model
@@ -54,7 +54,7 @@ class ImageCreateVariationParams < OpenAI::Internal::Type::BaseModel
5454
# Some parameter documentations has been truncated, see
5555
# {OpenAI::Models::ImageCreateVariationParams} for more details.
5656
#
57-
# @param image [Pathname, StringIO, IO, OpenAI::FilePart] The image to use as the basis for the variation(s). Must be a valid PNG file, le
57+
# @param image [Pathname, StringIO, IO, String, OpenAI::FilePart] The image to use as the basis for the variation(s). Must be a valid PNG file, le
5858
#
5959
# @param model [String, Symbol, OpenAI::ImageModel, nil] The model to use for image generation. Only `dall-e-2` is supported at this time
6060
#

lib/openai/models/image_edit_params.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ImageEditParams < OpenAI::Internal::Type::BaseModel
1616
# For `dall-e-2`, you can only provide one image, and it should be a square `png`
1717
# file less than 4MB.
1818
#
19-
# @return [Pathname, StringIO, IO, OpenAI::FilePart, Array<Pathname, StringIO, IO, OpenAI::FilePart>]
19+
# @return [Pathname, StringIO, IO, String, OpenAI::FilePart, Array<Pathname, StringIO, IO, String, OpenAI::FilePart>]
2020
required :image, union: -> { OpenAI::ImageEditParams::Image }
2121

2222
# @!attribute prompt
@@ -44,7 +44,7 @@ class ImageEditParams < OpenAI::Internal::Type::BaseModel
4444
# the mask will be applied on the first image. Must be a valid PNG file, less than
4545
# 4MB, and have the same dimensions as `image`.
4646
#
47-
# @return [Pathname, StringIO, IO, OpenAI::FilePart, nil]
47+
# @return [Pathname, StringIO, IO, String, OpenAI::FilePart, nil]
4848
optional :mask, OpenAI::Internal::Type::FileInput
4949

5050
# @!attribute model
@@ -98,13 +98,13 @@ class ImageEditParams < OpenAI::Internal::Type::BaseModel
9898
# Some parameter documentations has been truncated, see
9999
# {OpenAI::Models::ImageEditParams} for more details.
100100
#
101-
# @param image [Pathname, StringIO, IO, OpenAI::FilePart, Array<Pathname, StringIO, IO, OpenAI::FilePart>] The image(s) to edit. Must be a supported image file or an array of images.
101+
# @param image [Pathname, StringIO, IO, String, OpenAI::FilePart, Array<Pathname, StringIO, IO, String, OpenAI::FilePart>] The image(s) to edit. Must be a supported image file or an array of images.
102102
#
103103
# @param prompt [String] A text description of the desired image(s). The maximum length is 1000 character
104104
#
105105
# @param background [Symbol, OpenAI::ImageEditParams::Background, nil] Allows to set transparency for the background of the generated image(s).
106106
#
107-
# @param mask [Pathname, StringIO, IO, OpenAI::FilePart] An additional image whose fully transparent areas (e.g. where alpha is zero) ind
107+
# @param mask [Pathname, StringIO, IO, String, OpenAI::FilePart] An additional image whose fully transparent areas (e.g. where alpha is zero) ind
108108
#
109109
# @param model [String, Symbol, OpenAI::ImageModel, nil] The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are sup
110110
#

lib/openai/models/uploads/part_create_params.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class PartCreateParams < OpenAI::Internal::Type::BaseModel
1111
# @!attribute data
1212
# The chunk of bytes for this Part.
1313
#
14-
# @return [Pathname, StringIO, IO, OpenAI::FilePart]
14+
# @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
1515
required :data, OpenAI::Internal::Type::FileInput
1616

1717
# @!method initialize(data:, request_options: {})
1818
# Some parameter documentations has been truncated, see
1919
# {OpenAI::Models::Uploads::PartCreateParams} for more details.
2020
#
21-
# @param data [Pathname, StringIO, IO, OpenAI::FilePart] The chunk of bytes for this Part.
21+
# @param data [Pathname, StringIO, IO, String, OpenAI::FilePart] The chunk of bytes for this Part.
2222
#
2323
# @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
2424
end

lib/openai/resources/audio/transcriptions.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Transcriptions
1414
#
1515
# @overload create(file:, model:, chunking_strategy: nil, include: nil, language: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {})
1616
#
17-
# @param file [Pathname, StringIO, IO, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
17+
# @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
1818
#
1919
# @param model [String, Symbol, OpenAI::AudioModel] ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transc
2020
#
@@ -63,7 +63,7 @@ def create(params)
6363
#
6464
# @overload create_streaming(file:, model:, chunking_strategy: nil, include: nil, language: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {})
6565
#
66-
# @param file [Pathname, StringIO, IO, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
66+
# @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
6767
#
6868
# @param model [String, Symbol, OpenAI::AudioModel] ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transc
6969
#

lib/openai/resources/audio/translations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Translations
1111
#
1212
# @overload create(file:, model:, prompt: nil, response_format: nil, temperature: nil, request_options: {})
1313
#
14-
# @param file [Pathname, StringIO, IO, OpenAI::FilePart] The audio file object (not file name) translate, in one of these formats: flac,
14+
# @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) translate, in one of these formats: flac,
1515
#
1616
# @param model [String, Symbol, OpenAI::AudioModel] ID of the model to use. Only `whisper-1` (which is powered by our open source Wh
1717
#

0 commit comments

Comments
 (0)