Skip to content

Commit 67c9304

Browse files
authored
Merge branch 'next' into ruby-3.2
2 parents 85e9796 + 4244f89 commit 67c9304

File tree

854 files changed

+29507
-8930
lines changed

Some content is hidden

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

854 files changed

+29507
-8930
lines changed

.github/workflows/ci.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
name: CI
22
on:
33
push:
4-
branches:
5-
- main
6-
pull_request:
7-
branches:
8-
- main
9-
- next
4+
branches-ignore:
5+
- 'generated'
6+
- 'codegen/**'
7+
- 'integrated/**'
8+
- 'stl-preview-head/**'
9+
- 'stl-preview-base/**'
1010

1111
jobs:
1212
lint:
13+
timeout-minutes: 10
1314
name: lint
14-
runs-on: ubuntu-latest
15+
runs-on: ${{ github.repository == 'stainless-sdks/openai-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
16+
1517
steps:
1618
- uses: actions/checkout@v4
1719
- name: Set up Ruby
@@ -25,8 +27,9 @@ jobs:
2527
- name: Run lints
2628
run: ./scripts/lint
2729
test:
30+
timeout-minutes: 10
2831
name: test
29-
runs-on: ubuntu-latest
32+
runs-on: ${{ github.repository == 'stainless-sdks/openai-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
3033
steps:
3134
- uses: actions/checkout@v4
3235
- name: Set up Ruby

.github/workflows/create-releases.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ jobs:
2525
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
2626

2727
- name: Set up Ruby
28-
if: ${{ steps.release.outputs.releases_created }}
28+
if: ${{ steps.release.outputs.releases_created }}
2929
uses: ruby/setup-ruby@v1
3030
with:
3131
bundler-cache: false
3232
ruby-version: '3.2'
33-
- run: |-
33+
34+
- run: |
3435
bundle install
3536
3637
- name: Publish to RubyGems.org
37-
if: ${{ steps.release.outputs.releases_created }}
38+
if: ${{ steps.release.outputs.releases_created }}
3839
run: |
3940
bash ./bin/publish-gem
4041
env:

.rubocop.yml

+11
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,19 @@ Layout/MultilineMethodParameterLineBreaks:
6464
Layout/SpaceInsideHashLiteralBraces:
6565
EnforcedStyle: no_space
6666

67+
Lint/BooleanSymbol:
68+
Enabled: false
69+
6770
# This option occasionally mangles identifier names
6871
Lint/DeprecatedConstants:
6972
Exclude:
7073
- "**/*.rbi"
7174

75+
# We use pattern assertion in tests to ensure correctness.
76+
Lint/DuplicateMatchPattern:
77+
Exclude:
78+
- "test/**/*"
79+
7280
# Fairly useful in tests for pattern assertions.
7381
Lint/EmptyInPattern:
7482
Exclude:
@@ -119,6 +127,9 @@ Metrics/ParameterLists:
119127
Metrics/PerceivedComplexity:
120128
Enabled: false
121129

130+
Naming/AccessorMethodName:
131+
Enabled: false
132+
122133
# Need to preserve block identifier for documentation.
123134
Naming/BlockForwarding:
124135
Enabled: false

.stats.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 95
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-5633633cc38734869cf7d993f7b549bb8e4d10e0ec45381ec2cd91507cd8eb8f.yml
3-
openapi_spec_hash: c855121b2b2324b99499c9244c21d24d
4-
config_hash: d20837393b73efdb19cd08e04c1cc9a1
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-8b68ae6b807dca92e914da1dd9e835a20f69b075e79102a264367fd7fddddb33.yml
3+
openapi_spec_hash: b6ade5b1a6327339e6669e1134de2d03
4+
config_hash: b597cd9a31e9e5ec709e2eefb4c54122

.yardopts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
--type-name-tag generic:Generic
2+
--default-return void
23
--markup markdown
34
--markup-provider redcarpet
45
--exclude /rbi

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This will install all the required dependencies.
1414

1515
## Modifying/Adding code
1616

17-
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents `examples/` directory.
17+
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of `lib/openai/helpers/` and `examples/` directory.
1818

1919
## Adding and running examples
2020

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ group :development, :test do
2323
gem "minitest-hooks"
2424
gem "minitest-proveit"
2525
gem "minitest-rg"
26+
gem "webmock"
2627
end
2728

2829
group :development, :docs do

Gemfile.lock

+13
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ GEM
2929
minitest (>= 5.1)
3030
securerandom (>= 0.3)
3131
tzinfo (~> 2.0, >= 2.0.5)
32+
addressable (2.8.7)
33+
public_suffix (>= 2.0.2, < 7.0)
3234
ast (2.4.3)
3335
async (2.23.1)
3436
console (~> 1.29)
@@ -45,6 +47,9 @@ GEM
4547
fiber-annotation
4648
fiber-local (~> 1.1)
4749
json
50+
crack (1.0.0)
51+
bigdecimal
52+
rexml
4853
csv (3.3.3)
4954
drb (2.2.1)
5055
erubi (1.13.1)
@@ -54,6 +59,7 @@ GEM
5459
fiber-storage
5560
fiber-storage (1.0.0)
5661
fileutils (1.7.3)
62+
hashdiff (1.1.2)
5763
i18n (1.14.7)
5864
concurrent-ruby (~> 1.0)
5965
io-event (1.10.0)
@@ -82,6 +88,7 @@ GEM
8288
racc
8389
prettier_print (1.2.1)
8490
prism (1.4.0)
91+
public_suffix (6.0.1)
8592
racc (1.8.1)
8693
rainbow (3.1.1)
8794
rake (13.2.1)
@@ -96,6 +103,7 @@ GEM
96103
logger
97104
redcarpet (3.6.1)
98105
regexp_parser (2.10.0)
106+
rexml (3.4.1)
99107
rubocop (1.75.1)
100108
json (~> 2.3)
101109
language_server-protocol (~> 3.17.0.2)
@@ -165,6 +173,10 @@ GEM
165173
unicode-emoji (~> 4.0, >= 4.0.4)
166174
unicode-emoji (4.0.4)
167175
uri (1.0.3)
176+
webmock (3.25.1)
177+
addressable (>= 2.8.0)
178+
crack (>= 0.3.2)
179+
hashdiff (>= 0.4.0, < 2.0.0)
168180
webrick (1.9.1)
169181
yard (0.9.37)
170182
yard-sorbet (0.9.0)
@@ -191,6 +203,7 @@ DEPENDENCIES
191203
syntax_tree
192204
syntax_tree-rbs!
193205
tapioca
206+
webmock
194207
webrick
195208
yard
196209

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ openai = OpenAI::Client.new(
3333
)
3434

3535
chat_completion = openai.chat.completions.create(
36-
messages: [{role: :user, content: "Say this is a test"}],
36+
messages: [{role: "user", content: "Say this is a test"}],
3737
model: :"gpt-4.1"
3838
)
3939

@@ -48,7 +48,7 @@ When using sorbet, it is recommended to use model classes as below. This provide
4848

4949
```ruby
5050
openai.chat.completions.create(
51-
messages: [OpenAI::Models::Chat::ChatCompletionUserMessageParam.new(role: :user, content: "Say this is a test")],
51+
messages: [OpenAI::Models::Chat::ChatCompletionUserMessageParam.new(role: "user", content: "Say this is a test")],
5252
model: :"gpt-4.1"
5353
)
5454
```
@@ -80,7 +80,7 @@ We provide support for streaming responses using Server-Sent Events (SSE).
8080

8181
```ruby
8282
stream = openai.chat.completions.stream_raw(
83-
messages: [{role: :user, content: "Say this is a test"}],
83+
messages: [{role: "user", content: "Say this is a test"}],
8484
model: :"gpt-4.1"
8585
)
8686

@@ -97,11 +97,11 @@ Request parameters that correspond to file uploads can be passed as `StringIO`,
9797
require "pathname"
9898

9999
# using `Pathname`, the file will be lazily read, without reading everything in to memory
100-
file_object = openai.files.create(file: Pathname("input.jsonl"), purpose: :"fine-tune")
100+
file_object = openai.files.create(file: Pathname("input.jsonl"), purpose: "fine-tune")
101101

102102
file = File.read("input.jsonl")
103103
# using `StringIO`, useful if you already have the data in memory
104-
file_object = openai.files.create(file: StringIO.new(file), purpose: :"fine-tune")
104+
file_object = openai.files.create(file: StringIO.new(file), purpose: "fine-tune")
105105

106106
puts(file_object.id)
107107
```
@@ -150,7 +150,7 @@ openai = OpenAI::Client.new(
150150

151151
# Or, configure per-request:
152152
openai.chat.completions.create(
153-
messages: [{role: :user, content: "How can I get the name of the current day in JavaScript?"}],
153+
messages: [{role: "user", content: "How can I get the name of the current day in JavaScript?"}],
154154
model: :"gpt-4.1",
155155
request_options: {max_retries: 5}
156156
)
@@ -172,7 +172,7 @@ openai = OpenAI::Client.new(
172172

173173
# Or, configure per-request:
174174
openai.chat.completions.create(
175-
messages: [{role: :user, content: "How can I list all files in a directory using Python?"}],
175+
messages: [{role: "user", content: "How can I list all files in a directory using Python?"}],
176176
model: :"gpt-4.1",
177177
request_options: {timeout: 5}
178178
)
@@ -189,13 +189,13 @@ In all places where a `BaseModel` type is specified, vanilla Ruby `Hash` can als
189189
```ruby
190190
# This has tooling readability, for auto-completion, static analysis, and goto definition with supported language services
191191
params = OpenAI::Models::Chat::CompletionCreateParams.new(
192-
messages: [OpenAI::Models::Chat::ChatCompletionUserMessageParam.new(role: :user, content: "Say this is a test")],
192+
messages: [OpenAI::Models::Chat::ChatCompletionUserMessageParam.new(role: "user", content: "Say this is a test")],
193193
model: :"gpt-4.1"
194194
)
195195

196196
# This also works
197197
params = {
198-
messages: [{role: :user, content: "Say this is a test"}],
198+
messages: [{role: "user", content: "Say this is a test"}],
199199
model: :"gpt-4.1"
200200
}
201201
```
@@ -257,7 +257,7 @@ It is possible to pass a compatible model / parameter class to a method that exp
257257

258258
```ruby
259259
params = OpenAI::Models::Chat::CompletionCreateParams.new(
260-
messages: [OpenAI::Models::Chat::ChatCompletionUserMessageParam.new(role: :user, content: "Say this is a test")],
260+
messages: [OpenAI::Models::Chat::ChatCompletionUserMessageParam.new(role: "user", content: "Say this is a test")],
261261
model: :"gpt-4.1"
262262
)
263263
openai.chat.completions.create(**params)

Rakefile

+9-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@ multitask(:test) do
3131
.map { "require_relative(#{_1.dump});" }
3232
.join
3333

34-
ruby(*%w[-w -e], rb, verbose: false) { fail unless _1 }
34+
ruby(*%w[-e], rb, verbose: false) { fail unless _1 }
3535
end
3636

3737
rubo_find = %w[find ./lib ./test ./rbi -type f -and ( -name *.rb -or -name *.rbi ) -print0]
3838
xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --]
3939

4040
desc("Lint `*.rb(i)`")
4141
multitask(:"lint:rubocop") do
42-
lint = xargs + %w[rubocop --fail-level E] + (ENV.key?("CI") ? %w[--format github] : [])
42+
rubocop = %w[rubocop --fail-level E]
43+
rubocop += %w[--format github] if ENV.key?("CI")
44+
45+
# some lines cannot be shortened
46+
rubocop += %w[--except Lint/RedundantCopDisableDirective,Layout/LineLength]
47+
48+
lint = xargs + rubocop
4349
sh("#{rubo_find.shelljoin} | #{lint.shelljoin}")
4450
end
4551

@@ -135,5 +141,5 @@ end
135141

136142
desc("Release ruby gem")
137143
multitask(release: [:"build:gem"]) do
138-
sh(*%w[gem push], *FileList["openai-*.gem"])
144+
sh(*%w[gem push], *FileList["*.gem"])
139145
end

Steepfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "yaml"
44

5-
target :lib do
5+
target(:lib) do
66
configure_code_diagnostics(Steep::Diagnostic::Ruby.strict)
77

88
signature("sig")

lib/openai.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
require_relative "openai/internal/type/converter"
3232
require_relative "openai/internal/type/unknown"
3333
require_relative "openai/internal/type/boolean"
34-
require_relative "openai/internal/type/io_like"
34+
require_relative "openai/internal/type/file_input"
3535
require_relative "openai/internal/type/enum"
3636
require_relative "openai/internal/type/union"
3737
require_relative "openai/internal/type/array_of"
@@ -42,6 +42,7 @@
4242
require_relative "openai/internal/type/request_parameters"
4343
require_relative "openai/internal"
4444
require_relative "openai/request_options"
45+
require_relative "openai/file_part"
4546
require_relative "openai/errors"
4647
require_relative "openai/internal/transport/base_client"
4748
require_relative "openai/internal/transport/pooled_net_requester"
@@ -363,6 +364,10 @@
363364
require_relative "openai/models/responses/response_output_refusal"
364365
require_relative "openai/models/responses/response_output_text"
365366
require_relative "openai/models/responses/response_reasoning_item"
367+
require_relative "openai/models/responses/response_reasoning_summary_part_added_event"
368+
require_relative "openai/models/responses/response_reasoning_summary_part_done_event"
369+
require_relative "openai/models/responses/response_reasoning_summary_text_delta_event"
370+
require_relative "openai/models/responses/response_reasoning_summary_text_done_event"
366371
require_relative "openai/models/responses/response_refusal_delta_event"
367372
require_relative "openai/models/responses/response_refusal_done_event"
368373
require_relative "openai/models/responses/response_retrieve_params"

lib/openai/client.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ def initialize(
101101
organization: ENV["OPENAI_ORG_ID"],
102102
project: ENV["OPENAI_PROJECT_ID"],
103103
base_url: ENV["OPENAI_BASE_URL"],
104-
max_retries: DEFAULT_MAX_RETRIES,
105-
timeout: DEFAULT_TIMEOUT_IN_SECONDS,
106-
initial_retry_delay: DEFAULT_INITIAL_RETRY_DELAY,
107-
max_retry_delay: DEFAULT_MAX_RETRY_DELAY
104+
max_retries: OpenAI::Client::DEFAULT_MAX_RETRIES,
105+
timeout: OpenAI::Client::DEFAULT_TIMEOUT_IN_SECONDS,
106+
initial_retry_delay: OpenAI::Client::DEFAULT_INITIAL_RETRY_DELAY,
107+
max_retry_delay: OpenAI::Client::DEFAULT_MAX_RETRY_DELAY
108108
)
109109
base_url ||= "https://api.openai.com/v1"
110110

0 commit comments

Comments
 (0)