Skip to content

Commit 4f25be4

Browse files
chore(internal): codegen related update
1 parent 7a892a0 commit 4f25be4

86 files changed

Lines changed: 421 additions & 38 deletions

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,40 @@ on:
1313
- 'stl-preview-base/**'
1414

1515
jobs:
16+
build:
17+
timeout-minutes: 10
18+
name: build
19+
permissions:
20+
contents: read
21+
id-token: write
22+
runs-on: ${{ github.repository == 'stainless-sdks/openai-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
23+
if: |-
24+
github.repository == 'stainless-sdks/openai-ruby' &&
25+
(github.event_name == 'push' || github.event.pull_request.head.repo.fork)
26+
steps:
27+
- uses: actions/checkout@v6
28+
- name: Set up Ruby
29+
uses: ruby/setup-ruby@v1
30+
with:
31+
bundler-cache: false
32+
- run: |-
33+
bundle install
34+
35+
- name: Get GitHub OIDC Token
36+
if: github.repository == 'stainless-sdks/openai-ruby'
37+
id: github-oidc
38+
uses: actions/github-script@v8
39+
with:
40+
script: core.setOutput('github_token', await core.getIDToken());
41+
42+
- name: Build and upload gem artifacts
43+
if: github.repository == 'stainless-sdks/openai-ruby'
44+
env:
45+
URL: https://pkg.stainless.com/s
46+
AUTH: ${{ steps.github-oidc.outputs.github_token }}
47+
SHA: ${{ github.sha }}
48+
PACKAGE_NAME: openai
49+
run: ./scripts/utils/upload-artifact.sh
1650
lint:
1751
timeout-minutes: 10
1852
name: lint

lib/openai/client.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,37 @@ class Client < OpenAI::Internal::Transport::BaseClient
2727
# @return [String, nil]
2828
attr_reader :webhook_secret
2929

30+
# Given a prompt, the model will return one or more predicted completions, and can
31+
# also return the probabilities of alternative tokens at each position.
3032
# @return [OpenAI::Resources::Completions]
3133
attr_reader :completions
3234

3335
# @return [OpenAI::Resources::Chat]
3436
attr_reader :chat
3537

38+
# Get a vector representation of a given input that can be easily consumed by
39+
# machine learning models and algorithms.
3640
# @return [OpenAI::Resources::Embeddings]
3741
attr_reader :embeddings
3842

43+
# Files are used to upload documents that can be used with features like
44+
# Assistants and Fine-tuning.
3945
# @return [OpenAI::Resources::Files]
4046
attr_reader :files
4147

48+
# Given a prompt and/or an input image, the model will generate a new image.
4249
# @return [OpenAI::Resources::Images]
4350
attr_reader :images
4451

4552
# @return [OpenAI::Resources::Audio]
4653
attr_reader :audio
4754

55+
# Given text and/or image inputs, classifies if those inputs are potentially
56+
# harmful.
4857
# @return [OpenAI::Resources::Moderations]
4958
attr_reader :moderations
5059

60+
# List and describe the various models available in the API.
5161
# @return [OpenAI::Resources::Models]
5262
attr_reader :models
5363

@@ -66,9 +76,11 @@ class Client < OpenAI::Internal::Transport::BaseClient
6676
# @return [OpenAI::Resources::Beta]
6777
attr_reader :beta
6878

79+
# Create large batches of API requests to run asynchronously.
6980
# @return [OpenAI::Resources::Batches]
7081
attr_reader :batches
7182

83+
# Use Uploads to upload large files in multiple parts.
7284
# @return [OpenAI::Resources::Uploads]
7385
attr_reader :uploads
7486

@@ -78,9 +90,11 @@ class Client < OpenAI::Internal::Transport::BaseClient
7890
# @return [OpenAI::Resources::Realtime]
7991
attr_reader :realtime
8092

93+
# Manage conversations and conversation items.
8194
# @return [OpenAI::Resources::Conversations]
8295
attr_reader :conversations
8396

97+
# Manage and run evals in the OpenAI platform.
8498
# @return [OpenAI::Resources::Evals]
8599
attr_reader :evals
86100

lib/openai/internal/util.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,37 @@ def writable_enum(&blk)
490490
JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
491491

492492
class << self
493+
# @api private
494+
#
495+
# @param query [Hash{Symbol=>Object}]
496+
#
497+
# @return [Hash{Symbol=>Object}]
498+
def encode_query_params(query)
499+
out = {}
500+
query.each { write_query_param_element!(out, _1, _2) }
501+
out
502+
end
503+
504+
# @api private
505+
#
506+
# @param collection [Hash{Symbol=>Object}]
507+
# @param key [String]
508+
# @param element [Object]
509+
#
510+
# @return [nil]
511+
private def write_query_param_element!(collection, key, element)
512+
case element
513+
in Hash
514+
element.each do |name, value|
515+
write_query_param_element!(collection, "#{key}[#{name}]", value)
516+
end
517+
in Array
518+
collection["#{key}[]"] = element.map(&:to_s)
519+
else
520+
collection[key] = element.to_s
521+
end
522+
end
523+
493524
# @api private
494525
#
495526
# @param y [Enumerator::Yielder]

lib/openai/resources/audio.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
module OpenAI
44
module Resources
55
class Audio
6+
# Turn audio into text or text into audio.
67
# @return [OpenAI::Resources::Audio::Transcriptions]
78
attr_reader :transcriptions
89

10+
# Turn audio into text or text into audio.
911
# @return [OpenAI::Resources::Audio::Translations]
1012
attr_reader :translations
1113

14+
# Turn audio into text or text into audio.
1215
# @return [OpenAI::Resources::Audio::Speech]
1316
attr_reader :speech
1417

lib/openai/resources/audio/speech.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module OpenAI
44
module Resources
55
class Audio
6+
# Turn audio into text or text into audio.
67
class Speech
78
# Some parameter documentations has been truncated, see
89
# {OpenAI::Models::Audio::SpeechCreateParams} for more details.

lib/openai/resources/audio/transcriptions.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module OpenAI
44
module Resources
55
class Audio
6+
# Turn audio into text or text into audio.
67
class Transcriptions
78
# See {OpenAI::Resources::Audio::Transcriptions#create_streaming} for streaming
89
# counterpart.

lib/openai/resources/audio/translations.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module OpenAI
44
module Resources
55
class Audio
6+
# Turn audio into text or text into audio.
67
class Translations
78
# Some parameter documentations has been truncated, see
89
# {OpenAI::Models::Audio::TranslationCreateParams} for more details.

lib/openai/resources/batches.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module OpenAI
44
module Resources
5+
# Create large batches of API requests to run asynchronously.
56
class Batches
67
# Some parameter documentations has been truncated, see
78
# {OpenAI::Models::BatchCreateParams} for more details.
@@ -68,10 +69,11 @@ def retrieve(batch_id, params = {})
6869
# @see OpenAI::Models::BatchListParams
6970
def list(params = {})
7071
parsed, options = OpenAI::BatchListParams.dump_request(params)
72+
query = OpenAI::Internal::Util.encode_query_params(parsed)
7173
@client.request(
7274
method: :get,
7375
path: "batches",
74-
query: parsed,
76+
query: query,
7577
page: OpenAI::Internal::CursorPage,
7678
model: OpenAI::Batch,
7779
options: options

lib/openai/resources/beta.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ class Beta
66
# @return [OpenAI::Resources::Beta::ChatKit]
77
attr_reader :chatkit
88

9+
# Build Assistants that can call models and use tools.
910
# @return [OpenAI::Resources::Beta::Assistants]
1011
attr_reader :assistants
1112

13+
# Build Assistants that can call models and use tools.
1214
# @return [OpenAI::Resources::Beta::Threads]
1315
attr_reader :threads
1416

lib/openai/resources/beta/assistants.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module OpenAI
44
module Resources
55
class Beta
6+
# Build Assistants that can call models and use tools.
67
class Assistants
78
# @deprecated
89
#
@@ -146,10 +147,11 @@ def update(assistant_id, params = {})
146147
# @see OpenAI::Models::Beta::AssistantListParams
147148
def list(params = {})
148149
parsed, options = OpenAI::Beta::AssistantListParams.dump_request(params)
150+
query = OpenAI::Internal::Util.encode_query_params(parsed)
149151
@client.request(
150152
method: :get,
151153
path: "assistants",
152-
query: parsed,
154+
query: query,
153155
page: OpenAI::Internal::CursorPage,
154156
model: OpenAI::Beta::Assistant,
155157
options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}

0 commit comments

Comments
 (0)