openai 0.33.0 → 0.34.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 +13 -0
- data/README.md +1 -1
- data/lib/openai/models/conversations/conversation_item.rb +0 -4
- data/lib/openai/models/conversations/item_list_params.rb +1 -1
- data/lib/openai/models/custom_tool_input_format.rb +0 -6
- data/lib/openai/models/image_edit_params.rb +1 -1
- data/lib/openai/models/responses/custom_tool.rb +0 -6
- data/lib/openai/models/responses/input_token_count_params.rb +283 -0
- data/lib/openai/models/responses/input_token_count_response.rb +24 -0
- data/lib/openai/models/responses/response_code_interpreter_tool_call.rb +4 -4
- data/lib/openai/models/responses/response_computer_tool_call.rb +13 -18
- data/lib/openai/models/responses/response_computer_tool_call_output_item.rb +7 -7
- data/lib/openai/models/responses/response_create_params.rb +1 -1
- data/lib/openai/models/responses/response_includable.rb +5 -3
- data/lib/openai/models/responses/response_input_item.rb +0 -4
- data/lib/openai/models/responses/response_item.rb +0 -4
- data/lib/openai/models/responses/response_output_item.rb +0 -4
- data/lib/openai/models/responses/tool.rb +2 -12
- data/lib/openai/resources/conversations/items.rb +1 -1
- data/lib/openai/resources/images.rb +2 -2
- data/lib/openai/resources/responses/input_tokens.rb +61 -0
- data/lib/openai/resources/responses.rb +6 -2
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +3 -0
- data/rbi/openai/models/custom_tool_input_format.rbi +0 -2
- data/rbi/openai/models/responses/custom_tool.rbi +0 -2
- data/rbi/openai/models/responses/input_token_count_params.rbi +601 -0
- data/rbi/openai/models/responses/input_token_count_response.rbi +35 -0
- data/rbi/openai/models/responses/response_code_interpreter_tool_call.rbi +4 -4
- data/rbi/openai/models/responses/response_computer_tool_call.rbi +19 -13
- data/rbi/openai/models/responses/response_computer_tool_call_output_item.rbi +16 -8
- data/rbi/openai/models/responses/response_includable.rbi +18 -8
- data/rbi/openai/models/responses/tool.rbi +0 -1
- data/rbi/openai/resources/responses/input_tokens.rbi +120 -0
- data/rbi/openai/resources/responses.rbi +3 -0
- data/sig/openai/models/responses/input_token_count_params.rbs +165 -0
- data/sig/openai/models/responses/input_token_count_response.rbs +24 -0
- data/sig/openai/models/responses/response_computer_tool_call.rbs +9 -5
- data/sig/openai/models/responses/response_computer_tool_call_output_item.rbs +9 -5
- data/sig/openai/models/responses/response_includable.rbs +11 -7
- data/sig/openai/resources/responses/input_tokens.rbs +24 -0
- data/sig/openai/resources/responses.rbs +2 -0
- metadata +11 -2
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OpenAI
|
|
4
|
+
module Models
|
|
5
|
+
module Responses
|
|
6
|
+
class InputTokenCountParams < OpenAI::Internal::Type::BaseModel
|
|
7
|
+
extend OpenAI::Internal::Type::RequestParameters::Converter
|
|
8
|
+
include OpenAI::Internal::Type::RequestParameters
|
|
9
|
+
|
|
10
|
+
OrHash =
|
|
11
|
+
T.type_alias do
|
|
12
|
+
T.any(
|
|
13
|
+
OpenAI::Responses::InputTokenCountParams,
|
|
14
|
+
OpenAI::Internal::AnyHash
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# The conversation that this response belongs to. Items from this conversation are
|
|
19
|
+
# prepended to `input_items` for this response request. Input items and output
|
|
20
|
+
# items from this response are automatically added to this conversation after this
|
|
21
|
+
# response completes.
|
|
22
|
+
sig do
|
|
23
|
+
returns(
|
|
24
|
+
T.nilable(
|
|
25
|
+
T.any(String, OpenAI::Responses::ResponseConversationParam)
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
attr_accessor :conversation
|
|
30
|
+
|
|
31
|
+
# Text, image, or file inputs to the model, used to generate a response
|
|
32
|
+
sig do
|
|
33
|
+
returns(
|
|
34
|
+
T.nilable(OpenAI::Responses::InputTokenCountParams::Input::Variants)
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
attr_accessor :input
|
|
38
|
+
|
|
39
|
+
# A system (or developer) message inserted into the model's context. When used
|
|
40
|
+
# along with `previous_response_id`, the instructions from a previous response
|
|
41
|
+
# will not be carried over to the next response. This makes it simple to swap out
|
|
42
|
+
# system (or developer) messages in new responses.
|
|
43
|
+
sig { returns(T.nilable(String)) }
|
|
44
|
+
attr_accessor :instructions
|
|
45
|
+
|
|
46
|
+
# Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
|
47
|
+
# wide range of models with different capabilities, performance characteristics,
|
|
48
|
+
# and price points. Refer to the
|
|
49
|
+
# [model guide](https://platform.openai.com/docs/models) to browse and compare
|
|
50
|
+
# available models.
|
|
51
|
+
sig { returns(T.nilable(String)) }
|
|
52
|
+
attr_accessor :model
|
|
53
|
+
|
|
54
|
+
# Whether to allow the model to run tool calls in parallel.
|
|
55
|
+
sig { returns(T.nilable(T::Boolean)) }
|
|
56
|
+
attr_accessor :parallel_tool_calls
|
|
57
|
+
|
|
58
|
+
# The unique ID of the previous response to the model. Use this to create
|
|
59
|
+
# multi-turn conversations. Learn more about
|
|
60
|
+
# [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
|
61
|
+
# Cannot be used in conjunction with `conversation`.
|
|
62
|
+
sig { returns(T.nilable(String)) }
|
|
63
|
+
attr_accessor :previous_response_id
|
|
64
|
+
|
|
65
|
+
# **gpt-5 and o-series models only** Configuration options for
|
|
66
|
+
# [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
|
67
|
+
sig { returns(T.nilable(OpenAI::Reasoning)) }
|
|
68
|
+
attr_reader :reasoning
|
|
69
|
+
|
|
70
|
+
sig { params(reasoning: T.nilable(OpenAI::Reasoning::OrHash)).void }
|
|
71
|
+
attr_writer :reasoning
|
|
72
|
+
|
|
73
|
+
# Configuration options for a text response from the model. Can be plain text or
|
|
74
|
+
# structured JSON data. Learn more:
|
|
75
|
+
#
|
|
76
|
+
# - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
|
77
|
+
# - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
|
78
|
+
sig do
|
|
79
|
+
returns(T.nilable(OpenAI::Responses::InputTokenCountParams::Text))
|
|
80
|
+
end
|
|
81
|
+
attr_reader :text
|
|
82
|
+
|
|
83
|
+
sig do
|
|
84
|
+
params(
|
|
85
|
+
text:
|
|
86
|
+
T.nilable(OpenAI::Responses::InputTokenCountParams::Text::OrHash)
|
|
87
|
+
).void
|
|
88
|
+
end
|
|
89
|
+
attr_writer :text
|
|
90
|
+
|
|
91
|
+
# How the model should select which tool (or tools) to use when generating a
|
|
92
|
+
# response. See the `tools` parameter to see how to specify which tools the model
|
|
93
|
+
# can call.
|
|
94
|
+
sig do
|
|
95
|
+
returns(
|
|
96
|
+
T.nilable(
|
|
97
|
+
T.any(
|
|
98
|
+
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
|
99
|
+
OpenAI::Responses::ToolChoiceAllowed,
|
|
100
|
+
OpenAI::Responses::ToolChoiceTypes,
|
|
101
|
+
OpenAI::Responses::ToolChoiceFunction,
|
|
102
|
+
OpenAI::Responses::ToolChoiceMcp,
|
|
103
|
+
OpenAI::Responses::ToolChoiceCustom
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
end
|
|
108
|
+
attr_accessor :tool_choice
|
|
109
|
+
|
|
110
|
+
# An array of tools the model may call while generating a response. You can
|
|
111
|
+
# specify which tool to use by setting the `tool_choice` parameter.
|
|
112
|
+
sig do
|
|
113
|
+
returns(
|
|
114
|
+
T.nilable(
|
|
115
|
+
T::Array[
|
|
116
|
+
T.any(
|
|
117
|
+
OpenAI::Responses::FunctionTool,
|
|
118
|
+
OpenAI::Responses::FileSearchTool,
|
|
119
|
+
OpenAI::Responses::ComputerTool,
|
|
120
|
+
OpenAI::Responses::Tool::Mcp,
|
|
121
|
+
OpenAI::Responses::Tool::CodeInterpreter,
|
|
122
|
+
OpenAI::Responses::Tool::ImageGeneration,
|
|
123
|
+
OpenAI::Responses::Tool::LocalShell,
|
|
124
|
+
OpenAI::Responses::CustomTool,
|
|
125
|
+
OpenAI::Responses::WebSearchTool,
|
|
126
|
+
OpenAI::Responses::WebSearchPreviewTool
|
|
127
|
+
)
|
|
128
|
+
]
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
end
|
|
132
|
+
attr_accessor :tools
|
|
133
|
+
|
|
134
|
+
# The truncation strategy to use for the model response. - `auto`: If the input to
|
|
135
|
+
# this Response exceeds the model's context window size, the model will truncate
|
|
136
|
+
# the response to fit the context window by dropping items from the beginning of
|
|
137
|
+
# the conversation. - `disabled` (default): If the input size will exceed the
|
|
138
|
+
# context window size for a model, the request will fail with a 400 error.
|
|
139
|
+
sig do
|
|
140
|
+
returns(
|
|
141
|
+
T.nilable(
|
|
142
|
+
OpenAI::Responses::InputTokenCountParams::Truncation::OrSymbol
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
end
|
|
146
|
+
attr_reader :truncation
|
|
147
|
+
|
|
148
|
+
sig do
|
|
149
|
+
params(
|
|
150
|
+
truncation:
|
|
151
|
+
OpenAI::Responses::InputTokenCountParams::Truncation::OrSymbol
|
|
152
|
+
).void
|
|
153
|
+
end
|
|
154
|
+
attr_writer :truncation
|
|
155
|
+
|
|
156
|
+
sig do
|
|
157
|
+
params(
|
|
158
|
+
conversation:
|
|
159
|
+
T.nilable(
|
|
160
|
+
T.any(
|
|
161
|
+
String,
|
|
162
|
+
OpenAI::Responses::ResponseConversationParam::OrHash
|
|
163
|
+
)
|
|
164
|
+
),
|
|
165
|
+
input:
|
|
166
|
+
T.nilable(
|
|
167
|
+
OpenAI::Responses::InputTokenCountParams::Input::Variants
|
|
168
|
+
),
|
|
169
|
+
instructions: T.nilable(String),
|
|
170
|
+
model: T.nilable(String),
|
|
171
|
+
parallel_tool_calls: T.nilable(T::Boolean),
|
|
172
|
+
previous_response_id: T.nilable(String),
|
|
173
|
+
reasoning: T.nilable(OpenAI::Reasoning::OrHash),
|
|
174
|
+
text:
|
|
175
|
+
T.nilable(OpenAI::Responses::InputTokenCountParams::Text::OrHash),
|
|
176
|
+
tool_choice:
|
|
177
|
+
T.nilable(
|
|
178
|
+
T.any(
|
|
179
|
+
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
|
180
|
+
OpenAI::Responses::ToolChoiceAllowed::OrHash,
|
|
181
|
+
OpenAI::Responses::ToolChoiceTypes::OrHash,
|
|
182
|
+
OpenAI::Responses::ToolChoiceFunction::OrHash,
|
|
183
|
+
OpenAI::Responses::ToolChoiceMcp::OrHash,
|
|
184
|
+
OpenAI::Responses::ToolChoiceCustom::OrHash
|
|
185
|
+
)
|
|
186
|
+
),
|
|
187
|
+
tools:
|
|
188
|
+
T.nilable(
|
|
189
|
+
T::Array[
|
|
190
|
+
T.any(
|
|
191
|
+
OpenAI::Responses::FunctionTool::OrHash,
|
|
192
|
+
OpenAI::Responses::FileSearchTool::OrHash,
|
|
193
|
+
OpenAI::Responses::ComputerTool::OrHash,
|
|
194
|
+
OpenAI::Responses::Tool::Mcp::OrHash,
|
|
195
|
+
OpenAI::Responses::Tool::CodeInterpreter::OrHash,
|
|
196
|
+
OpenAI::Responses::Tool::ImageGeneration::OrHash,
|
|
197
|
+
OpenAI::Responses::Tool::LocalShell::OrHash,
|
|
198
|
+
OpenAI::Responses::CustomTool::OrHash,
|
|
199
|
+
OpenAI::Responses::WebSearchTool::OrHash,
|
|
200
|
+
OpenAI::Responses::WebSearchPreviewTool::OrHash
|
|
201
|
+
)
|
|
202
|
+
]
|
|
203
|
+
),
|
|
204
|
+
truncation:
|
|
205
|
+
OpenAI::Responses::InputTokenCountParams::Truncation::OrSymbol,
|
|
206
|
+
request_options: OpenAI::RequestOptions::OrHash
|
|
207
|
+
).returns(T.attached_class)
|
|
208
|
+
end
|
|
209
|
+
def self.new(
|
|
210
|
+
# The conversation that this response belongs to. Items from this conversation are
|
|
211
|
+
# prepended to `input_items` for this response request. Input items and output
|
|
212
|
+
# items from this response are automatically added to this conversation after this
|
|
213
|
+
# response completes.
|
|
214
|
+
conversation: nil,
|
|
215
|
+
# Text, image, or file inputs to the model, used to generate a response
|
|
216
|
+
input: nil,
|
|
217
|
+
# A system (or developer) message inserted into the model's context. When used
|
|
218
|
+
# along with `previous_response_id`, the instructions from a previous response
|
|
219
|
+
# will not be carried over to the next response. This makes it simple to swap out
|
|
220
|
+
# system (or developer) messages in new responses.
|
|
221
|
+
instructions: nil,
|
|
222
|
+
# Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
|
223
|
+
# wide range of models with different capabilities, performance characteristics,
|
|
224
|
+
# and price points. Refer to the
|
|
225
|
+
# [model guide](https://platform.openai.com/docs/models) to browse and compare
|
|
226
|
+
# available models.
|
|
227
|
+
model: nil,
|
|
228
|
+
# Whether to allow the model to run tool calls in parallel.
|
|
229
|
+
parallel_tool_calls: nil,
|
|
230
|
+
# The unique ID of the previous response to the model. Use this to create
|
|
231
|
+
# multi-turn conversations. Learn more about
|
|
232
|
+
# [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
|
233
|
+
# Cannot be used in conjunction with `conversation`.
|
|
234
|
+
previous_response_id: nil,
|
|
235
|
+
# **gpt-5 and o-series models only** Configuration options for
|
|
236
|
+
# [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
|
237
|
+
reasoning: nil,
|
|
238
|
+
# Configuration options for a text response from the model. Can be plain text or
|
|
239
|
+
# structured JSON data. Learn more:
|
|
240
|
+
#
|
|
241
|
+
# - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
|
242
|
+
# - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
|
243
|
+
text: nil,
|
|
244
|
+
# How the model should select which tool (or tools) to use when generating a
|
|
245
|
+
# response. See the `tools` parameter to see how to specify which tools the model
|
|
246
|
+
# can call.
|
|
247
|
+
tool_choice: nil,
|
|
248
|
+
# An array of tools the model may call while generating a response. You can
|
|
249
|
+
# specify which tool to use by setting the `tool_choice` parameter.
|
|
250
|
+
tools: nil,
|
|
251
|
+
# The truncation strategy to use for the model response. - `auto`: If the input to
|
|
252
|
+
# this Response exceeds the model's context window size, the model will truncate
|
|
253
|
+
# the response to fit the context window by dropping items from the beginning of
|
|
254
|
+
# the conversation. - `disabled` (default): If the input size will exceed the
|
|
255
|
+
# context window size for a model, the request will fail with a 400 error.
|
|
256
|
+
truncation: nil,
|
|
257
|
+
request_options: {}
|
|
258
|
+
)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
sig do
|
|
262
|
+
override.returns(
|
|
263
|
+
{
|
|
264
|
+
conversation:
|
|
265
|
+
T.nilable(
|
|
266
|
+
T.any(String, OpenAI::Responses::ResponseConversationParam)
|
|
267
|
+
),
|
|
268
|
+
input:
|
|
269
|
+
T.nilable(
|
|
270
|
+
OpenAI::Responses::InputTokenCountParams::Input::Variants
|
|
271
|
+
),
|
|
272
|
+
instructions: T.nilable(String),
|
|
273
|
+
model: T.nilable(String),
|
|
274
|
+
parallel_tool_calls: T.nilable(T::Boolean),
|
|
275
|
+
previous_response_id: T.nilable(String),
|
|
276
|
+
reasoning: T.nilable(OpenAI::Reasoning),
|
|
277
|
+
text: T.nilable(OpenAI::Responses::InputTokenCountParams::Text),
|
|
278
|
+
tool_choice:
|
|
279
|
+
T.nilable(
|
|
280
|
+
T.any(
|
|
281
|
+
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
|
282
|
+
OpenAI::Responses::ToolChoiceAllowed,
|
|
283
|
+
OpenAI::Responses::ToolChoiceTypes,
|
|
284
|
+
OpenAI::Responses::ToolChoiceFunction,
|
|
285
|
+
OpenAI::Responses::ToolChoiceMcp,
|
|
286
|
+
OpenAI::Responses::ToolChoiceCustom
|
|
287
|
+
)
|
|
288
|
+
),
|
|
289
|
+
tools:
|
|
290
|
+
T.nilable(
|
|
291
|
+
T::Array[
|
|
292
|
+
T.any(
|
|
293
|
+
OpenAI::Responses::FunctionTool,
|
|
294
|
+
OpenAI::Responses::FileSearchTool,
|
|
295
|
+
OpenAI::Responses::ComputerTool,
|
|
296
|
+
OpenAI::Responses::Tool::Mcp,
|
|
297
|
+
OpenAI::Responses::Tool::CodeInterpreter,
|
|
298
|
+
OpenAI::Responses::Tool::ImageGeneration,
|
|
299
|
+
OpenAI::Responses::Tool::LocalShell,
|
|
300
|
+
OpenAI::Responses::CustomTool,
|
|
301
|
+
OpenAI::Responses::WebSearchTool,
|
|
302
|
+
OpenAI::Responses::WebSearchPreviewTool
|
|
303
|
+
)
|
|
304
|
+
]
|
|
305
|
+
),
|
|
306
|
+
truncation:
|
|
307
|
+
OpenAI::Responses::InputTokenCountParams::Truncation::OrSymbol,
|
|
308
|
+
request_options: OpenAI::RequestOptions
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
end
|
|
312
|
+
def to_hash
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# The conversation that this response belongs to. Items from this conversation are
|
|
316
|
+
# prepended to `input_items` for this response request. Input items and output
|
|
317
|
+
# items from this response are automatically added to this conversation after this
|
|
318
|
+
# response completes.
|
|
319
|
+
module Conversation
|
|
320
|
+
extend OpenAI::Internal::Type::Union
|
|
321
|
+
|
|
322
|
+
Variants =
|
|
323
|
+
T.type_alias do
|
|
324
|
+
T.any(String, OpenAI::Responses::ResponseConversationParam)
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
sig do
|
|
328
|
+
override.returns(
|
|
329
|
+
T::Array[
|
|
330
|
+
OpenAI::Responses::InputTokenCountParams::Conversation::Variants
|
|
331
|
+
]
|
|
332
|
+
)
|
|
333
|
+
end
|
|
334
|
+
def self.variants
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# Text, image, or file inputs to the model, used to generate a response
|
|
339
|
+
module Input
|
|
340
|
+
extend OpenAI::Internal::Type::Union
|
|
341
|
+
|
|
342
|
+
Variants =
|
|
343
|
+
T.type_alias do
|
|
344
|
+
T.any(
|
|
345
|
+
String,
|
|
346
|
+
T::Array[OpenAI::Responses::ResponseInputItem::Variants]
|
|
347
|
+
)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
sig do
|
|
351
|
+
override.returns(
|
|
352
|
+
T::Array[
|
|
353
|
+
OpenAI::Responses::InputTokenCountParams::Input::Variants
|
|
354
|
+
]
|
|
355
|
+
)
|
|
356
|
+
end
|
|
357
|
+
def self.variants
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
ResponseInputItemArray =
|
|
361
|
+
T.let(
|
|
362
|
+
OpenAI::Internal::Type::ArrayOf[
|
|
363
|
+
union: OpenAI::Responses::ResponseInputItem
|
|
364
|
+
],
|
|
365
|
+
OpenAI::Internal::Type::Converter
|
|
366
|
+
)
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
class Text < OpenAI::Internal::Type::BaseModel
|
|
370
|
+
OrHash =
|
|
371
|
+
T.type_alias do
|
|
372
|
+
T.any(
|
|
373
|
+
OpenAI::Responses::InputTokenCountParams::Text,
|
|
374
|
+
OpenAI::Internal::AnyHash
|
|
375
|
+
)
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# An object specifying the format that the model must output.
|
|
379
|
+
#
|
|
380
|
+
# Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
|
|
381
|
+
# ensures the model will match your supplied JSON schema. Learn more in the
|
|
382
|
+
# [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
|
|
383
|
+
#
|
|
384
|
+
# The default format is `{ "type": "text" }` with no additional options.
|
|
385
|
+
#
|
|
386
|
+
# **Not recommended for gpt-4o and newer models:**
|
|
387
|
+
#
|
|
388
|
+
# Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
389
|
+
# ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
390
|
+
# preferred for models that support it.
|
|
391
|
+
sig do
|
|
392
|
+
returns(
|
|
393
|
+
T.nilable(
|
|
394
|
+
T.any(
|
|
395
|
+
OpenAI::ResponseFormatText,
|
|
396
|
+
OpenAI::Responses::ResponseFormatTextJSONSchemaConfig,
|
|
397
|
+
OpenAI::ResponseFormatJSONObject
|
|
398
|
+
)
|
|
399
|
+
)
|
|
400
|
+
)
|
|
401
|
+
end
|
|
402
|
+
attr_reader :format_
|
|
403
|
+
|
|
404
|
+
sig do
|
|
405
|
+
params(
|
|
406
|
+
format_:
|
|
407
|
+
T.any(
|
|
408
|
+
OpenAI::ResponseFormatText::OrHash,
|
|
409
|
+
OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash,
|
|
410
|
+
OpenAI::ResponseFormatJSONObject::OrHash
|
|
411
|
+
)
|
|
412
|
+
).void
|
|
413
|
+
end
|
|
414
|
+
attr_writer :format_
|
|
415
|
+
|
|
416
|
+
# Constrains the verbosity of the model's response. Lower values will result in
|
|
417
|
+
# more concise responses, while higher values will result in more verbose
|
|
418
|
+
# responses. Currently supported values are `low`, `medium`, and `high`.
|
|
419
|
+
sig do
|
|
420
|
+
returns(
|
|
421
|
+
T.nilable(
|
|
422
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity::OrSymbol
|
|
423
|
+
)
|
|
424
|
+
)
|
|
425
|
+
end
|
|
426
|
+
attr_accessor :verbosity
|
|
427
|
+
|
|
428
|
+
# Configuration options for a text response from the model. Can be plain text or
|
|
429
|
+
# structured JSON data. Learn more:
|
|
430
|
+
#
|
|
431
|
+
# - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
|
432
|
+
# - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
|
|
433
|
+
sig do
|
|
434
|
+
params(
|
|
435
|
+
format_:
|
|
436
|
+
T.any(
|
|
437
|
+
OpenAI::ResponseFormatText::OrHash,
|
|
438
|
+
OpenAI::Responses::ResponseFormatTextJSONSchemaConfig::OrHash,
|
|
439
|
+
OpenAI::ResponseFormatJSONObject::OrHash
|
|
440
|
+
),
|
|
441
|
+
verbosity:
|
|
442
|
+
T.nilable(
|
|
443
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity::OrSymbol
|
|
444
|
+
)
|
|
445
|
+
).returns(T.attached_class)
|
|
446
|
+
end
|
|
447
|
+
def self.new(
|
|
448
|
+
# An object specifying the format that the model must output.
|
|
449
|
+
#
|
|
450
|
+
# Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
|
|
451
|
+
# ensures the model will match your supplied JSON schema. Learn more in the
|
|
452
|
+
# [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
|
|
453
|
+
#
|
|
454
|
+
# The default format is `{ "type": "text" }` with no additional options.
|
|
455
|
+
#
|
|
456
|
+
# **Not recommended for gpt-4o and newer models:**
|
|
457
|
+
#
|
|
458
|
+
# Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
459
|
+
# ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
460
|
+
# preferred for models that support it.
|
|
461
|
+
format_: nil,
|
|
462
|
+
# Constrains the verbosity of the model's response. Lower values will result in
|
|
463
|
+
# more concise responses, while higher values will result in more verbose
|
|
464
|
+
# responses. Currently supported values are `low`, `medium`, and `high`.
|
|
465
|
+
verbosity: nil
|
|
466
|
+
)
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
sig do
|
|
470
|
+
override.returns(
|
|
471
|
+
{
|
|
472
|
+
format_:
|
|
473
|
+
T.any(
|
|
474
|
+
OpenAI::ResponseFormatText,
|
|
475
|
+
OpenAI::Responses::ResponseFormatTextJSONSchemaConfig,
|
|
476
|
+
OpenAI::ResponseFormatJSONObject
|
|
477
|
+
),
|
|
478
|
+
verbosity:
|
|
479
|
+
T.nilable(
|
|
480
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity::OrSymbol
|
|
481
|
+
)
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
end
|
|
485
|
+
def to_hash
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
# Constrains the verbosity of the model's response. Lower values will result in
|
|
489
|
+
# more concise responses, while higher values will result in more verbose
|
|
490
|
+
# responses. Currently supported values are `low`, `medium`, and `high`.
|
|
491
|
+
module Verbosity
|
|
492
|
+
extend OpenAI::Internal::Type::Enum
|
|
493
|
+
|
|
494
|
+
TaggedSymbol =
|
|
495
|
+
T.type_alias do
|
|
496
|
+
T.all(
|
|
497
|
+
Symbol,
|
|
498
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity
|
|
499
|
+
)
|
|
500
|
+
end
|
|
501
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
502
|
+
|
|
503
|
+
LOW =
|
|
504
|
+
T.let(
|
|
505
|
+
:low,
|
|
506
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity::TaggedSymbol
|
|
507
|
+
)
|
|
508
|
+
MEDIUM =
|
|
509
|
+
T.let(
|
|
510
|
+
:medium,
|
|
511
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity::TaggedSymbol
|
|
512
|
+
)
|
|
513
|
+
HIGH =
|
|
514
|
+
T.let(
|
|
515
|
+
:high,
|
|
516
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity::TaggedSymbol
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
sig do
|
|
520
|
+
override.returns(
|
|
521
|
+
T::Array[
|
|
522
|
+
OpenAI::Responses::InputTokenCountParams::Text::Verbosity::TaggedSymbol
|
|
523
|
+
]
|
|
524
|
+
)
|
|
525
|
+
end
|
|
526
|
+
def self.values
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
end
|
|
530
|
+
|
|
531
|
+
# How the model should select which tool (or tools) to use when generating a
|
|
532
|
+
# response. See the `tools` parameter to see how to specify which tools the model
|
|
533
|
+
# can call.
|
|
534
|
+
module ToolChoice
|
|
535
|
+
extend OpenAI::Internal::Type::Union
|
|
536
|
+
|
|
537
|
+
Variants =
|
|
538
|
+
T.type_alias do
|
|
539
|
+
T.any(
|
|
540
|
+
OpenAI::Responses::ToolChoiceOptions::TaggedSymbol,
|
|
541
|
+
OpenAI::Responses::ToolChoiceAllowed,
|
|
542
|
+
OpenAI::Responses::ToolChoiceTypes,
|
|
543
|
+
OpenAI::Responses::ToolChoiceFunction,
|
|
544
|
+
OpenAI::Responses::ToolChoiceMcp,
|
|
545
|
+
OpenAI::Responses::ToolChoiceCustom
|
|
546
|
+
)
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
sig do
|
|
550
|
+
override.returns(
|
|
551
|
+
T::Array[
|
|
552
|
+
OpenAI::Responses::InputTokenCountParams::ToolChoice::Variants
|
|
553
|
+
]
|
|
554
|
+
)
|
|
555
|
+
end
|
|
556
|
+
def self.variants
|
|
557
|
+
end
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
# The truncation strategy to use for the model response. - `auto`: If the input to
|
|
561
|
+
# this Response exceeds the model's context window size, the model will truncate
|
|
562
|
+
# the response to fit the context window by dropping items from the beginning of
|
|
563
|
+
# the conversation. - `disabled` (default): If the input size will exceed the
|
|
564
|
+
# context window size for a model, the request will fail with a 400 error.
|
|
565
|
+
module Truncation
|
|
566
|
+
extend OpenAI::Internal::Type::Enum
|
|
567
|
+
|
|
568
|
+
TaggedSymbol =
|
|
569
|
+
T.type_alias do
|
|
570
|
+
T.all(
|
|
571
|
+
Symbol,
|
|
572
|
+
OpenAI::Responses::InputTokenCountParams::Truncation
|
|
573
|
+
)
|
|
574
|
+
end
|
|
575
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
576
|
+
|
|
577
|
+
AUTO =
|
|
578
|
+
T.let(
|
|
579
|
+
:auto,
|
|
580
|
+
OpenAI::Responses::InputTokenCountParams::Truncation::TaggedSymbol
|
|
581
|
+
)
|
|
582
|
+
DISABLED =
|
|
583
|
+
T.let(
|
|
584
|
+
:disabled,
|
|
585
|
+
OpenAI::Responses::InputTokenCountParams::Truncation::TaggedSymbol
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
sig do
|
|
589
|
+
override.returns(
|
|
590
|
+
T::Array[
|
|
591
|
+
OpenAI::Responses::InputTokenCountParams::Truncation::TaggedSymbol
|
|
592
|
+
]
|
|
593
|
+
)
|
|
594
|
+
end
|
|
595
|
+
def self.values
|
|
596
|
+
end
|
|
597
|
+
end
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
end
|
|
601
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OpenAI
|
|
4
|
+
module Models
|
|
5
|
+
module Responses
|
|
6
|
+
class InputTokenCountResponse < OpenAI::Internal::Type::BaseModel
|
|
7
|
+
OrHash =
|
|
8
|
+
T.type_alias do
|
|
9
|
+
T.any(
|
|
10
|
+
OpenAI::Models::Responses::InputTokenCountResponse,
|
|
11
|
+
OpenAI::Internal::AnyHash
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
sig { returns(Integer) }
|
|
16
|
+
attr_accessor :input_tokens
|
|
17
|
+
|
|
18
|
+
sig { returns(Symbol) }
|
|
19
|
+
attr_accessor :object
|
|
20
|
+
|
|
21
|
+
sig do
|
|
22
|
+
params(input_tokens: Integer, object: Symbol).returns(
|
|
23
|
+
T.attached_class
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
def self.new(input_tokens:, object: :"response.input_tokens")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
sig { override.returns({ input_tokens: Integer, object: Symbol }) }
|
|
30
|
+
def to_hash
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -140,7 +140,7 @@ module OpenAI
|
|
|
140
140
|
sig { returns(String) }
|
|
141
141
|
attr_accessor :logs
|
|
142
142
|
|
|
143
|
-
# The type of the output. Always
|
|
143
|
+
# The type of the output. Always `logs`.
|
|
144
144
|
sig { returns(Symbol) }
|
|
145
145
|
attr_accessor :type
|
|
146
146
|
|
|
@@ -149,7 +149,7 @@ module OpenAI
|
|
|
149
149
|
def self.new(
|
|
150
150
|
# The logs output from the code interpreter.
|
|
151
151
|
logs:,
|
|
152
|
-
# The type of the output. Always
|
|
152
|
+
# The type of the output. Always `logs`.
|
|
153
153
|
type: :logs
|
|
154
154
|
)
|
|
155
155
|
end
|
|
@@ -168,7 +168,7 @@ module OpenAI
|
|
|
168
168
|
)
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
# The type of the output. Always
|
|
171
|
+
# The type of the output. Always `image`.
|
|
172
172
|
sig { returns(Symbol) }
|
|
173
173
|
attr_accessor :type
|
|
174
174
|
|
|
@@ -181,7 +181,7 @@ module OpenAI
|
|
|
181
181
|
def self.new(
|
|
182
182
|
# The URL of the image output from the code interpreter.
|
|
183
183
|
url:,
|
|
184
|
-
# The type of the output. Always
|
|
184
|
+
# The type of the output. Always `image`.
|
|
185
185
|
type: :image
|
|
186
186
|
)
|
|
187
187
|
end
|