openai 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -0
- data/README.md +79 -1
- data/lib/openai/client.rb +11 -0
- data/lib/openai/errors.rb +25 -0
- data/lib/openai/internal/type/array_of.rb +6 -1
- data/lib/openai/internal/type/base_model.rb +76 -24
- data/lib/openai/internal/type/boolean.rb +7 -1
- data/lib/openai/internal/type/converter.rb +42 -34
- data/lib/openai/internal/type/enum.rb +10 -2
- data/lib/openai/internal/type/file_input.rb +6 -1
- data/lib/openai/internal/type/hash_of.rb +6 -1
- data/lib/openai/internal/type/union.rb +12 -7
- data/lib/openai/internal/type/unknown.rb +7 -1
- data/lib/openai/models/all_models.rb +4 -0
- data/lib/openai/models/audio/speech_create_params.rb +23 -2
- data/lib/openai/models/audio/transcription.rb +118 -1
- data/lib/openai/models/audio/transcription_text_done_event.rb +80 -1
- data/lib/openai/models/audio/transcription_verbose.rb +31 -1
- data/lib/openai/models/chat/chat_completion.rb +32 -31
- data/lib/openai/models/chat/chat_completion_chunk.rb +30 -29
- data/lib/openai/models/chat/completion_create_params.rb +34 -31
- data/lib/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rb +60 -25
- data/lib/openai/models/images_response.rb +92 -1
- data/lib/openai/models/responses/response.rb +59 -35
- data/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rb +17 -8
- data/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rb +14 -10
- data/lib/openai/models/responses/response_code_interpreter_call_completed_event.rb +11 -10
- data/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rb +11 -10
- data/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rb +11 -10
- data/lib/openai/models/responses/response_code_interpreter_tool_call.rb +49 -78
- data/lib/openai/models/responses/response_create_params.rb +92 -67
- data/lib/openai/models/responses/response_function_web_search.rb +115 -1
- data/lib/openai/models/responses/response_includable.rb +8 -6
- data/lib/openai/models/responses/response_output_text.rb +18 -2
- data/lib/openai/models/responses/response_stream_event.rb +2 -2
- data/lib/openai/models/responses/tool_choice_mcp.rb +40 -0
- data/lib/openai/models/responses/tool_choice_types.rb +0 -3
- data/lib/openai/models/responses_model.rb +4 -0
- data/lib/openai/models/webhooks/batch_cancelled_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/batch_completed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/batch_expired_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/batch_failed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/eval_run_canceled_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/eval_run_failed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/eval_run_succeeded_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/response_cancelled_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/response_completed_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/response_failed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/response_incomplete_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/unwrap_webhook_event.rb +59 -0
- data/lib/openai/models/webhooks/webhook_unwrap_params.rb +16 -0
- data/lib/openai/models.rb +2 -0
- data/lib/openai/resources/audio/speech.rb +3 -1
- data/lib/openai/resources/chat/completions.rb +10 -2
- data/lib/openai/resources/fine_tuning/checkpoints/permissions.rb +1 -2
- data/lib/openai/resources/responses.rb +24 -16
- data/lib/openai/resources/webhooks.rb +124 -0
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +18 -0
- data/rbi/openai/client.rbi +3 -0
- data/rbi/openai/errors.rbi +16 -0
- data/rbi/openai/internal/type/boolean.rbi +2 -0
- data/rbi/openai/internal/type/converter.rbi +15 -15
- data/rbi/openai/internal/type/union.rbi +5 -0
- data/rbi/openai/internal/type/unknown.rbi +2 -0
- data/rbi/openai/models/all_models.rbi +20 -0
- data/rbi/openai/models/audio/speech_create_params.rbi +59 -2
- data/rbi/openai/models/audio/transcription.rbi +213 -3
- data/rbi/openai/models/audio/transcription_text_done_event.rbi +146 -1
- data/rbi/openai/models/audio/transcription_verbose.rbi +47 -0
- data/rbi/openai/models/chat/chat_completion.rbi +47 -42
- data/rbi/openai/models/chat/chat_completion_chunk.rbi +47 -42
- data/rbi/openai/models/chat/completion_create_params.rbi +51 -42
- data/rbi/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rbi +95 -26
- data/rbi/openai/models/images_response.rbi +146 -0
- data/rbi/openai/models/responses/response.rbi +75 -44
- data/rbi/openai/models/responses/response_code_interpreter_call_code_delta_event.rbi +17 -7
- data/rbi/openai/models/responses/response_code_interpreter_call_code_done_event.rbi +13 -5
- data/rbi/openai/models/responses/response_code_interpreter_call_completed_event.rbi +13 -21
- data/rbi/openai/models/responses/response_code_interpreter_call_in_progress_event.rbi +13 -21
- data/rbi/openai/models/responses/response_code_interpreter_call_interpreting_event.rbi +13 -21
- data/rbi/openai/models/responses/response_code_interpreter_tool_call.rbi +83 -125
- data/rbi/openai/models/responses/response_create_params.rbi +174 -115
- data/rbi/openai/models/responses/response_function_web_search.rbi +163 -0
- data/rbi/openai/models/responses/response_includable.rbi +17 -11
- data/rbi/openai/models/responses/response_output_text.rbi +26 -4
- data/rbi/openai/models/responses/tool_choice_mcp.rbi +53 -0
- data/rbi/openai/models/responses/tool_choice_types.rbi +0 -5
- data/rbi/openai/models/responses_model.rbi +20 -0
- data/rbi/openai/models/webhooks/batch_cancelled_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/batch_completed_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/batch_expired_webhook_event.rbi +150 -0
- data/rbi/openai/models/webhooks/batch_failed_webhook_event.rbi +149 -0
- data/rbi/openai/models/webhooks/eval_run_canceled_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/eval_run_failed_webhook_event.rbi +151 -0
- data/rbi/openai/models/webhooks/eval_run_succeeded_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rbi +158 -0
- data/rbi/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rbi +156 -0
- data/rbi/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rbi +158 -0
- data/rbi/openai/models/webhooks/response_cancelled_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/response_completed_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/response_failed_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/response_incomplete_webhook_event.rbi +155 -0
- data/rbi/openai/models/webhooks/unwrap_webhook_event.rbi +40 -0
- data/rbi/openai/models/webhooks/webhook_unwrap_params.rbi +32 -0
- data/rbi/openai/models.rbi +2 -0
- data/rbi/openai/resources/audio/speech.rbi +6 -1
- data/rbi/openai/resources/chat/completions.rbi +34 -30
- data/rbi/openai/resources/fine_tuning/checkpoints/permissions.rbi +1 -3
- data/rbi/openai/resources/responses.rbi +108 -84
- data/rbi/openai/resources/webhooks.rbi +68 -0
- data/sig/openai/client.rbs +2 -0
- data/sig/openai/errors.rbs +9 -0
- data/sig/openai/internal/type/converter.rbs +7 -1
- data/sig/openai/models/all_models.rbs +8 -0
- data/sig/openai/models/audio/speech_create_params.rbs +21 -1
- data/sig/openai/models/audio/transcription.rbs +95 -3
- data/sig/openai/models/audio/transcription_text_done_event.rbs +72 -2
- data/sig/openai/models/audio/transcription_verbose.rbs +21 -0
- data/sig/openai/models/chat/chat_completion.rbs +2 -1
- data/sig/openai/models/chat/chat_completion_chunk.rbs +2 -1
- data/sig/openai/models/chat/completion_create_params.rbs +2 -1
- data/sig/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rbs +53 -16
- data/sig/openai/models/images_response.rbs +83 -0
- data/sig/openai/models/responses/response.rbs +13 -1
- data/sig/openai/models/responses/response_code_interpreter_call_code_delta_event.rbs +5 -0
- data/sig/openai/models/responses/response_code_interpreter_call_code_done_event.rbs +5 -0
- data/sig/openai/models/responses/response_code_interpreter_call_completed_event.rbs +4 -4
- data/sig/openai/models/responses/response_code_interpreter_call_in_progress_event.rbs +4 -4
- data/sig/openai/models/responses/response_code_interpreter_call_interpreting_event.rbs +4 -4
- data/sig/openai/models/responses/response_code_interpreter_tool_call.rbs +31 -52
- data/sig/openai/models/responses/response_create_params.rbs +31 -11
- data/sig/openai/models/responses/response_function_web_search.rbs +54 -0
- data/sig/openai/models/responses/response_includable.rbs +7 -5
- data/sig/openai/models/responses/response_output_text.rbs +15 -1
- data/sig/openai/models/responses/tool_choice_mcp.rbs +23 -0
- data/sig/openai/models/responses/tool_choice_types.rbs +0 -2
- data/sig/openai/models/responses_model.rbs +8 -0
- data/sig/openai/models/webhooks/batch_cancelled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/batch_completed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/batch_expired_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/batch_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/eval_run_canceled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/eval_run_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/eval_run_succeeded_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_cancelled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_completed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_incomplete_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/unwrap_webhook_event.rbs +27 -0
- data/sig/openai/models/webhooks/webhook_unwrap_params.rbs +17 -0
- data/sig/openai/models.rbs +2 -0
- data/sig/openai/resources/audio/speech.rbs +1 -0
- data/sig/openai/resources/fine_tuning/checkpoints/permissions.rbs +1 -1
- data/sig/openai/resources/responses.rbs +8 -4
- data/sig/openai/resources/webhooks.rbs +33 -0
- metadata +56 -2
@@ -28,12 +28,34 @@ module OpenAI
|
|
28
28
|
end
|
29
29
|
attr_writer :logprobs
|
30
30
|
|
31
|
+
# Token usage statistics for the request.
|
32
|
+
sig do
|
33
|
+
returns(T.nilable(OpenAI::Audio::Transcription::Usage::Variants))
|
34
|
+
end
|
35
|
+
attr_reader :usage
|
36
|
+
|
37
|
+
sig do
|
38
|
+
params(
|
39
|
+
usage:
|
40
|
+
T.any(
|
41
|
+
OpenAI::Audio::Transcription::Usage::Tokens::OrHash,
|
42
|
+
OpenAI::Audio::Transcription::Usage::Duration::OrHash
|
43
|
+
)
|
44
|
+
).void
|
45
|
+
end
|
46
|
+
attr_writer :usage
|
47
|
+
|
31
48
|
# Represents a transcription response returned by model, based on the provided
|
32
49
|
# input.
|
33
50
|
sig do
|
34
51
|
params(
|
35
52
|
text: String,
|
36
|
-
logprobs: T::Array[OpenAI::Audio::Transcription::Logprob::OrHash]
|
53
|
+
logprobs: T::Array[OpenAI::Audio::Transcription::Logprob::OrHash],
|
54
|
+
usage:
|
55
|
+
T.any(
|
56
|
+
OpenAI::Audio::Transcription::Usage::Tokens::OrHash,
|
57
|
+
OpenAI::Audio::Transcription::Usage::Duration::OrHash
|
58
|
+
)
|
37
59
|
).returns(T.attached_class)
|
38
60
|
end
|
39
61
|
def self.new(
|
@@ -42,7 +64,9 @@ module OpenAI
|
|
42
64
|
# The log probabilities of the tokens in the transcription. Only returned with the
|
43
65
|
# models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
|
44
66
|
# to the `include` array.
|
45
|
-
logprobs: nil
|
67
|
+
logprobs: nil,
|
68
|
+
# Token usage statistics for the request.
|
69
|
+
usage: nil
|
46
70
|
)
|
47
71
|
end
|
48
72
|
|
@@ -50,7 +74,8 @@ module OpenAI
|
|
50
74
|
override.returns(
|
51
75
|
{
|
52
76
|
text: String,
|
53
|
-
logprobs: T::Array[OpenAI::Audio::Transcription::Logprob]
|
77
|
+
logprobs: T::Array[OpenAI::Audio::Transcription::Logprob],
|
78
|
+
usage: OpenAI::Audio::Transcription::Usage::Variants
|
54
79
|
}
|
55
80
|
)
|
56
81
|
end
|
@@ -112,6 +137,191 @@ module OpenAI
|
|
112
137
|
def to_hash
|
113
138
|
end
|
114
139
|
end
|
140
|
+
|
141
|
+
# Token usage statistics for the request.
|
142
|
+
module Usage
|
143
|
+
extend OpenAI::Internal::Type::Union
|
144
|
+
|
145
|
+
Variants =
|
146
|
+
T.type_alias do
|
147
|
+
T.any(
|
148
|
+
OpenAI::Audio::Transcription::Usage::Tokens,
|
149
|
+
OpenAI::Audio::Transcription::Usage::Duration
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
class Tokens < OpenAI::Internal::Type::BaseModel
|
154
|
+
OrHash =
|
155
|
+
T.type_alias do
|
156
|
+
T.any(
|
157
|
+
OpenAI::Audio::Transcription::Usage::Tokens,
|
158
|
+
OpenAI::Internal::AnyHash
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Number of input tokens billed for this request.
|
163
|
+
sig { returns(Integer) }
|
164
|
+
attr_accessor :input_tokens
|
165
|
+
|
166
|
+
# Number of output tokens generated.
|
167
|
+
sig { returns(Integer) }
|
168
|
+
attr_accessor :output_tokens
|
169
|
+
|
170
|
+
# Total number of tokens used (input + output).
|
171
|
+
sig { returns(Integer) }
|
172
|
+
attr_accessor :total_tokens
|
173
|
+
|
174
|
+
# The type of the usage object. Always `tokens` for this variant.
|
175
|
+
sig { returns(Symbol) }
|
176
|
+
attr_accessor :type
|
177
|
+
|
178
|
+
# Details about the input tokens billed for this request.
|
179
|
+
sig do
|
180
|
+
returns(
|
181
|
+
T.nilable(
|
182
|
+
OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
|
183
|
+
)
|
184
|
+
)
|
185
|
+
end
|
186
|
+
attr_reader :input_token_details
|
187
|
+
|
188
|
+
sig do
|
189
|
+
params(
|
190
|
+
input_token_details:
|
191
|
+
OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails::OrHash
|
192
|
+
).void
|
193
|
+
end
|
194
|
+
attr_writer :input_token_details
|
195
|
+
|
196
|
+
# Usage statistics for models billed by token usage.
|
197
|
+
sig do
|
198
|
+
params(
|
199
|
+
input_tokens: Integer,
|
200
|
+
output_tokens: Integer,
|
201
|
+
total_tokens: Integer,
|
202
|
+
input_token_details:
|
203
|
+
OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails::OrHash,
|
204
|
+
type: Symbol
|
205
|
+
).returns(T.attached_class)
|
206
|
+
end
|
207
|
+
def self.new(
|
208
|
+
# Number of input tokens billed for this request.
|
209
|
+
input_tokens:,
|
210
|
+
# Number of output tokens generated.
|
211
|
+
output_tokens:,
|
212
|
+
# Total number of tokens used (input + output).
|
213
|
+
total_tokens:,
|
214
|
+
# Details about the input tokens billed for this request.
|
215
|
+
input_token_details: nil,
|
216
|
+
# The type of the usage object. Always `tokens` for this variant.
|
217
|
+
type: :tokens
|
218
|
+
)
|
219
|
+
end
|
220
|
+
|
221
|
+
sig do
|
222
|
+
override.returns(
|
223
|
+
{
|
224
|
+
input_tokens: Integer,
|
225
|
+
output_tokens: Integer,
|
226
|
+
total_tokens: Integer,
|
227
|
+
type: Symbol,
|
228
|
+
input_token_details:
|
229
|
+
OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
|
230
|
+
}
|
231
|
+
)
|
232
|
+
end
|
233
|
+
def to_hash
|
234
|
+
end
|
235
|
+
|
236
|
+
class InputTokenDetails < OpenAI::Internal::Type::BaseModel
|
237
|
+
OrHash =
|
238
|
+
T.type_alias do
|
239
|
+
T.any(
|
240
|
+
OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails,
|
241
|
+
OpenAI::Internal::AnyHash
|
242
|
+
)
|
243
|
+
end
|
244
|
+
|
245
|
+
# Number of audio tokens billed for this request.
|
246
|
+
sig { returns(T.nilable(Integer)) }
|
247
|
+
attr_reader :audio_tokens
|
248
|
+
|
249
|
+
sig { params(audio_tokens: Integer).void }
|
250
|
+
attr_writer :audio_tokens
|
251
|
+
|
252
|
+
# Number of text tokens billed for this request.
|
253
|
+
sig { returns(T.nilable(Integer)) }
|
254
|
+
attr_reader :text_tokens
|
255
|
+
|
256
|
+
sig { params(text_tokens: Integer).void }
|
257
|
+
attr_writer :text_tokens
|
258
|
+
|
259
|
+
# Details about the input tokens billed for this request.
|
260
|
+
sig do
|
261
|
+
params(audio_tokens: Integer, text_tokens: Integer).returns(
|
262
|
+
T.attached_class
|
263
|
+
)
|
264
|
+
end
|
265
|
+
def self.new(
|
266
|
+
# Number of audio tokens billed for this request.
|
267
|
+
audio_tokens: nil,
|
268
|
+
# Number of text tokens billed for this request.
|
269
|
+
text_tokens: nil
|
270
|
+
)
|
271
|
+
end
|
272
|
+
|
273
|
+
sig do
|
274
|
+
override.returns(
|
275
|
+
{ audio_tokens: Integer, text_tokens: Integer }
|
276
|
+
)
|
277
|
+
end
|
278
|
+
def to_hash
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
class Duration < OpenAI::Internal::Type::BaseModel
|
284
|
+
OrHash =
|
285
|
+
T.type_alias do
|
286
|
+
T.any(
|
287
|
+
OpenAI::Audio::Transcription::Usage::Duration,
|
288
|
+
OpenAI::Internal::AnyHash
|
289
|
+
)
|
290
|
+
end
|
291
|
+
|
292
|
+
# Duration of the input audio in seconds.
|
293
|
+
sig { returns(Float) }
|
294
|
+
attr_accessor :duration
|
295
|
+
|
296
|
+
# The type of the usage object. Always `duration` for this variant.
|
297
|
+
sig { returns(Symbol) }
|
298
|
+
attr_accessor :type
|
299
|
+
|
300
|
+
# Usage statistics for models billed by audio input duration.
|
301
|
+
sig do
|
302
|
+
params(duration: Float, type: Symbol).returns(T.attached_class)
|
303
|
+
end
|
304
|
+
def self.new(
|
305
|
+
# Duration of the input audio in seconds.
|
306
|
+
duration:,
|
307
|
+
# The type of the usage object. Always `duration` for this variant.
|
308
|
+
type: :duration
|
309
|
+
)
|
310
|
+
end
|
311
|
+
|
312
|
+
sig { override.returns({ duration: Float, type: Symbol }) }
|
313
|
+
def to_hash
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
sig do
|
318
|
+
override.returns(
|
319
|
+
T::Array[OpenAI::Audio::Transcription::Usage::Variants]
|
320
|
+
)
|
321
|
+
end
|
322
|
+
def self.variants
|
323
|
+
end
|
324
|
+
end
|
115
325
|
end
|
116
326
|
end
|
117
327
|
end
|
@@ -43,6 +43,19 @@ module OpenAI
|
|
43
43
|
end
|
44
44
|
attr_writer :logprobs
|
45
45
|
|
46
|
+
# Usage statistics for models billed by token usage.
|
47
|
+
sig do
|
48
|
+
returns(T.nilable(OpenAI::Audio::TranscriptionTextDoneEvent::Usage))
|
49
|
+
end
|
50
|
+
attr_reader :usage
|
51
|
+
|
52
|
+
sig do
|
53
|
+
params(
|
54
|
+
usage: OpenAI::Audio::TranscriptionTextDoneEvent::Usage::OrHash
|
55
|
+
).void
|
56
|
+
end
|
57
|
+
attr_writer :usage
|
58
|
+
|
46
59
|
# Emitted when the transcription is complete. Contains the complete transcription
|
47
60
|
# text. Only emitted when you
|
48
61
|
# [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
@@ -54,6 +67,7 @@ module OpenAI
|
|
54
67
|
T::Array[
|
55
68
|
OpenAI::Audio::TranscriptionTextDoneEvent::Logprob::OrHash
|
56
69
|
],
|
70
|
+
usage: OpenAI::Audio::TranscriptionTextDoneEvent::Usage::OrHash,
|
57
71
|
type: Symbol
|
58
72
|
).returns(T.attached_class)
|
59
73
|
end
|
@@ -65,6 +79,8 @@ module OpenAI
|
|
65
79
|
# [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
|
66
80
|
# with the `include[]` parameter set to `logprobs`.
|
67
81
|
logprobs: nil,
|
82
|
+
# Usage statistics for models billed by token usage.
|
83
|
+
usage: nil,
|
68
84
|
# The type of the event. Always `transcript.text.done`.
|
69
85
|
type: :"transcript.text.done"
|
70
86
|
)
|
@@ -76,7 +92,8 @@ module OpenAI
|
|
76
92
|
text: String,
|
77
93
|
type: Symbol,
|
78
94
|
logprobs:
|
79
|
-
T::Array[OpenAI::Audio::TranscriptionTextDoneEvent::Logprob]
|
95
|
+
T::Array[OpenAI::Audio::TranscriptionTextDoneEvent::Logprob],
|
96
|
+
usage: OpenAI::Audio::TranscriptionTextDoneEvent::Usage
|
80
97
|
}
|
81
98
|
)
|
82
99
|
end
|
@@ -138,6 +155,134 @@ module OpenAI
|
|
138
155
|
def to_hash
|
139
156
|
end
|
140
157
|
end
|
158
|
+
|
159
|
+
class Usage < OpenAI::Internal::Type::BaseModel
|
160
|
+
OrHash =
|
161
|
+
T.type_alias do
|
162
|
+
T.any(
|
163
|
+
OpenAI::Audio::TranscriptionTextDoneEvent::Usage,
|
164
|
+
OpenAI::Internal::AnyHash
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Number of input tokens billed for this request.
|
169
|
+
sig { returns(Integer) }
|
170
|
+
attr_accessor :input_tokens
|
171
|
+
|
172
|
+
# Number of output tokens generated.
|
173
|
+
sig { returns(Integer) }
|
174
|
+
attr_accessor :output_tokens
|
175
|
+
|
176
|
+
# Total number of tokens used (input + output).
|
177
|
+
sig { returns(Integer) }
|
178
|
+
attr_accessor :total_tokens
|
179
|
+
|
180
|
+
# The type of the usage object. Always `tokens` for this variant.
|
181
|
+
sig { returns(Symbol) }
|
182
|
+
attr_accessor :type
|
183
|
+
|
184
|
+
# Details about the input tokens billed for this request.
|
185
|
+
sig do
|
186
|
+
returns(
|
187
|
+
T.nilable(
|
188
|
+
OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails
|
189
|
+
)
|
190
|
+
)
|
191
|
+
end
|
192
|
+
attr_reader :input_token_details
|
193
|
+
|
194
|
+
sig do
|
195
|
+
params(
|
196
|
+
input_token_details:
|
197
|
+
OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails::OrHash
|
198
|
+
).void
|
199
|
+
end
|
200
|
+
attr_writer :input_token_details
|
201
|
+
|
202
|
+
# Usage statistics for models billed by token usage.
|
203
|
+
sig do
|
204
|
+
params(
|
205
|
+
input_tokens: Integer,
|
206
|
+
output_tokens: Integer,
|
207
|
+
total_tokens: Integer,
|
208
|
+
input_token_details:
|
209
|
+
OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails::OrHash,
|
210
|
+
type: Symbol
|
211
|
+
).returns(T.attached_class)
|
212
|
+
end
|
213
|
+
def self.new(
|
214
|
+
# Number of input tokens billed for this request.
|
215
|
+
input_tokens:,
|
216
|
+
# Number of output tokens generated.
|
217
|
+
output_tokens:,
|
218
|
+
# Total number of tokens used (input + output).
|
219
|
+
total_tokens:,
|
220
|
+
# Details about the input tokens billed for this request.
|
221
|
+
input_token_details: nil,
|
222
|
+
# The type of the usage object. Always `tokens` for this variant.
|
223
|
+
type: :tokens
|
224
|
+
)
|
225
|
+
end
|
226
|
+
|
227
|
+
sig do
|
228
|
+
override.returns(
|
229
|
+
{
|
230
|
+
input_tokens: Integer,
|
231
|
+
output_tokens: Integer,
|
232
|
+
total_tokens: Integer,
|
233
|
+
type: Symbol,
|
234
|
+
input_token_details:
|
235
|
+
OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails
|
236
|
+
}
|
237
|
+
)
|
238
|
+
end
|
239
|
+
def to_hash
|
240
|
+
end
|
241
|
+
|
242
|
+
class InputTokenDetails < OpenAI::Internal::Type::BaseModel
|
243
|
+
OrHash =
|
244
|
+
T.type_alias do
|
245
|
+
T.any(
|
246
|
+
OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails,
|
247
|
+
OpenAI::Internal::AnyHash
|
248
|
+
)
|
249
|
+
end
|
250
|
+
|
251
|
+
# Number of audio tokens billed for this request.
|
252
|
+
sig { returns(T.nilable(Integer)) }
|
253
|
+
attr_reader :audio_tokens
|
254
|
+
|
255
|
+
sig { params(audio_tokens: Integer).void }
|
256
|
+
attr_writer :audio_tokens
|
257
|
+
|
258
|
+
# Number of text tokens billed for this request.
|
259
|
+
sig { returns(T.nilable(Integer)) }
|
260
|
+
attr_reader :text_tokens
|
261
|
+
|
262
|
+
sig { params(text_tokens: Integer).void }
|
263
|
+
attr_writer :text_tokens
|
264
|
+
|
265
|
+
# Details about the input tokens billed for this request.
|
266
|
+
sig do
|
267
|
+
params(audio_tokens: Integer, text_tokens: Integer).returns(
|
268
|
+
T.attached_class
|
269
|
+
)
|
270
|
+
end
|
271
|
+
def self.new(
|
272
|
+
# Number of audio tokens billed for this request.
|
273
|
+
audio_tokens: nil,
|
274
|
+
# Number of text tokens billed for this request.
|
275
|
+
text_tokens: nil
|
276
|
+
)
|
277
|
+
end
|
278
|
+
|
279
|
+
sig do
|
280
|
+
override.returns({ audio_tokens: Integer, text_tokens: Integer })
|
281
|
+
end
|
282
|
+
def to_hash
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
141
286
|
end
|
142
287
|
end
|
143
288
|
end
|
@@ -37,6 +37,15 @@ module OpenAI
|
|
37
37
|
end
|
38
38
|
attr_writer :segments
|
39
39
|
|
40
|
+
# Usage statistics for models billed by audio input duration.
|
41
|
+
sig { returns(T.nilable(OpenAI::Audio::TranscriptionVerbose::Usage)) }
|
42
|
+
attr_reader :usage
|
43
|
+
|
44
|
+
sig do
|
45
|
+
params(usage: OpenAI::Audio::TranscriptionVerbose::Usage::OrHash).void
|
46
|
+
end
|
47
|
+
attr_writer :usage
|
48
|
+
|
40
49
|
# Extracted words and their corresponding timestamps.
|
41
50
|
sig { returns(T.nilable(T::Array[OpenAI::Audio::TranscriptionWord])) }
|
42
51
|
attr_reader :words
|
@@ -54,6 +63,7 @@ module OpenAI
|
|
54
63
|
language: String,
|
55
64
|
text: String,
|
56
65
|
segments: T::Array[OpenAI::Audio::TranscriptionSegment::OrHash],
|
66
|
+
usage: OpenAI::Audio::TranscriptionVerbose::Usage::OrHash,
|
57
67
|
words: T::Array[OpenAI::Audio::TranscriptionWord::OrHash]
|
58
68
|
).returns(T.attached_class)
|
59
69
|
end
|
@@ -66,6 +76,8 @@ module OpenAI
|
|
66
76
|
text:,
|
67
77
|
# Segments of the transcribed text and their corresponding details.
|
68
78
|
segments: nil,
|
79
|
+
# Usage statistics for models billed by audio input duration.
|
80
|
+
usage: nil,
|
69
81
|
# Extracted words and their corresponding timestamps.
|
70
82
|
words: nil
|
71
83
|
)
|
@@ -78,12 +90,47 @@ module OpenAI
|
|
78
90
|
language: String,
|
79
91
|
text: String,
|
80
92
|
segments: T::Array[OpenAI::Audio::TranscriptionSegment],
|
93
|
+
usage: OpenAI::Audio::TranscriptionVerbose::Usage,
|
81
94
|
words: T::Array[OpenAI::Audio::TranscriptionWord]
|
82
95
|
}
|
83
96
|
)
|
84
97
|
end
|
85
98
|
def to_hash
|
86
99
|
end
|
100
|
+
|
101
|
+
class Usage < OpenAI::Internal::Type::BaseModel
|
102
|
+
OrHash =
|
103
|
+
T.type_alias do
|
104
|
+
T.any(
|
105
|
+
OpenAI::Audio::TranscriptionVerbose::Usage,
|
106
|
+
OpenAI::Internal::AnyHash
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Duration of the input audio in seconds.
|
111
|
+
sig { returns(Float) }
|
112
|
+
attr_accessor :duration
|
113
|
+
|
114
|
+
# The type of the usage object. Always `duration` for this variant.
|
115
|
+
sig { returns(Symbol) }
|
116
|
+
attr_accessor :type
|
117
|
+
|
118
|
+
# Usage statistics for models billed by audio input duration.
|
119
|
+
sig do
|
120
|
+
params(duration: Float, type: Symbol).returns(T.attached_class)
|
121
|
+
end
|
122
|
+
def self.new(
|
123
|
+
# Duration of the input audio in seconds.
|
124
|
+
duration:,
|
125
|
+
# The type of the usage object. Always `duration` for this variant.
|
126
|
+
type: :duration
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
sig { override.returns({ duration: Float, type: Symbol }) }
|
131
|
+
def to_hash
|
132
|
+
end
|
133
|
+
end
|
87
134
|
end
|
88
135
|
end
|
89
136
|
end
|
@@ -32,23 +32,23 @@ module OpenAI
|
|
32
32
|
sig { returns(Symbol) }
|
33
33
|
attr_accessor :object
|
34
34
|
|
35
|
-
# Specifies the
|
36
|
-
# relevant for customers subscribed to the scale tier service:
|
35
|
+
# Specifies the processing type used for serving the request.
|
37
36
|
#
|
38
|
-
# - If set to 'auto',
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
# - If set to '
|
44
|
-
#
|
45
|
-
# -
|
46
|
-
#
|
47
|
-
# [Learn more](https://platform.openai.com/docs/guides/flex-processing).
|
37
|
+
# - If set to 'auto', then the request will be processed with the service tier
|
38
|
+
# configured in the Project settings. Unless otherwise configured, the Project
|
39
|
+
# will use 'default'.
|
40
|
+
# - If set to 'default', then the requset will be processed with the standard
|
41
|
+
# pricing and performance for the selected model.
|
42
|
+
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
43
|
+
# 'priority', then the request will be processed with the corresponding service
|
44
|
+
# tier. [Contact sales](https://openai.com/contact-sales) to learn more about
|
45
|
+
# Priority processing.
|
48
46
|
# - When not set, the default behavior is 'auto'.
|
49
47
|
#
|
50
|
-
# When
|
51
|
-
#
|
48
|
+
# When the `service_tier` parameter is set, the response body will include the
|
49
|
+
# `service_tier` value based on the processing mode actually used to serve the
|
50
|
+
# request. This response value may be different from the value set in the
|
51
|
+
# parameter.
|
52
52
|
sig do
|
53
53
|
returns(
|
54
54
|
T.nilable(OpenAI::Chat::ChatCompletion::ServiceTier::TaggedSymbol)
|
@@ -98,23 +98,23 @@ module OpenAI
|
|
98
98
|
created:,
|
99
99
|
# The model used for the chat completion.
|
100
100
|
model:,
|
101
|
-
# Specifies the
|
102
|
-
# relevant for customers subscribed to the scale tier service:
|
101
|
+
# Specifies the processing type used for serving the request.
|
103
102
|
#
|
104
|
-
# - If set to 'auto',
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# - If set to '
|
110
|
-
#
|
111
|
-
# -
|
112
|
-
#
|
113
|
-
# [Learn more](https://platform.openai.com/docs/guides/flex-processing).
|
103
|
+
# - If set to 'auto', then the request will be processed with the service tier
|
104
|
+
# configured in the Project settings. Unless otherwise configured, the Project
|
105
|
+
# will use 'default'.
|
106
|
+
# - If set to 'default', then the requset will be processed with the standard
|
107
|
+
# pricing and performance for the selected model.
|
108
|
+
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
109
|
+
# 'priority', then the request will be processed with the corresponding service
|
110
|
+
# tier. [Contact sales](https://openai.com/contact-sales) to learn more about
|
111
|
+
# Priority processing.
|
114
112
|
# - When not set, the default behavior is 'auto'.
|
115
113
|
#
|
116
|
-
# When
|
117
|
-
#
|
114
|
+
# When the `service_tier` parameter is set, the response body will include the
|
115
|
+
# `service_tier` value based on the processing mode actually used to serve the
|
116
|
+
# request. This response value may be different from the value set in the
|
117
|
+
# parameter.
|
118
118
|
service_tier: nil,
|
119
119
|
# This fingerprint represents the backend configuration that the model runs with.
|
120
120
|
#
|
@@ -363,23 +363,23 @@ module OpenAI
|
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
366
|
-
# Specifies the
|
367
|
-
# relevant for customers subscribed to the scale tier service:
|
366
|
+
# Specifies the processing type used for serving the request.
|
368
367
|
#
|
369
|
-
# - If set to 'auto',
|
370
|
-
#
|
371
|
-
#
|
372
|
-
#
|
373
|
-
#
|
374
|
-
# - If set to '
|
375
|
-
#
|
376
|
-
# -
|
377
|
-
#
|
378
|
-
# [Learn more](https://platform.openai.com/docs/guides/flex-processing).
|
368
|
+
# - If set to 'auto', then the request will be processed with the service tier
|
369
|
+
# configured in the Project settings. Unless otherwise configured, the Project
|
370
|
+
# will use 'default'.
|
371
|
+
# - If set to 'default', then the requset will be processed with the standard
|
372
|
+
# pricing and performance for the selected model.
|
373
|
+
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
374
|
+
# 'priority', then the request will be processed with the corresponding service
|
375
|
+
# tier. [Contact sales](https://openai.com/contact-sales) to learn more about
|
376
|
+
# Priority processing.
|
379
377
|
# - When not set, the default behavior is 'auto'.
|
380
378
|
#
|
381
|
-
# When
|
382
|
-
#
|
379
|
+
# When the `service_tier` parameter is set, the response body will include the
|
380
|
+
# `service_tier` value based on the processing mode actually used to serve the
|
381
|
+
# request. This response value may be different from the value set in the
|
382
|
+
# parameter.
|
383
383
|
module ServiceTier
|
384
384
|
extend OpenAI::Internal::Type::Enum
|
385
385
|
|
@@ -409,6 +409,11 @@ module OpenAI
|
|
409
409
|
:scale,
|
410
410
|
OpenAI::Chat::ChatCompletion::ServiceTier::TaggedSymbol
|
411
411
|
)
|
412
|
+
PRIORITY =
|
413
|
+
T.let(
|
414
|
+
:priority,
|
415
|
+
OpenAI::Chat::ChatCompletion::ServiceTier::TaggedSymbol
|
416
|
+
)
|
412
417
|
|
413
418
|
sig do
|
414
419
|
override.returns(
|