openai 0.17.1 → 0.19.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 +50 -0
- data/README.md +1 -1
- data/lib/openai/client.rb +4 -0
- data/lib/openai/helpers/structured_output/array_of.rb +2 -10
- data/lib/openai/helpers/structured_output/base_model.rb +4 -11
- data/lib/openai/helpers/structured_output/boolean.rb +1 -0
- data/lib/openai/helpers/structured_output/json_schema_converter.rb +19 -3
- data/lib/openai/helpers/structured_output/union_of.rb +2 -10
- data/lib/openai/internal/conversation_cursor_page.rb +92 -0
- data/lib/openai/internal/transport/base_client.rb +1 -4
- data/lib/openai/internal/transport/pooled_net_requester.rb +1 -9
- data/lib/openai/internal/util.rb +1 -1
- data/lib/openai/models/audio/transcription.rb +1 -4
- data/lib/openai/models/audio/transcription_create_params.rb +2 -7
- data/lib/openai/models/audio/transcription_text_done_event.rb +1 -4
- data/lib/openai/models/batch_create_params.rb +38 -1
- data/lib/openai/models/beta/assistant_create_params.rb +6 -19
- data/lib/openai/models/beta/assistant_stream_event.rb +6 -24
- data/lib/openai/models/beta/assistant_update_params.rb +1 -4
- data/lib/openai/models/beta/message_stream_event.rb +1 -4
- data/lib/openai/models/beta/run_step_stream_event.rb +1 -4
- data/lib/openai/models/beta/thread_create_and_run_params.rb +12 -34
- data/lib/openai/models/beta/thread_create_params.rb +7 -22
- data/lib/openai/models/beta/threads/message.rb +3 -10
- data/lib/openai/models/beta/threads/message_create_params.rb +2 -7
- data/lib/openai/models/beta/threads/run.rb +4 -9
- data/lib/openai/models/beta/threads/run_create_params.rb +5 -12
- data/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb +1 -3
- data/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb +5 -17
- data/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb +1 -3
- data/lib/openai/models/beta/threads/runs/file_search_tool_call.rb +4 -12
- data/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rb +1 -4
- data/lib/openai/models/beta/threads/runs/tool_calls_step_details.rb +1 -4
- data/lib/openai/models/beta/threads/text.rb +1 -4
- data/lib/openai/models/chat/chat_completion.rb +6 -6
- data/lib/openai/models/chat/chat_completion_chunk.rb +7 -9
- data/lib/openai/models/chat/chat_completion_custom_tool.rb +2 -7
- data/lib/openai/models/chat/completion_create_params.rb +7 -7
- data/lib/openai/models/conversations/computer_screenshot_content.rb +38 -0
- data/lib/openai/models/conversations/container_file_citation_body.rb +58 -0
- data/lib/openai/models/conversations/conversation.rb +51 -0
- data/lib/openai/models/conversations/conversation_create_params.rb +39 -0
- data/lib/openai/models/conversations/conversation_delete_params.rb +16 -0
- data/lib/openai/models/conversations/conversation_deleted.rb +29 -0
- data/lib/openai/models/conversations/conversation_deleted_resource.rb +30 -0
- data/lib/openai/models/conversations/conversation_item.rb +568 -0
- data/lib/openai/models/conversations/conversation_item_list.rb +55 -0
- data/lib/openai/models/conversations/conversation_retrieve_params.rb +16 -0
- data/lib/openai/models/conversations/conversation_update_params.rb +31 -0
- data/lib/openai/models/conversations/file_citation_body.rb +42 -0
- data/lib/openai/models/conversations/input_file_content.rb +42 -0
- data/lib/openai/models/conversations/input_image_content.rb +62 -0
- data/lib/openai/models/conversations/input_text_content.rb +26 -0
- data/lib/openai/models/conversations/item_create_params.rb +37 -0
- data/lib/openai/models/conversations/item_delete_params.rb +22 -0
- data/lib/openai/models/conversations/item_list_params.rb +84 -0
- data/lib/openai/models/conversations/item_retrieve_params.rb +36 -0
- data/lib/openai/models/conversations/lob_prob.rb +35 -0
- data/lib/openai/models/conversations/message.rb +115 -0
- data/lib/openai/models/conversations/output_text_content.rb +57 -0
- data/lib/openai/models/conversations/refusal_content.rb +26 -0
- data/lib/openai/models/conversations/summary_text_content.rb +23 -0
- data/lib/openai/models/conversations/text_content.rb +23 -0
- data/lib/openai/models/conversations/top_log_prob.rb +29 -0
- data/lib/openai/models/conversations/url_citation_body.rb +50 -0
- data/lib/openai/models/eval_create_params.rb +6 -20
- data/lib/openai/models/evals/create_eval_completions_run_data_source.rb +29 -53
- data/lib/openai/models/evals/create_eval_jsonl_run_data_source.rb +1 -3
- data/lib/openai/models/evals/run_create_params.rb +18 -54
- data/lib/openai/models/file_create_params.rb +37 -1
- data/lib/openai/models/fine_tuning/reinforcement_hyperparameters.rb +1 -4
- data/lib/openai/models/graders/text_similarity_grader.rb +6 -5
- data/lib/openai/models/moderation.rb +5 -15
- data/lib/openai/models/reasoning.rb +1 -1
- data/lib/openai/models/responses/input_item_list_params.rb +1 -9
- data/lib/openai/models/responses/response.rb +32 -9
- data/lib/openai/models/responses/response_computer_tool_call.rb +2 -6
- data/lib/openai/models/responses/response_computer_tool_call_output_item.rb +1 -3
- data/lib/openai/models/responses/response_conversation_param.rb +20 -0
- data/lib/openai/models/responses/response_create_params.rb +40 -9
- data/lib/openai/models/responses/response_input_item.rb +2 -7
- data/lib/openai/models/responses/response_input_message_item.rb +1 -4
- data/lib/openai/models/responses/response_output_item.rb +1 -3
- data/lib/openai/models/responses/response_output_message.rb +1 -3
- data/lib/openai/models/responses/response_output_text.rb +3 -10
- data/lib/openai/models/responses/response_stream_event.rb +4 -16
- data/lib/openai/models/responses/response_text_delta_event.rb +1 -3
- data/lib/openai/models/responses/response_text_done_event.rb +1 -3
- data/lib/openai/models/responses/tool.rb +145 -34
- data/lib/openai/models/upload_create_params.rb +37 -1
- data/lib/openai/models.rb +2 -0
- data/lib/openai/resources/batches.rb +3 -1
- data/lib/openai/resources/conversations/items.rb +141 -0
- data/lib/openai/resources/conversations.rb +112 -0
- data/lib/openai/resources/files.rb +4 -2
- data/lib/openai/resources/responses/input_items.rb +1 -3
- data/lib/openai/resources/responses.rb +8 -4
- data/lib/openai/resources/uploads.rb +3 -1
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +31 -0
- data/rbi/openai/client.rbi +3 -0
- data/rbi/openai/errors.rbi +5 -5
- data/rbi/openai/helpers/structured_output/array_of.rbi +0 -3
- data/rbi/openai/helpers/structured_output/json_schema_converter.rbi +10 -0
- data/rbi/openai/internal/conversation_cursor_page.rbi +25 -0
- data/rbi/openai/models/batch_create_params.rbi +60 -0
- data/rbi/openai/models/beta/thread_create_and_run_params.rbi +3 -3
- data/rbi/openai/models/beta/threads/run.rbi +3 -3
- data/rbi/openai/models/beta/threads/run_create_params.rbi +3 -3
- data/rbi/openai/models/chat/chat_completion.rbi +6 -9
- data/rbi/openai/models/chat/chat_completion_chunk.rbi +6 -9
- data/rbi/openai/models/chat/completion_create_params.rbi +8 -11
- data/rbi/openai/models/conversations/computer_screenshot_content.rbi +60 -0
- data/rbi/openai/models/conversations/container_file_citation_body.rbi +82 -0
- data/rbi/openai/models/conversations/conversation.rbi +76 -0
- data/rbi/openai/models/conversations/conversation_create_params.rbi +144 -0
- data/rbi/openai/models/conversations/conversation_delete_params.rbi +32 -0
- data/rbi/openai/models/conversations/conversation_deleted.rbi +40 -0
- data/rbi/openai/models/conversations/conversation_deleted_resource.rbi +40 -0
- data/rbi/openai/models/conversations/conversation_item.rbi +835 -0
- data/rbi/openai/models/conversations/conversation_item_list.rbi +101 -0
- data/rbi/openai/models/conversations/conversation_retrieve_params.rbi +32 -0
- data/rbi/openai/models/conversations/conversation_update_params.rbi +56 -0
- data/rbi/openai/models/conversations/file_citation_body.rbi +61 -0
- data/rbi/openai/models/conversations/input_file_content.rbi +72 -0
- data/rbi/openai/models/conversations/input_image_content.rbi +113 -0
- data/rbi/openai/models/conversations/input_text_content.rbi +38 -0
- data/rbi/openai/models/conversations/item_create_params.rbi +150 -0
- data/rbi/openai/models/conversations/item_delete_params.rbi +40 -0
- data/rbi/openai/models/conversations/item_list_params.rbi +174 -0
- data/rbi/openai/models/conversations/item_retrieve_params.rbi +70 -0
- data/rbi/openai/models/conversations/lob_prob.rbi +50 -0
- data/rbi/openai/models/conversations/message.rbi +196 -0
- data/rbi/openai/models/conversations/output_text_content.rbi +110 -0
- data/rbi/openai/models/conversations/refusal_content.rbi +38 -0
- data/rbi/openai/models/conversations/summary_text_content.rbi +31 -0
- data/rbi/openai/models/conversations/text_content.rbi +28 -0
- data/rbi/openai/models/conversations/top_log_prob.rbi +41 -0
- data/rbi/openai/models/conversations/url_citation_body.rbi +74 -0
- data/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi +33 -33
- data/rbi/openai/models/file_create_params.rbi +56 -0
- data/rbi/openai/models/graders/text_similarity_grader.rbi +11 -6
- data/rbi/openai/models/reasoning.rbi +1 -1
- data/rbi/openai/models/responses/input_item_list_params.rbi +0 -11
- data/rbi/openai/models/responses/response.rbi +57 -11
- data/rbi/openai/models/responses/response_conversation_param.rbi +33 -0
- data/rbi/openai/models/responses/response_create_params.rbi +62 -11
- data/rbi/openai/models/responses/tool.rbi +243 -31
- data/rbi/openai/models/upload_create_params.rbi +56 -0
- data/rbi/openai/models.rbi +2 -0
- data/rbi/openai/resources/batches.rbi +5 -0
- data/rbi/openai/resources/beta/threads/runs.rbi +2 -2
- data/rbi/openai/resources/beta/threads.rbi +2 -2
- data/rbi/openai/resources/chat/completions.rbi +6 -8
- data/rbi/openai/resources/conversations/items.rbi +152 -0
- data/rbi/openai/resources/conversations.rbi +110 -0
- data/rbi/openai/resources/files.rbi +5 -1
- data/rbi/openai/resources/responses/input_items.rbi +0 -3
- data/rbi/openai/resources/responses.rbi +32 -8
- data/rbi/openai/resources/uploads.rbi +4 -0
- data/sig/openai/client.rbs +2 -0
- data/sig/openai/internal/conversation_cursor_page.rbs +15 -0
- data/sig/openai/models/batch_create_params.rbs +22 -1
- data/sig/openai/models/conversations/computer_screenshot_content.rbs +28 -0
- data/sig/openai/models/conversations/container_file_citation_body.rbs +47 -0
- data/sig/openai/models/conversations/conversation.rbs +37 -0
- data/sig/openai/models/conversations/conversation_create_params.rbs +33 -0
- data/sig/openai/models/conversations/conversation_delete_params.rbs +17 -0
- data/sig/openai/models/conversations/conversation_deleted.rbs +28 -0
- data/sig/openai/models/conversations/conversation_deleted_resource.rbs +28 -0
- data/sig/openai/models/conversations/conversation_item.rbs +403 -0
- data/sig/openai/models/conversations/conversation_item_list.rbs +44 -0
- data/sig/openai/models/conversations/conversation_retrieve_params.rbs +17 -0
- data/sig/openai/models/conversations/conversation_update_params.rbs +26 -0
- data/sig/openai/models/conversations/file_citation_body.rbs +37 -0
- data/sig/openai/models/conversations/input_file_content.rbs +41 -0
- data/sig/openai/models/conversations/input_image_content.rbs +49 -0
- data/sig/openai/models/conversations/input_text_content.rbs +17 -0
- data/sig/openai/models/conversations/item_create_params.rbs +37 -0
- data/sig/openai/models/conversations/item_delete_params.rbs +25 -0
- data/sig/openai/models/conversations/item_list_params.rbs +66 -0
- data/sig/openai/models/conversations/item_retrieve_params.rbs +37 -0
- data/sig/openai/models/conversations/lob_prob.rbs +37 -0
- data/sig/openai/models/conversations/message.rbs +95 -0
- data/sig/openai/models/conversations/output_text_content.rbs +52 -0
- data/sig/openai/models/conversations/refusal_content.rbs +17 -0
- data/sig/openai/models/conversations/summary_text_content.rbs +17 -0
- data/sig/openai/models/conversations/text_content.rbs +17 -0
- data/sig/openai/models/conversations/top_log_prob.rbs +28 -0
- data/sig/openai/models/conversations/url_citation_body.rbs +42 -0
- data/sig/openai/models/evals/create_eval_completions_run_data_source.rbs +22 -22
- data/sig/openai/models/file_create_params.rbs +22 -1
- data/sig/openai/models/graders/text_similarity_grader.rbs +3 -1
- data/sig/openai/models/responses/input_item_list_params.rbs +0 -7
- data/sig/openai/models/responses/response.rbs +15 -0
- data/sig/openai/models/responses/response_conversation_param.rbs +15 -0
- data/sig/openai/models/responses/response_create_params.rbs +14 -0
- data/sig/openai/models/responses/tool.rbs +83 -18
- data/sig/openai/models/upload_create_params.rbs +22 -1
- data/sig/openai/models.rbs +2 -0
- data/sig/openai/resources/batches.rbs +1 -0
- data/sig/openai/resources/conversations/items.rbs +38 -0
- data/sig/openai/resources/conversations.rbs +31 -0
- data/sig/openai/resources/files.rbs +1 -0
- data/sig/openai/resources/responses/input_items.rbs +0 -1
- data/sig/openai/resources/responses.rbs +2 -0
- data/sig/openai/resources/uploads.rbs +1 -0
- metadata +95 -2
@@ -33,12 +33,25 @@ module OpenAI
|
|
33
33
|
sig { returns(OpenAI::FilePurpose::OrSymbol) }
|
34
34
|
attr_accessor :purpose
|
35
35
|
|
36
|
+
# The expiration policy for a file. By default, files with `purpose=batch` expire
|
37
|
+
# after 30 days and all other files are persisted until they are manually deleted.
|
38
|
+
sig { returns(T.nilable(OpenAI::UploadCreateParams::ExpiresAfter)) }
|
39
|
+
attr_reader :expires_after
|
40
|
+
|
41
|
+
sig do
|
42
|
+
params(
|
43
|
+
expires_after: OpenAI::UploadCreateParams::ExpiresAfter::OrHash
|
44
|
+
).void
|
45
|
+
end
|
46
|
+
attr_writer :expires_after
|
47
|
+
|
36
48
|
sig do
|
37
49
|
params(
|
38
50
|
bytes: Integer,
|
39
51
|
filename: String,
|
40
52
|
mime_type: String,
|
41
53
|
purpose: OpenAI::FilePurpose::OrSymbol,
|
54
|
+
expires_after: OpenAI::UploadCreateParams::ExpiresAfter::OrHash,
|
42
55
|
request_options: OpenAI::RequestOptions::OrHash
|
43
56
|
).returns(T.attached_class)
|
44
57
|
end
|
@@ -57,6 +70,9 @@ module OpenAI
|
|
57
70
|
# See the
|
58
71
|
# [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose).
|
59
72
|
purpose:,
|
73
|
+
# The expiration policy for a file. By default, files with `purpose=batch` expire
|
74
|
+
# after 30 days and all other files are persisted until they are manually deleted.
|
75
|
+
expires_after: nil,
|
60
76
|
request_options: {}
|
61
77
|
)
|
62
78
|
end
|
@@ -68,12 +84,52 @@ module OpenAI
|
|
68
84
|
filename: String,
|
69
85
|
mime_type: String,
|
70
86
|
purpose: OpenAI::FilePurpose::OrSymbol,
|
87
|
+
expires_after: OpenAI::UploadCreateParams::ExpiresAfter,
|
71
88
|
request_options: OpenAI::RequestOptions
|
72
89
|
}
|
73
90
|
)
|
74
91
|
end
|
75
92
|
def to_hash
|
76
93
|
end
|
94
|
+
|
95
|
+
class ExpiresAfter < OpenAI::Internal::Type::BaseModel
|
96
|
+
OrHash =
|
97
|
+
T.type_alias do
|
98
|
+
T.any(
|
99
|
+
OpenAI::UploadCreateParams::ExpiresAfter,
|
100
|
+
OpenAI::Internal::AnyHash
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Anchor timestamp after which the expiration policy applies. Supported anchors:
|
105
|
+
# `created_at`.
|
106
|
+
sig { returns(Symbol) }
|
107
|
+
attr_accessor :anchor
|
108
|
+
|
109
|
+
# The number of seconds after the anchor time that the file will expire. Must be
|
110
|
+
# between 3600 (1 hour) and 2592000 (30 days).
|
111
|
+
sig { returns(Integer) }
|
112
|
+
attr_accessor :seconds
|
113
|
+
|
114
|
+
# The expiration policy for a file. By default, files with `purpose=batch` expire
|
115
|
+
# after 30 days and all other files are persisted until they are manually deleted.
|
116
|
+
sig do
|
117
|
+
params(seconds: Integer, anchor: Symbol).returns(T.attached_class)
|
118
|
+
end
|
119
|
+
def self.new(
|
120
|
+
# The number of seconds after the anchor time that the file will expire. Must be
|
121
|
+
# between 3600 (1 hour) and 2592000 (30 days).
|
122
|
+
seconds:,
|
123
|
+
# Anchor timestamp after which the expiration policy applies. Supported anchors:
|
124
|
+
# `created_at`.
|
125
|
+
anchor: :created_at
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
sig { override.returns({ anchor: Symbol, seconds: Integer }) }
|
130
|
+
def to_hash
|
131
|
+
end
|
132
|
+
end
|
77
133
|
end
|
78
134
|
end
|
79
135
|
end
|
data/rbi/openai/models.rbi
CHANGED
@@ -11,6 +11,8 @@ module OpenAI
|
|
11
11
|
endpoint: OpenAI::BatchCreateParams::Endpoint::OrSymbol,
|
12
12
|
input_file_id: String,
|
13
13
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
14
|
+
output_expires_after:
|
15
|
+
OpenAI::BatchCreateParams::OutputExpiresAfter::OrHash,
|
14
16
|
request_options: OpenAI::RequestOptions::OrHash
|
15
17
|
).returns(OpenAI::Batch)
|
16
18
|
end
|
@@ -40,6 +42,9 @@ module OpenAI
|
|
40
42
|
# Keys are strings with a maximum length of 64 characters. Values are strings with
|
41
43
|
# a maximum length of 512 characters.
|
42
44
|
metadata: nil,
|
45
|
+
# The expiration policy for the output and/or error file that are generated for a
|
46
|
+
# batch.
|
47
|
+
output_expires_after: nil,
|
43
48
|
request_options: {}
|
44
49
|
)
|
45
50
|
end
|
@@ -174,7 +174,7 @@ module OpenAI
|
|
174
174
|
# We generally recommend altering this or temperature but not both.
|
175
175
|
top_p: nil,
|
176
176
|
# Body param: Controls for how a thread will be truncated prior to the run. Use
|
177
|
-
# this to control the
|
177
|
+
# this to control the initial context window of the run.
|
178
178
|
truncation_strategy: nil,
|
179
179
|
# There is no need to provide `stream:`. Instead, use `#create_stream_raw` or
|
180
180
|
# `#create` for streaming and non-streaming use cases, respectively.
|
@@ -353,7 +353,7 @@ module OpenAI
|
|
353
353
|
# We generally recommend altering this or temperature but not both.
|
354
354
|
top_p: nil,
|
355
355
|
# Body param: Controls for how a thread will be truncated prior to the run. Use
|
356
|
-
# this to control the
|
356
|
+
# this to control the initial context window of the run.
|
357
357
|
truncation_strategy: nil,
|
358
358
|
# There is no need to provide `stream:`. Instead, use `#create_stream_raw` or
|
359
359
|
# `#create` for streaming and non-streaming use cases, respectively.
|
@@ -242,7 +242,7 @@ module OpenAI
|
|
242
242
|
# We generally recommend altering this or temperature but not both.
|
243
243
|
top_p: nil,
|
244
244
|
# Controls for how a thread will be truncated prior to the run. Use this to
|
245
|
-
# control the
|
245
|
+
# control the initial context window of the run.
|
246
246
|
truncation_strategy: nil,
|
247
247
|
# There is no need to provide `stream:`. Instead, use `#stream_raw` or
|
248
248
|
# `#create_and_run` for streaming and non-streaming use cases, respectively.
|
@@ -396,7 +396,7 @@ module OpenAI
|
|
396
396
|
# We generally recommend altering this or temperature but not both.
|
397
397
|
top_p: nil,
|
398
398
|
# Controls for how a thread will be truncated prior to the run. Use this to
|
399
|
-
# control the
|
399
|
+
# control the initial context window of the run.
|
400
400
|
truncation_strategy: nil,
|
401
401
|
# There is no need to provide `stream:`. Instead, use `#stream_raw` or
|
402
402
|
# `#create_and_run` for streaming and non-streaming use cases, respectively.
|
@@ -254,9 +254,8 @@ module OpenAI
|
|
254
254
|
# - If set to 'default', then the request will be processed with the standard
|
255
255
|
# pricing and performance for the selected model.
|
256
256
|
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
257
|
-
# 'priority', then the request
|
258
|
-
#
|
259
|
-
# Priority processing.
|
257
|
+
# '[priority](https://openai.com/api-priority-processing/)', then the request
|
258
|
+
# will be processed with the corresponding service tier.
|
260
259
|
# - When not set, the default behavior is 'auto'.
|
261
260
|
#
|
262
261
|
# When the `service_tier` parameter is set, the response body will include the
|
@@ -273,7 +272,7 @@ module OpenAI
|
|
273
272
|
# our [model distillation](https://platform.openai.com/docs/guides/distillation)
|
274
273
|
# or [evals](https://platform.openai.com/docs/guides/evals) products.
|
275
274
|
#
|
276
|
-
# Supports text and image inputs. Note: image inputs over
|
275
|
+
# Supports text and image inputs. Note: image inputs over 8MB will be dropped.
|
277
276
|
store: nil,
|
278
277
|
# Options for streaming response. Only set this when you set `stream: true`.
|
279
278
|
stream_options: nil,
|
@@ -572,9 +571,8 @@ module OpenAI
|
|
572
571
|
# - If set to 'default', then the request will be processed with the standard
|
573
572
|
# pricing and performance for the selected model.
|
574
573
|
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
575
|
-
# 'priority', then the request
|
576
|
-
#
|
577
|
-
# Priority processing.
|
574
|
+
# '[priority](https://openai.com/api-priority-processing/)', then the request
|
575
|
+
# will be processed with the corresponding service tier.
|
578
576
|
# - When not set, the default behavior is 'auto'.
|
579
577
|
#
|
580
578
|
# When the `service_tier` parameter is set, the response body will include the
|
@@ -591,7 +589,7 @@ module OpenAI
|
|
591
589
|
# our [model distillation](https://platform.openai.com/docs/guides/distillation)
|
592
590
|
# or [evals](https://platform.openai.com/docs/guides/evals) products.
|
593
591
|
#
|
594
|
-
# Supports text and image inputs. Note: image inputs over
|
592
|
+
# Supports text and image inputs. Note: image inputs over 8MB will be dropped.
|
595
593
|
store: nil,
|
596
594
|
# Options for streaming response. Only set this when you set `stream: true`.
|
597
595
|
stream_options: nil,
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module OpenAI
|
4
|
+
module Resources
|
5
|
+
class Conversations
|
6
|
+
class Items
|
7
|
+
# Create items in a conversation with the given ID.
|
8
|
+
sig do
|
9
|
+
params(
|
10
|
+
conversation_id: String,
|
11
|
+
items:
|
12
|
+
T::Array[
|
13
|
+
T.any(
|
14
|
+
OpenAI::Responses::EasyInputMessage::OrHash,
|
15
|
+
OpenAI::Responses::ResponseInputItem::Message::OrHash,
|
16
|
+
OpenAI::Responses::ResponseOutputMessage::OrHash,
|
17
|
+
OpenAI::Responses::ResponseFileSearchToolCall::OrHash,
|
18
|
+
OpenAI::Responses::ResponseComputerToolCall::OrHash,
|
19
|
+
OpenAI::Responses::ResponseInputItem::ComputerCallOutput::OrHash,
|
20
|
+
OpenAI::Responses::ResponseFunctionWebSearch::OrHash,
|
21
|
+
OpenAI::Responses::ResponseFunctionToolCall::OrHash,
|
22
|
+
OpenAI::Responses::ResponseInputItem::FunctionCallOutput::OrHash,
|
23
|
+
OpenAI::Responses::ResponseReasoningItem::OrHash,
|
24
|
+
OpenAI::Responses::ResponseInputItem::ImageGenerationCall::OrHash,
|
25
|
+
OpenAI::Responses::ResponseCodeInterpreterToolCall::OrHash,
|
26
|
+
OpenAI::Responses::ResponseInputItem::LocalShellCall::OrHash,
|
27
|
+
OpenAI::Responses::ResponseInputItem::LocalShellCallOutput::OrHash,
|
28
|
+
OpenAI::Responses::ResponseInputItem::McpListTools::OrHash,
|
29
|
+
OpenAI::Responses::ResponseInputItem::McpApprovalRequest::OrHash,
|
30
|
+
OpenAI::Responses::ResponseInputItem::McpApprovalResponse::OrHash,
|
31
|
+
OpenAI::Responses::ResponseInputItem::McpCall::OrHash,
|
32
|
+
OpenAI::Responses::ResponseCustomToolCallOutput::OrHash,
|
33
|
+
OpenAI::Responses::ResponseCustomToolCall::OrHash,
|
34
|
+
OpenAI::Responses::ResponseInputItem::ItemReference::OrHash
|
35
|
+
)
|
36
|
+
],
|
37
|
+
include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
|
38
|
+
request_options: OpenAI::RequestOptions::OrHash
|
39
|
+
).returns(OpenAI::Conversations::ConversationItemList)
|
40
|
+
end
|
41
|
+
def create(
|
42
|
+
# Path param: The ID of the conversation to add the item to.
|
43
|
+
conversation_id,
|
44
|
+
# Body param: The items to add to the conversation. You may add up to 20 items at
|
45
|
+
# a time.
|
46
|
+
items:,
|
47
|
+
# Query param: Additional fields to include in the response. See the `include`
|
48
|
+
# parameter for
|
49
|
+
# [listing Conversation items above](https://platform.openai.com/docs/api-reference/conversations/list-items#conversations_list_items-include)
|
50
|
+
# for more information.
|
51
|
+
include: nil,
|
52
|
+
request_options: {}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Get a single item from a conversation with the given IDs.
|
57
|
+
sig do
|
58
|
+
params(
|
59
|
+
item_id: String,
|
60
|
+
conversation_id: String,
|
61
|
+
include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
|
62
|
+
request_options: OpenAI::RequestOptions::OrHash
|
63
|
+
).returns(OpenAI::Conversations::ConversationItem::Variants)
|
64
|
+
end
|
65
|
+
def retrieve(
|
66
|
+
# Path param: The ID of the item to retrieve.
|
67
|
+
item_id,
|
68
|
+
# Path param: The ID of the conversation that contains the item.
|
69
|
+
conversation_id:,
|
70
|
+
# Query param: Additional fields to include in the response. See the `include`
|
71
|
+
# parameter for
|
72
|
+
# [listing Conversation items above](https://platform.openai.com/docs/api-reference/conversations/list-items#conversations_list_items-include)
|
73
|
+
# for more information.
|
74
|
+
include: nil,
|
75
|
+
request_options: {}
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# List all items for a conversation with the given ID.
|
80
|
+
sig do
|
81
|
+
params(
|
82
|
+
conversation_id: String,
|
83
|
+
after: String,
|
84
|
+
include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
|
85
|
+
limit: Integer,
|
86
|
+
order: OpenAI::Conversations::ItemListParams::Order::OrSymbol,
|
87
|
+
request_options: OpenAI::RequestOptions::OrHash
|
88
|
+
).returns(
|
89
|
+
OpenAI::Internal::ConversationCursorPage[
|
90
|
+
OpenAI::Conversations::ConversationItem::Variants
|
91
|
+
]
|
92
|
+
)
|
93
|
+
end
|
94
|
+
def list(
|
95
|
+
# The ID of the conversation to list items for.
|
96
|
+
conversation_id,
|
97
|
+
# An item ID to list items after, used in pagination.
|
98
|
+
after: nil,
|
99
|
+
# Specify additional output data to include in the model response. Currently
|
100
|
+
# supported values are:
|
101
|
+
#
|
102
|
+
# - `code_interpreter_call.outputs`: Includes the outputs of python code execution
|
103
|
+
# in code interpreter tool call items.
|
104
|
+
# - `computer_call_output.output.image_url`: Include image urls from the computer
|
105
|
+
# call output.
|
106
|
+
# - `file_search_call.results`: Include the search results of the file search tool
|
107
|
+
# call.
|
108
|
+
# - `message.input_image.image_url`: Include image urls from the input message.
|
109
|
+
# - `message.output_text.logprobs`: Include logprobs with assistant messages.
|
110
|
+
# - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
|
111
|
+
# tokens in reasoning item outputs. This enables reasoning items to be used in
|
112
|
+
# multi-turn conversations when using the Responses API statelessly (like when
|
113
|
+
# the `store` parameter is set to `false`, or when an organization is enrolled
|
114
|
+
# in the zero data retention program).
|
115
|
+
include: nil,
|
116
|
+
# A limit on the number of objects to be returned. Limit can range between 1 and
|
117
|
+
# 100, and the default is 20.
|
118
|
+
limit: nil,
|
119
|
+
# The order to return the input items in. Default is `desc`.
|
120
|
+
#
|
121
|
+
# - `asc`: Return the input items in ascending order.
|
122
|
+
# - `desc`: Return the input items in descending order.
|
123
|
+
order: nil,
|
124
|
+
request_options: {}
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Delete an item from a conversation with the given IDs.
|
129
|
+
sig do
|
130
|
+
params(
|
131
|
+
item_id: String,
|
132
|
+
conversation_id: String,
|
133
|
+
request_options: OpenAI::RequestOptions::OrHash
|
134
|
+
).returns(OpenAI::Conversations::Conversation)
|
135
|
+
end
|
136
|
+
def delete(
|
137
|
+
# The ID of the item to delete.
|
138
|
+
item_id,
|
139
|
+
# The ID of the conversation that contains the item.
|
140
|
+
conversation_id:,
|
141
|
+
request_options: {}
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
# @api private
|
146
|
+
sig { params(client: OpenAI::Client).returns(T.attached_class) }
|
147
|
+
def self.new(client:)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module OpenAI
|
4
|
+
module Resources
|
5
|
+
class Conversations
|
6
|
+
sig { returns(OpenAI::Resources::Conversations::Items) }
|
7
|
+
attr_reader :items
|
8
|
+
|
9
|
+
# Create a conversation with the given ID.
|
10
|
+
sig do
|
11
|
+
params(
|
12
|
+
items:
|
13
|
+
T.nilable(
|
14
|
+
T::Array[
|
15
|
+
T.any(
|
16
|
+
OpenAI::Responses::EasyInputMessage::OrHash,
|
17
|
+
OpenAI::Responses::ResponseInputItem::Message::OrHash,
|
18
|
+
OpenAI::Responses::ResponseOutputMessage::OrHash,
|
19
|
+
OpenAI::Responses::ResponseFileSearchToolCall::OrHash,
|
20
|
+
OpenAI::Responses::ResponseComputerToolCall::OrHash,
|
21
|
+
OpenAI::Responses::ResponseInputItem::ComputerCallOutput::OrHash,
|
22
|
+
OpenAI::Responses::ResponseFunctionWebSearch::OrHash,
|
23
|
+
OpenAI::Responses::ResponseFunctionToolCall::OrHash,
|
24
|
+
OpenAI::Responses::ResponseInputItem::FunctionCallOutput::OrHash,
|
25
|
+
OpenAI::Responses::ResponseReasoningItem::OrHash,
|
26
|
+
OpenAI::Responses::ResponseInputItem::ImageGenerationCall::OrHash,
|
27
|
+
OpenAI::Responses::ResponseCodeInterpreterToolCall::OrHash,
|
28
|
+
OpenAI::Responses::ResponseInputItem::LocalShellCall::OrHash,
|
29
|
+
OpenAI::Responses::ResponseInputItem::LocalShellCallOutput::OrHash,
|
30
|
+
OpenAI::Responses::ResponseInputItem::McpListTools::OrHash,
|
31
|
+
OpenAI::Responses::ResponseInputItem::McpApprovalRequest::OrHash,
|
32
|
+
OpenAI::Responses::ResponseInputItem::McpApprovalResponse::OrHash,
|
33
|
+
OpenAI::Responses::ResponseInputItem::McpCall::OrHash,
|
34
|
+
OpenAI::Responses::ResponseCustomToolCallOutput::OrHash,
|
35
|
+
OpenAI::Responses::ResponseCustomToolCall::OrHash,
|
36
|
+
OpenAI::Responses::ResponseInputItem::ItemReference::OrHash
|
37
|
+
)
|
38
|
+
]
|
39
|
+
),
|
40
|
+
metadata: T.nilable(T::Hash[Symbol, String]),
|
41
|
+
request_options: OpenAI::RequestOptions::OrHash
|
42
|
+
).returns(OpenAI::Conversations::Conversation)
|
43
|
+
end
|
44
|
+
def create(
|
45
|
+
# Initial items to include in the conversation context. You may add up to 20 items
|
46
|
+
# at a time.
|
47
|
+
items: nil,
|
48
|
+
# Set of 16 key-value pairs that can be attached to an object. Useful for storing
|
49
|
+
# additional information about the object in a structured format.
|
50
|
+
metadata: nil,
|
51
|
+
request_options: {}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Get a conversation with the given ID.
|
56
|
+
sig do
|
57
|
+
params(
|
58
|
+
conversation_id: String,
|
59
|
+
request_options: OpenAI::RequestOptions::OrHash
|
60
|
+
).returns(OpenAI::Conversations::Conversation)
|
61
|
+
end
|
62
|
+
def retrieve(
|
63
|
+
# The ID of the conversation to retrieve.
|
64
|
+
conversation_id,
|
65
|
+
request_options: {}
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Update a conversation's metadata with the given ID.
|
70
|
+
sig do
|
71
|
+
params(
|
72
|
+
conversation_id: String,
|
73
|
+
metadata: T::Hash[Symbol, String],
|
74
|
+
request_options: OpenAI::RequestOptions::OrHash
|
75
|
+
).returns(OpenAI::Conversations::Conversation)
|
76
|
+
end
|
77
|
+
def update(
|
78
|
+
# The ID of the conversation to update.
|
79
|
+
conversation_id,
|
80
|
+
# Set of 16 key-value pairs that can be attached to an object. This can be useful
|
81
|
+
# for storing additional information about the object in a structured format, and
|
82
|
+
# querying for objects via API or the dashboard. Keys are strings with a maximum
|
83
|
+
# length of 64 characters. Values are strings with a maximum length of 512
|
84
|
+
# characters.
|
85
|
+
metadata:,
|
86
|
+
request_options: {}
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Delete a conversation with the given ID.
|
91
|
+
sig do
|
92
|
+
params(
|
93
|
+
conversation_id: String,
|
94
|
+
request_options: OpenAI::RequestOptions::OrHash
|
95
|
+
).returns(OpenAI::Conversations::ConversationDeletedResource)
|
96
|
+
end
|
97
|
+
def delete(
|
98
|
+
# The ID of the conversation to delete.
|
99
|
+
conversation_id,
|
100
|
+
request_options: {}
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
# @api private
|
105
|
+
sig { params(client: OpenAI::Client).returns(T.attached_class) }
|
106
|
+
def self.new(client:)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -5,7 +5,7 @@ module OpenAI
|
|
5
5
|
class Files
|
6
6
|
# Upload a file that can be used across various endpoints. Individual files can be
|
7
7
|
# up to 512 MB, and the size of all files uploaded by one organization can be up
|
8
|
-
# to
|
8
|
+
# to 1 TB.
|
9
9
|
#
|
10
10
|
# The Assistants API supports files up to 2 million tokens and of specific file
|
11
11
|
# types. See the
|
@@ -28,6 +28,7 @@ module OpenAI
|
|
28
28
|
params(
|
29
29
|
file: OpenAI::Internal::FileInput,
|
30
30
|
purpose: OpenAI::FilePurpose::OrSymbol,
|
31
|
+
expires_after: OpenAI::FileCreateParams::ExpiresAfter::OrHash,
|
31
32
|
request_options: OpenAI::RequestOptions::OrHash
|
32
33
|
).returns(OpenAI::FileObject)
|
33
34
|
end
|
@@ -39,6 +40,9 @@ module OpenAI
|
|
39
40
|
# fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
|
40
41
|
# Flexible file type for any purpose - `evals`: Used for eval data sets
|
41
42
|
purpose:,
|
43
|
+
# The expiration policy for a file. By default, files with `purpose=batch` expire
|
44
|
+
# after 30 days and all other files are persisted until they are manually deleted.
|
45
|
+
expires_after: nil,
|
42
46
|
request_options: {}
|
43
47
|
)
|
44
48
|
end
|
@@ -9,7 +9,6 @@ module OpenAI
|
|
9
9
|
params(
|
10
10
|
response_id: String,
|
11
11
|
after: String,
|
12
|
-
before: String,
|
13
12
|
include: T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol],
|
14
13
|
limit: Integer,
|
15
14
|
order: OpenAI::Responses::InputItemListParams::Order::OrSymbol,
|
@@ -25,8 +24,6 @@ module OpenAI
|
|
25
24
|
response_id,
|
26
25
|
# An item ID to list items after, used in pagination.
|
27
26
|
after: nil,
|
28
|
-
# An item ID to list items before, used in pagination.
|
29
|
-
before: nil,
|
30
27
|
# Additional fields to include in the response. See the `include` parameter for
|
31
28
|
# Response creation above for more information.
|
32
29
|
include: nil,
|
@@ -22,6 +22,13 @@ module OpenAI
|
|
22
22
|
sig do
|
23
23
|
params(
|
24
24
|
background: T.nilable(T::Boolean),
|
25
|
+
conversation:
|
26
|
+
T.nilable(
|
27
|
+
T.any(
|
28
|
+
String,
|
29
|
+
OpenAI::Responses::ResponseConversationParam::OrHash
|
30
|
+
)
|
31
|
+
),
|
25
32
|
include:
|
26
33
|
T.nilable(
|
27
34
|
T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol]
|
@@ -96,6 +103,11 @@ module OpenAI
|
|
96
103
|
# Whether to run the model response in the background.
|
97
104
|
# [Learn more](https://platform.openai.com/docs/guides/background).
|
98
105
|
background: nil,
|
106
|
+
# The conversation that this response belongs to. Items from this conversation are
|
107
|
+
# prepended to `input_items` for this response request. Input items and output
|
108
|
+
# items from this response are automatically added to this conversation after this
|
109
|
+
# response completes.
|
110
|
+
conversation: nil,
|
99
111
|
# Specify additional output data to include in the model response. Currently
|
100
112
|
# supported values are:
|
101
113
|
#
|
@@ -156,6 +168,7 @@ module OpenAI
|
|
156
168
|
# The unique ID of the previous response to the model. Use this to create
|
157
169
|
# multi-turn conversations. Learn more about
|
158
170
|
# [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
171
|
+
# Cannot be used in conjunction with `conversation`.
|
159
172
|
previous_response_id: nil,
|
160
173
|
# Reference to a prompt template and its variables.
|
161
174
|
# [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
@@ -164,7 +177,7 @@ module OpenAI
|
|
164
177
|
# hit rates. Replaces the `user` field.
|
165
178
|
# [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
|
166
179
|
prompt_cache_key: nil,
|
167
|
-
# **o-series models only**
|
180
|
+
# **gpt-5 and o-series models only**
|
168
181
|
#
|
169
182
|
# Configuration options for
|
170
183
|
# [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
@@ -183,9 +196,8 @@ module OpenAI
|
|
183
196
|
# - If set to 'default', then the request will be processed with the standard
|
184
197
|
# pricing and performance for the selected model.
|
185
198
|
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
186
|
-
# 'priority', then the request
|
187
|
-
#
|
188
|
-
# Priority processing.
|
199
|
+
# '[priority](https://openai.com/api-priority-processing/)', then the request
|
200
|
+
# will be processed with the corresponding service tier.
|
189
201
|
# - When not set, the default behavior is 'auto'.
|
190
202
|
#
|
191
203
|
# When the `service_tier` parameter is set, the response body will include the
|
@@ -275,6 +287,13 @@ module OpenAI
|
|
275
287
|
sig do
|
276
288
|
params(
|
277
289
|
background: T.nilable(T::Boolean),
|
290
|
+
conversation:
|
291
|
+
T.nilable(
|
292
|
+
T.any(
|
293
|
+
String,
|
294
|
+
OpenAI::Responses::ResponseConversationParam::OrHash
|
295
|
+
)
|
296
|
+
),
|
278
297
|
include:
|
279
298
|
T.nilable(
|
280
299
|
T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol]
|
@@ -355,6 +374,11 @@ module OpenAI
|
|
355
374
|
# Whether to run the model response in the background.
|
356
375
|
# [Learn more](https://platform.openai.com/docs/guides/background).
|
357
376
|
background: nil,
|
377
|
+
# The conversation that this response belongs to. Items from this conversation are
|
378
|
+
# prepended to `input_items` for this response request. Input items and output
|
379
|
+
# items from this response are automatically added to this conversation after this
|
380
|
+
# response completes.
|
381
|
+
conversation: nil,
|
358
382
|
# Specify additional output data to include in the model response. Currently
|
359
383
|
# supported values are:
|
360
384
|
#
|
@@ -415,6 +439,7 @@ module OpenAI
|
|
415
439
|
# The unique ID of the previous response to the model. Use this to create
|
416
440
|
# multi-turn conversations. Learn more about
|
417
441
|
# [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
442
|
+
# Cannot be used in conjunction with `conversation`.
|
418
443
|
previous_response_id: nil,
|
419
444
|
# Reference to a prompt template and its variables.
|
420
445
|
# [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
@@ -423,7 +448,7 @@ module OpenAI
|
|
423
448
|
# hit rates. Replaces the `user` field.
|
424
449
|
# [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
|
425
450
|
prompt_cache_key: nil,
|
426
|
-
# **o-series models only**
|
451
|
+
# **gpt-5 and o-series models only**
|
427
452
|
#
|
428
453
|
# Configuration options for
|
429
454
|
# [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
@@ -442,9 +467,8 @@ module OpenAI
|
|
442
467
|
# - If set to 'default', then the request will be processed with the standard
|
443
468
|
# pricing and performance for the selected model.
|
444
469
|
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
445
|
-
# 'priority', then the request
|
446
|
-
#
|
447
|
-
# Priority processing.
|
470
|
+
# '[priority](https://openai.com/api-priority-processing/)', then the request
|
471
|
+
# will be processed with the corresponding service tier.
|
448
472
|
# - When not set, the default behavior is 'auto'.
|
449
473
|
#
|
450
474
|
# When the `service_tier` parameter is set, the response body will include the
|
@@ -31,6 +31,7 @@ module OpenAI
|
|
31
31
|
filename: String,
|
32
32
|
mime_type: String,
|
33
33
|
purpose: OpenAI::FilePurpose::OrSymbol,
|
34
|
+
expires_after: OpenAI::UploadCreateParams::ExpiresAfter::OrHash,
|
34
35
|
request_options: OpenAI::RequestOptions::OrHash
|
35
36
|
).returns(OpenAI::Upload)
|
36
37
|
end
|
@@ -49,6 +50,9 @@ module OpenAI
|
|
49
50
|
# See the
|
50
51
|
# [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose).
|
51
52
|
purpose:,
|
53
|
+
# The expiration policy for a file. By default, files with `purpose=batch` expire
|
54
|
+
# after 30 days and all other files are persisted until they are manually deleted.
|
55
|
+
expires_after: nil,
|
52
56
|
request_options: {}
|
53
57
|
)
|
54
58
|
end
|
data/sig/openai/client.rbs
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module OpenAI
|
2
|
+
module Internal
|
3
|
+
class ConversationCursorPage[Elem]
|
4
|
+
include OpenAI::Internal::Type::BasePage[Elem]
|
5
|
+
|
6
|
+
attr_accessor data: ::Array[Elem]?
|
7
|
+
|
8
|
+
attr_accessor has_more: bool
|
9
|
+
|
10
|
+
attr_accessor last_id: String
|
11
|
+
|
12
|
+
def inspect: -> String
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|