openai 0.22.1 → 0.23.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 +8 -0
- data/README.md +1 -1
- data/lib/openai/models/realtime/audio_transcription.rb +60 -0
- data/lib/openai/models/realtime/client_secret_create_params.rb +18 -9
- data/lib/openai/models/realtime/client_secret_create_response.rb +11 -250
- data/lib/openai/models/realtime/conversation_item.rb +1 -1
- data/lib/openai/models/realtime/conversation_item_added.rb +14 -1
- data/lib/openai/models/realtime/conversation_item_done.rb +3 -0
- data/lib/openai/models/realtime/conversation_item_input_audio_transcription_completed_event.rb +10 -8
- data/lib/openai/models/realtime/conversation_item_input_audio_transcription_delta_event.rb +14 -5
- data/lib/openai/models/realtime/conversation_item_truncate_event.rb +2 -2
- data/lib/openai/models/realtime/input_audio_buffer_append_event.rb +10 -5
- data/lib/openai/models/realtime/models.rb +58 -0
- data/lib/openai/models/realtime/noise_reduction_type.rb +20 -0
- data/lib/openai/models/realtime/realtime_audio_config.rb +6 -427
- data/lib/openai/models/realtime/realtime_audio_config_input.rb +89 -0
- data/lib/openai/models/realtime/realtime_audio_config_output.rb +100 -0
- data/lib/openai/models/realtime/realtime_audio_formats.rb +121 -0
- data/lib/openai/models/realtime/realtime_audio_input_turn_detection.rb +131 -0
- data/lib/openai/models/realtime/realtime_client_event.rb +31 -23
- data/lib/openai/models/realtime/realtime_conversation_item_assistant_message.rb +43 -10
- data/lib/openai/models/realtime/realtime_conversation_item_function_call.rb +16 -7
- data/lib/openai/models/realtime/realtime_conversation_item_function_call_output.rb +15 -7
- data/lib/openai/models/realtime/realtime_conversation_item_system_message.rb +18 -6
- data/lib/openai/models/realtime/realtime_conversation_item_user_message.rb +62 -13
- data/lib/openai/models/realtime/realtime_response.rb +117 -107
- data/lib/openai/models/realtime/realtime_response_create_audio_output.rb +100 -0
- data/lib/openai/models/realtime/realtime_response_create_mcp_tool.rb +310 -0
- data/lib/openai/models/realtime/realtime_response_create_params.rb +225 -0
- data/lib/openai/models/realtime/realtime_response_status.rb +1 -1
- data/lib/openai/models/realtime/realtime_response_usage.rb +5 -2
- data/lib/openai/models/realtime/realtime_response_usage_input_token_details.rb +58 -8
- data/lib/openai/models/realtime/realtime_server_event.rb +21 -5
- data/lib/openai/models/realtime/realtime_session.rb +9 -125
- data/lib/openai/models/realtime/realtime_session_client_secret.rb +36 -0
- data/lib/openai/models/realtime/realtime_session_create_request.rb +50 -71
- data/lib/openai/models/realtime/realtime_session_create_response.rb +621 -219
- data/lib/openai/models/realtime/realtime_tools_config_union.rb +2 -53
- data/lib/openai/models/realtime/realtime_tracing_config.rb +7 -6
- data/lib/openai/models/realtime/realtime_transcription_session_audio.rb +19 -0
- data/lib/openai/models/realtime/realtime_transcription_session_audio_input.rb +90 -0
- data/lib/openai/models/realtime/realtime_transcription_session_audio_input_turn_detection.rb +131 -0
- data/lib/openai/models/realtime/realtime_transcription_session_client_secret.rb +38 -0
- data/lib/openai/models/realtime/realtime_transcription_session_create_request.rb +12 -270
- data/lib/openai/models/realtime/realtime_transcription_session_create_response.rb +78 -0
- data/lib/openai/models/realtime/realtime_transcription_session_input_audio_transcription.rb +66 -0
- data/lib/openai/models/realtime/realtime_transcription_session_turn_detection.rb +57 -0
- data/lib/openai/models/realtime/realtime_truncation.rb +8 -40
- data/lib/openai/models/realtime/realtime_truncation_retention_ratio.rb +34 -0
- data/lib/openai/models/realtime/response_cancel_event.rb +3 -1
- data/lib/openai/models/realtime/response_create_event.rb +18 -348
- data/lib/openai/models/realtime/response_done_event.rb +7 -0
- data/lib/openai/models/realtime/session_created_event.rb +20 -4
- data/lib/openai/models/realtime/session_update_event.rb +36 -12
- data/lib/openai/models/realtime/session_updated_event.rb +20 -4
- data/lib/openai/models/realtime/transcription_session_created.rb +8 -243
- data/lib/openai/models/realtime/transcription_session_update.rb +179 -3
- data/lib/openai/models/realtime/transcription_session_updated_event.rb +8 -243
- data/lib/openai/resources/realtime/client_secrets.rb +2 -3
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +19 -1
- data/rbi/openai/models/realtime/audio_transcription.rbi +132 -0
- data/rbi/openai/models/realtime/client_secret_create_params.rbi +25 -11
- data/rbi/openai/models/realtime/client_secret_create_response.rbi +2 -587
- data/rbi/openai/models/realtime/conversation_item_added.rbi +14 -1
- data/rbi/openai/models/realtime/conversation_item_done.rbi +3 -0
- data/rbi/openai/models/realtime/conversation_item_input_audio_transcription_completed_event.rbi +11 -8
- data/rbi/openai/models/realtime/conversation_item_input_audio_transcription_delta_event.rbi +15 -5
- data/rbi/openai/models/realtime/conversation_item_truncate_event.rbi +2 -2
- data/rbi/openai/models/realtime/input_audio_buffer_append_event.rbi +10 -5
- data/rbi/openai/models/realtime/models.rbi +97 -0
- data/rbi/openai/models/realtime/noise_reduction_type.rbi +31 -0
- data/rbi/openai/models/realtime/realtime_audio_config.rbi +8 -956
- data/rbi/openai/models/realtime/realtime_audio_config_input.rbi +221 -0
- data/rbi/openai/models/realtime/realtime_audio_config_output.rbi +222 -0
- data/rbi/openai/models/realtime/realtime_audio_formats.rbi +329 -0
- data/rbi/openai/models/realtime/realtime_audio_input_turn_detection.rbi +262 -0
- data/rbi/openai/models/realtime/realtime_conversation_item_assistant_message.rbi +51 -10
- data/rbi/openai/models/realtime/realtime_conversation_item_function_call.rbi +16 -7
- data/rbi/openai/models/realtime/realtime_conversation_item_function_call_output.rbi +14 -7
- data/rbi/openai/models/realtime/realtime_conversation_item_system_message.rbi +16 -6
- data/rbi/openai/models/realtime/realtime_conversation_item_user_message.rbi +110 -12
- data/rbi/openai/models/realtime/realtime_response.rbi +287 -212
- data/rbi/openai/models/realtime/realtime_response_create_audio_output.rbi +250 -0
- data/rbi/openai/models/realtime/realtime_response_create_mcp_tool.rbi +616 -0
- data/rbi/openai/models/realtime/realtime_response_create_params.rbi +529 -0
- data/rbi/openai/models/realtime/realtime_response_usage.rbi +8 -2
- data/rbi/openai/models/realtime/realtime_response_usage_input_token_details.rbi +106 -7
- data/rbi/openai/models/realtime/realtime_server_event.rbi +4 -1
- data/rbi/openai/models/realtime/realtime_session.rbi +12 -262
- data/rbi/openai/models/realtime/realtime_session_client_secret.rbi +49 -0
- data/rbi/openai/models/realtime/realtime_session_create_request.rbi +112 -133
- data/rbi/openai/models/realtime/realtime_session_create_response.rbi +1229 -405
- data/rbi/openai/models/realtime/realtime_tools_config_union.rbi +1 -117
- data/rbi/openai/models/realtime/realtime_tracing_config.rbi +11 -10
- data/rbi/openai/models/realtime/realtime_transcription_session_audio.rbi +50 -0
- data/rbi/openai/models/realtime/realtime_transcription_session_audio_input.rbi +226 -0
- data/rbi/openai/models/realtime/realtime_transcription_session_audio_input_turn_detection.rbi +259 -0
- data/rbi/openai/models/realtime/realtime_transcription_session_client_secret.rbi +51 -0
- data/rbi/openai/models/realtime/realtime_transcription_session_create_request.rbi +25 -597
- data/rbi/openai/models/realtime/realtime_transcription_session_create_response.rbi +195 -0
- data/rbi/openai/models/realtime/realtime_transcription_session_input_audio_transcription.rbi +144 -0
- data/rbi/openai/models/realtime/realtime_transcription_session_turn_detection.rbi +94 -0
- data/rbi/openai/models/realtime/realtime_truncation.rbi +5 -56
- data/rbi/openai/models/realtime/realtime_truncation_retention_ratio.rbi +45 -0
- data/rbi/openai/models/realtime/response_cancel_event.rbi +3 -1
- data/rbi/openai/models/realtime/response_create_event.rbi +19 -786
- data/rbi/openai/models/realtime/response_done_event.rbi +7 -0
- data/rbi/openai/models/realtime/session_created_event.rbi +42 -9
- data/rbi/openai/models/realtime/session_update_event.rbi +57 -19
- data/rbi/openai/models/realtime/session_updated_event.rbi +42 -9
- data/rbi/openai/models/realtime/transcription_session_created.rbi +17 -591
- data/rbi/openai/models/realtime/transcription_session_update.rbi +425 -7
- data/rbi/openai/models/realtime/transcription_session_updated_event.rbi +14 -591
- data/rbi/openai/resources/realtime/client_secrets.rbi +5 -3
- data/sig/openai/models/realtime/audio_transcription.rbs +57 -0
- data/sig/openai/models/realtime/client_secret_create_response.rbs +1 -251
- data/sig/openai/models/realtime/models.rbs +57 -0
- data/sig/openai/models/realtime/noise_reduction_type.rbs +16 -0
- data/sig/openai/models/realtime/realtime_audio_config.rbs +12 -331
- data/sig/openai/models/realtime/realtime_audio_config_input.rbs +72 -0
- data/sig/openai/models/realtime/realtime_audio_config_output.rbs +72 -0
- data/sig/openai/models/realtime/realtime_audio_formats.rbs +128 -0
- data/sig/openai/models/realtime/realtime_audio_input_turn_detection.rbs +99 -0
- data/sig/openai/models/realtime/realtime_conversation_item_assistant_message.rbs +17 -2
- data/sig/openai/models/realtime/realtime_conversation_item_user_message.rbs +30 -1
- data/sig/openai/models/realtime/realtime_response.rbs +103 -82
- data/sig/openai/models/realtime/realtime_response_create_audio_output.rbs +84 -0
- data/sig/openai/models/realtime/realtime_response_create_mcp_tool.rbs +218 -0
- data/sig/openai/models/realtime/realtime_response_create_params.rbs +148 -0
- data/sig/openai/models/realtime/realtime_response_usage_input_token_details.rbs +50 -1
- data/sig/openai/models/realtime/realtime_session.rbs +16 -106
- data/sig/openai/models/realtime/realtime_session_client_secret.rbs +20 -0
- data/sig/openai/models/realtime/realtime_session_create_request.rbs +27 -43
- data/sig/openai/models/realtime/realtime_session_create_response.rbs +389 -187
- data/sig/openai/models/realtime/realtime_tools_config_union.rbs +1 -53
- data/sig/openai/models/realtime/realtime_transcription_session_audio.rbs +24 -0
- data/sig/openai/models/realtime/realtime_transcription_session_audio_input.rbs +72 -0
- data/sig/openai/models/realtime/realtime_transcription_session_audio_input_turn_detection.rbs +99 -0
- data/sig/openai/models/realtime/realtime_transcription_session_client_secret.rbs +20 -0
- data/sig/openai/models/realtime/realtime_transcription_session_create_request.rbs +11 -203
- data/sig/openai/models/realtime/realtime_transcription_session_create_response.rbs +69 -0
- data/sig/openai/models/realtime/realtime_transcription_session_input_audio_transcription.rbs +59 -0
- data/sig/openai/models/realtime/realtime_transcription_session_turn_detection.rbs +47 -0
- data/sig/openai/models/realtime/realtime_truncation.rbs +1 -28
- data/sig/openai/models/realtime/realtime_truncation_retention_ratio.rbs +21 -0
- data/sig/openai/models/realtime/response_create_event.rbs +6 -249
- data/sig/openai/models/realtime/session_created_event.rbs +14 -4
- data/sig/openai/models/realtime/session_update_event.rbs +14 -4
- data/sig/openai/models/realtime/session_updated_event.rbs +14 -4
- data/sig/openai/models/realtime/transcription_session_created.rbs +4 -254
- data/sig/openai/models/realtime/transcription_session_update.rbs +154 -4
- data/sig/openai/models/realtime/transcription_session_updated_event.rbs +4 -254
- metadata +59 -5
- data/lib/openai/models/realtime/realtime_client_secret_config.rb +0 -64
- data/rbi/openai/models/realtime/realtime_client_secret_config.rbi +0 -147
- data/sig/openai/models/realtime/realtime_client_secret_config.rbs +0 -60
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OpenAI
|
|
4
|
+
module Models
|
|
5
|
+
module Realtime
|
|
6
|
+
class RealtimeResponseCreateParams < OpenAI::Internal::Type::BaseModel
|
|
7
|
+
OrHash =
|
|
8
|
+
T.type_alias do
|
|
9
|
+
T.any(
|
|
10
|
+
OpenAI::Realtime::RealtimeResponseCreateParams,
|
|
11
|
+
OpenAI::Internal::AnyHash
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Configuration for audio input and output.
|
|
16
|
+
sig do
|
|
17
|
+
returns(
|
|
18
|
+
T.nilable(OpenAI::Realtime::RealtimeResponseCreateAudioOutput)
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
attr_reader :audio
|
|
22
|
+
|
|
23
|
+
sig do
|
|
24
|
+
params(
|
|
25
|
+
audio: OpenAI::Realtime::RealtimeResponseCreateAudioOutput::OrHash
|
|
26
|
+
).void
|
|
27
|
+
end
|
|
28
|
+
attr_writer :audio
|
|
29
|
+
|
|
30
|
+
# Controls which conversation the response is added to. Currently supports `auto`
|
|
31
|
+
# and `none`, with `auto` as the default value. The `auto` value means that the
|
|
32
|
+
# contents of the response will be added to the default conversation. Set this to
|
|
33
|
+
# `none` to create an out-of-band response which will not add items to default
|
|
34
|
+
# conversation.
|
|
35
|
+
sig do
|
|
36
|
+
returns(
|
|
37
|
+
T.nilable(
|
|
38
|
+
T.any(
|
|
39
|
+
String,
|
|
40
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::OrSymbol
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
attr_reader :conversation
|
|
46
|
+
|
|
47
|
+
sig do
|
|
48
|
+
params(
|
|
49
|
+
conversation:
|
|
50
|
+
T.any(
|
|
51
|
+
String,
|
|
52
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::OrSymbol
|
|
53
|
+
)
|
|
54
|
+
).void
|
|
55
|
+
end
|
|
56
|
+
attr_writer :conversation
|
|
57
|
+
|
|
58
|
+
# Input items to include in the prompt for the model. Using this field creates a
|
|
59
|
+
# new context for this Response instead of using the default conversation. An
|
|
60
|
+
# empty array `[]` will clear the context for this Response. Note that this can
|
|
61
|
+
# include references to items that previously appeared in the session using their
|
|
62
|
+
# id.
|
|
63
|
+
sig do
|
|
64
|
+
returns(
|
|
65
|
+
T.nilable(
|
|
66
|
+
T::Array[
|
|
67
|
+
T.any(
|
|
68
|
+
OpenAI::Realtime::RealtimeConversationItemSystemMessage,
|
|
69
|
+
OpenAI::Realtime::RealtimeConversationItemUserMessage,
|
|
70
|
+
OpenAI::Realtime::RealtimeConversationItemAssistantMessage,
|
|
71
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCall,
|
|
72
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCallOutput,
|
|
73
|
+
OpenAI::Realtime::RealtimeMcpApprovalResponse,
|
|
74
|
+
OpenAI::Realtime::RealtimeMcpListTools,
|
|
75
|
+
OpenAI::Realtime::RealtimeMcpToolCall,
|
|
76
|
+
OpenAI::Realtime::RealtimeMcpApprovalRequest
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
attr_reader :input
|
|
83
|
+
|
|
84
|
+
sig do
|
|
85
|
+
params(
|
|
86
|
+
input:
|
|
87
|
+
T::Array[
|
|
88
|
+
T.any(
|
|
89
|
+
OpenAI::Realtime::RealtimeConversationItemSystemMessage::OrHash,
|
|
90
|
+
OpenAI::Realtime::RealtimeConversationItemUserMessage::OrHash,
|
|
91
|
+
OpenAI::Realtime::RealtimeConversationItemAssistantMessage::OrHash,
|
|
92
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCall::OrHash,
|
|
93
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCallOutput::OrHash,
|
|
94
|
+
OpenAI::Realtime::RealtimeMcpApprovalResponse::OrHash,
|
|
95
|
+
OpenAI::Realtime::RealtimeMcpListTools::OrHash,
|
|
96
|
+
OpenAI::Realtime::RealtimeMcpToolCall::OrHash,
|
|
97
|
+
OpenAI::Realtime::RealtimeMcpApprovalRequest::OrHash
|
|
98
|
+
)
|
|
99
|
+
]
|
|
100
|
+
).void
|
|
101
|
+
end
|
|
102
|
+
attr_writer :input
|
|
103
|
+
|
|
104
|
+
# The default system instructions (i.e. system message) prepended to model calls.
|
|
105
|
+
# This field allows the client to guide the model on desired responses. The model
|
|
106
|
+
# can be instructed on response content and format, (e.g. "be extremely succinct",
|
|
107
|
+
# "act friendly", "here are examples of good responses") and on audio behavior
|
|
108
|
+
# (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
|
109
|
+
# instructions are not guaranteed to be followed by the model, but they provide
|
|
110
|
+
# guidance to the model on the desired behavior. Note that the server sets default
|
|
111
|
+
# instructions which will be used if this field is not set and are visible in the
|
|
112
|
+
# `session.created` event at the start of the session.
|
|
113
|
+
sig { returns(T.nilable(String)) }
|
|
114
|
+
attr_reader :instructions
|
|
115
|
+
|
|
116
|
+
sig { params(instructions: String).void }
|
|
117
|
+
attr_writer :instructions
|
|
118
|
+
|
|
119
|
+
# Maximum number of output tokens for a single assistant response, inclusive of
|
|
120
|
+
# tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
|
121
|
+
# `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
|
122
|
+
sig { returns(T.nilable(T.any(Integer, Symbol))) }
|
|
123
|
+
attr_reader :max_output_tokens
|
|
124
|
+
|
|
125
|
+
sig { params(max_output_tokens: T.any(Integer, Symbol)).void }
|
|
126
|
+
attr_writer :max_output_tokens
|
|
127
|
+
|
|
128
|
+
# Set of 16 key-value pairs that can be attached to an object. This can be useful
|
|
129
|
+
# for storing additional information about the object in a structured format, and
|
|
130
|
+
# querying for objects via API or the dashboard.
|
|
131
|
+
#
|
|
132
|
+
# Keys are strings with a maximum length of 64 characters. Values are strings with
|
|
133
|
+
# a maximum length of 512 characters.
|
|
134
|
+
sig { returns(T.nilable(T::Hash[Symbol, String])) }
|
|
135
|
+
attr_accessor :metadata
|
|
136
|
+
|
|
137
|
+
# The set of modalities the model used to respond, currently the only possible
|
|
138
|
+
# values are `[\"audio\"]`, `[\"text\"]`. Audio output always include a text
|
|
139
|
+
# transcript. Setting the output to mode `text` will disable audio output from the
|
|
140
|
+
# model.
|
|
141
|
+
sig do
|
|
142
|
+
returns(
|
|
143
|
+
T.nilable(
|
|
144
|
+
T::Array[
|
|
145
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality::OrSymbol
|
|
146
|
+
]
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
end
|
|
150
|
+
attr_reader :output_modalities
|
|
151
|
+
|
|
152
|
+
sig do
|
|
153
|
+
params(
|
|
154
|
+
output_modalities:
|
|
155
|
+
T::Array[
|
|
156
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality::OrSymbol
|
|
157
|
+
]
|
|
158
|
+
).void
|
|
159
|
+
end
|
|
160
|
+
attr_writer :output_modalities
|
|
161
|
+
|
|
162
|
+
# Reference to a prompt template and its variables.
|
|
163
|
+
# [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
|
164
|
+
sig { returns(T.nilable(OpenAI::Responses::ResponsePrompt)) }
|
|
165
|
+
attr_reader :prompt
|
|
166
|
+
|
|
167
|
+
sig do
|
|
168
|
+
params(
|
|
169
|
+
prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash)
|
|
170
|
+
).void
|
|
171
|
+
end
|
|
172
|
+
attr_writer :prompt
|
|
173
|
+
|
|
174
|
+
# How the model chooses tools. Provide one of the string modes or force a specific
|
|
175
|
+
# function/MCP tool.
|
|
176
|
+
sig do
|
|
177
|
+
returns(
|
|
178
|
+
T.nilable(
|
|
179
|
+
T.any(
|
|
180
|
+
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
|
181
|
+
OpenAI::Responses::ToolChoiceFunction,
|
|
182
|
+
OpenAI::Responses::ToolChoiceMcp
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
attr_reader :tool_choice
|
|
188
|
+
|
|
189
|
+
sig do
|
|
190
|
+
params(
|
|
191
|
+
tool_choice:
|
|
192
|
+
T.any(
|
|
193
|
+
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
|
194
|
+
OpenAI::Responses::ToolChoiceFunction::OrHash,
|
|
195
|
+
OpenAI::Responses::ToolChoiceMcp::OrHash
|
|
196
|
+
)
|
|
197
|
+
).void
|
|
198
|
+
end
|
|
199
|
+
attr_writer :tool_choice
|
|
200
|
+
|
|
201
|
+
# Tools available to the model.
|
|
202
|
+
sig do
|
|
203
|
+
returns(
|
|
204
|
+
T.nilable(
|
|
205
|
+
T::Array[
|
|
206
|
+
T.any(
|
|
207
|
+
OpenAI::Realtime::Models,
|
|
208
|
+
OpenAI::Realtime::RealtimeResponseCreateMcpTool
|
|
209
|
+
)
|
|
210
|
+
]
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
end
|
|
214
|
+
attr_reader :tools
|
|
215
|
+
|
|
216
|
+
sig do
|
|
217
|
+
params(
|
|
218
|
+
tools:
|
|
219
|
+
T::Array[
|
|
220
|
+
T.any(
|
|
221
|
+
OpenAI::Realtime::Models::OrHash,
|
|
222
|
+
OpenAI::Realtime::RealtimeResponseCreateMcpTool::OrHash
|
|
223
|
+
)
|
|
224
|
+
]
|
|
225
|
+
).void
|
|
226
|
+
end
|
|
227
|
+
attr_writer :tools
|
|
228
|
+
|
|
229
|
+
# Create a new Realtime response with these parameters
|
|
230
|
+
sig do
|
|
231
|
+
params(
|
|
232
|
+
audio: OpenAI::Realtime::RealtimeResponseCreateAudioOutput::OrHash,
|
|
233
|
+
conversation:
|
|
234
|
+
T.any(
|
|
235
|
+
String,
|
|
236
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::OrSymbol
|
|
237
|
+
),
|
|
238
|
+
input:
|
|
239
|
+
T::Array[
|
|
240
|
+
T.any(
|
|
241
|
+
OpenAI::Realtime::RealtimeConversationItemSystemMessage::OrHash,
|
|
242
|
+
OpenAI::Realtime::RealtimeConversationItemUserMessage::OrHash,
|
|
243
|
+
OpenAI::Realtime::RealtimeConversationItemAssistantMessage::OrHash,
|
|
244
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCall::OrHash,
|
|
245
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCallOutput::OrHash,
|
|
246
|
+
OpenAI::Realtime::RealtimeMcpApprovalResponse::OrHash,
|
|
247
|
+
OpenAI::Realtime::RealtimeMcpListTools::OrHash,
|
|
248
|
+
OpenAI::Realtime::RealtimeMcpToolCall::OrHash,
|
|
249
|
+
OpenAI::Realtime::RealtimeMcpApprovalRequest::OrHash
|
|
250
|
+
)
|
|
251
|
+
],
|
|
252
|
+
instructions: String,
|
|
253
|
+
max_output_tokens: T.any(Integer, Symbol),
|
|
254
|
+
metadata: T.nilable(T::Hash[Symbol, String]),
|
|
255
|
+
output_modalities:
|
|
256
|
+
T::Array[
|
|
257
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality::OrSymbol
|
|
258
|
+
],
|
|
259
|
+
prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
|
|
260
|
+
tool_choice:
|
|
261
|
+
T.any(
|
|
262
|
+
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
|
263
|
+
OpenAI::Responses::ToolChoiceFunction::OrHash,
|
|
264
|
+
OpenAI::Responses::ToolChoiceMcp::OrHash
|
|
265
|
+
),
|
|
266
|
+
tools:
|
|
267
|
+
T::Array[
|
|
268
|
+
T.any(
|
|
269
|
+
OpenAI::Realtime::Models::OrHash,
|
|
270
|
+
OpenAI::Realtime::RealtimeResponseCreateMcpTool::OrHash
|
|
271
|
+
)
|
|
272
|
+
]
|
|
273
|
+
).returns(T.attached_class)
|
|
274
|
+
end
|
|
275
|
+
def self.new(
|
|
276
|
+
# Configuration for audio input and output.
|
|
277
|
+
audio: nil,
|
|
278
|
+
# Controls which conversation the response is added to. Currently supports `auto`
|
|
279
|
+
# and `none`, with `auto` as the default value. The `auto` value means that the
|
|
280
|
+
# contents of the response will be added to the default conversation. Set this to
|
|
281
|
+
# `none` to create an out-of-band response which will not add items to default
|
|
282
|
+
# conversation.
|
|
283
|
+
conversation: nil,
|
|
284
|
+
# Input items to include in the prompt for the model. Using this field creates a
|
|
285
|
+
# new context for this Response instead of using the default conversation. An
|
|
286
|
+
# empty array `[]` will clear the context for this Response. Note that this can
|
|
287
|
+
# include references to items that previously appeared in the session using their
|
|
288
|
+
# id.
|
|
289
|
+
input: nil,
|
|
290
|
+
# The default system instructions (i.e. system message) prepended to model calls.
|
|
291
|
+
# This field allows the client to guide the model on desired responses. The model
|
|
292
|
+
# can be instructed on response content and format, (e.g. "be extremely succinct",
|
|
293
|
+
# "act friendly", "here are examples of good responses") and on audio behavior
|
|
294
|
+
# (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
|
|
295
|
+
# instructions are not guaranteed to be followed by the model, but they provide
|
|
296
|
+
# guidance to the model on the desired behavior. Note that the server sets default
|
|
297
|
+
# instructions which will be used if this field is not set and are visible in the
|
|
298
|
+
# `session.created` event at the start of the session.
|
|
299
|
+
instructions: nil,
|
|
300
|
+
# Maximum number of output tokens for a single assistant response, inclusive of
|
|
301
|
+
# tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
|
302
|
+
# `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
|
303
|
+
max_output_tokens: nil,
|
|
304
|
+
# Set of 16 key-value pairs that can be attached to an object. This can be useful
|
|
305
|
+
# for storing additional information about the object in a structured format, and
|
|
306
|
+
# querying for objects via API or the dashboard.
|
|
307
|
+
#
|
|
308
|
+
# Keys are strings with a maximum length of 64 characters. Values are strings with
|
|
309
|
+
# a maximum length of 512 characters.
|
|
310
|
+
metadata: nil,
|
|
311
|
+
# The set of modalities the model used to respond, currently the only possible
|
|
312
|
+
# values are `[\"audio\"]`, `[\"text\"]`. Audio output always include a text
|
|
313
|
+
# transcript. Setting the output to mode `text` will disable audio output from the
|
|
314
|
+
# model.
|
|
315
|
+
output_modalities: nil,
|
|
316
|
+
# Reference to a prompt template and its variables.
|
|
317
|
+
# [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
|
|
318
|
+
prompt: nil,
|
|
319
|
+
# How the model chooses tools. Provide one of the string modes or force a specific
|
|
320
|
+
# function/MCP tool.
|
|
321
|
+
tool_choice: nil,
|
|
322
|
+
# Tools available to the model.
|
|
323
|
+
tools: nil
|
|
324
|
+
)
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
sig do
|
|
328
|
+
override.returns(
|
|
329
|
+
{
|
|
330
|
+
audio: OpenAI::Realtime::RealtimeResponseCreateAudioOutput,
|
|
331
|
+
conversation:
|
|
332
|
+
T.any(
|
|
333
|
+
String,
|
|
334
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::OrSymbol
|
|
335
|
+
),
|
|
336
|
+
input:
|
|
337
|
+
T::Array[
|
|
338
|
+
T.any(
|
|
339
|
+
OpenAI::Realtime::RealtimeConversationItemSystemMessage,
|
|
340
|
+
OpenAI::Realtime::RealtimeConversationItemUserMessage,
|
|
341
|
+
OpenAI::Realtime::RealtimeConversationItemAssistantMessage,
|
|
342
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCall,
|
|
343
|
+
OpenAI::Realtime::RealtimeConversationItemFunctionCallOutput,
|
|
344
|
+
OpenAI::Realtime::RealtimeMcpApprovalResponse,
|
|
345
|
+
OpenAI::Realtime::RealtimeMcpListTools,
|
|
346
|
+
OpenAI::Realtime::RealtimeMcpToolCall,
|
|
347
|
+
OpenAI::Realtime::RealtimeMcpApprovalRequest
|
|
348
|
+
)
|
|
349
|
+
],
|
|
350
|
+
instructions: String,
|
|
351
|
+
max_output_tokens: T.any(Integer, Symbol),
|
|
352
|
+
metadata: T.nilable(T::Hash[Symbol, String]),
|
|
353
|
+
output_modalities:
|
|
354
|
+
T::Array[
|
|
355
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality::OrSymbol
|
|
356
|
+
],
|
|
357
|
+
prompt: T.nilable(OpenAI::Responses::ResponsePrompt),
|
|
358
|
+
tool_choice:
|
|
359
|
+
T.any(
|
|
360
|
+
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
|
361
|
+
OpenAI::Responses::ToolChoiceFunction,
|
|
362
|
+
OpenAI::Responses::ToolChoiceMcp
|
|
363
|
+
),
|
|
364
|
+
tools:
|
|
365
|
+
T::Array[
|
|
366
|
+
T.any(
|
|
367
|
+
OpenAI::Realtime::Models,
|
|
368
|
+
OpenAI::Realtime::RealtimeResponseCreateMcpTool
|
|
369
|
+
)
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
end
|
|
374
|
+
def to_hash
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
# Controls which conversation the response is added to. Currently supports `auto`
|
|
378
|
+
# and `none`, with `auto` as the default value. The `auto` value means that the
|
|
379
|
+
# contents of the response will be added to the default conversation. Set this to
|
|
380
|
+
# `none` to create an out-of-band response which will not add items to default
|
|
381
|
+
# conversation.
|
|
382
|
+
module Conversation
|
|
383
|
+
extend OpenAI::Internal::Type::Union
|
|
384
|
+
|
|
385
|
+
Variants =
|
|
386
|
+
T.type_alias do
|
|
387
|
+
T.any(
|
|
388
|
+
String,
|
|
389
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::TaggedSymbol
|
|
390
|
+
)
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
sig do
|
|
394
|
+
override.returns(
|
|
395
|
+
T::Array[
|
|
396
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::Variants
|
|
397
|
+
]
|
|
398
|
+
)
|
|
399
|
+
end
|
|
400
|
+
def self.variants
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
TaggedSymbol =
|
|
404
|
+
T.type_alias do
|
|
405
|
+
T.all(
|
|
406
|
+
Symbol,
|
|
407
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation
|
|
408
|
+
)
|
|
409
|
+
end
|
|
410
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
411
|
+
|
|
412
|
+
AUTO =
|
|
413
|
+
T.let(
|
|
414
|
+
:auto,
|
|
415
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::TaggedSymbol
|
|
416
|
+
)
|
|
417
|
+
NONE =
|
|
418
|
+
T.let(
|
|
419
|
+
:none,
|
|
420
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Conversation::TaggedSymbol
|
|
421
|
+
)
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
# Maximum number of output tokens for a single assistant response, inclusive of
|
|
425
|
+
# tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
|
|
426
|
+
# `inf` for the maximum available tokens for a given model. Defaults to `inf`.
|
|
427
|
+
module MaxOutputTokens
|
|
428
|
+
extend OpenAI::Internal::Type::Union
|
|
429
|
+
|
|
430
|
+
Variants = T.type_alias { T.any(Integer, Symbol) }
|
|
431
|
+
|
|
432
|
+
sig do
|
|
433
|
+
override.returns(
|
|
434
|
+
T::Array[
|
|
435
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::MaxOutputTokens::Variants
|
|
436
|
+
]
|
|
437
|
+
)
|
|
438
|
+
end
|
|
439
|
+
def self.variants
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
module OutputModality
|
|
444
|
+
extend OpenAI::Internal::Type::Enum
|
|
445
|
+
|
|
446
|
+
TaggedSymbol =
|
|
447
|
+
T.type_alias do
|
|
448
|
+
T.all(
|
|
449
|
+
Symbol,
|
|
450
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality
|
|
451
|
+
)
|
|
452
|
+
end
|
|
453
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
454
|
+
|
|
455
|
+
TEXT =
|
|
456
|
+
T.let(
|
|
457
|
+
:text,
|
|
458
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality::TaggedSymbol
|
|
459
|
+
)
|
|
460
|
+
AUDIO =
|
|
461
|
+
T.let(
|
|
462
|
+
:audio,
|
|
463
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality::TaggedSymbol
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
sig do
|
|
467
|
+
override.returns(
|
|
468
|
+
T::Array[
|
|
469
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality::TaggedSymbol
|
|
470
|
+
]
|
|
471
|
+
)
|
|
472
|
+
end
|
|
473
|
+
def self.values
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
# How the model chooses tools. Provide one of the string modes or force a specific
|
|
478
|
+
# function/MCP tool.
|
|
479
|
+
module ToolChoice
|
|
480
|
+
extend OpenAI::Internal::Type::Union
|
|
481
|
+
|
|
482
|
+
Variants =
|
|
483
|
+
T.type_alias do
|
|
484
|
+
T.any(
|
|
485
|
+
OpenAI::Responses::ToolChoiceOptions::TaggedSymbol,
|
|
486
|
+
OpenAI::Responses::ToolChoiceFunction,
|
|
487
|
+
OpenAI::Responses::ToolChoiceMcp
|
|
488
|
+
)
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
sig do
|
|
492
|
+
override.returns(
|
|
493
|
+
T::Array[
|
|
494
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::ToolChoice::Variants
|
|
495
|
+
]
|
|
496
|
+
)
|
|
497
|
+
end
|
|
498
|
+
def self.variants
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
# Give the model access to additional tools via remote Model Context Protocol
|
|
503
|
+
# (MCP) servers.
|
|
504
|
+
# [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
|
|
505
|
+
module Tool
|
|
506
|
+
extend OpenAI::Internal::Type::Union
|
|
507
|
+
|
|
508
|
+
Variants =
|
|
509
|
+
T.type_alias do
|
|
510
|
+
T.any(
|
|
511
|
+
OpenAI::Realtime::Models,
|
|
512
|
+
OpenAI::Realtime::RealtimeResponseCreateMcpTool
|
|
513
|
+
)
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
sig do
|
|
517
|
+
override.returns(
|
|
518
|
+
T::Array[
|
|
519
|
+
OpenAI::Realtime::RealtimeResponseCreateParams::Tool::Variants
|
|
520
|
+
]
|
|
521
|
+
)
|
|
522
|
+
end
|
|
523
|
+
def self.variants
|
|
524
|
+
end
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
end
|
|
@@ -12,7 +12,10 @@ module OpenAI
|
|
|
12
12
|
)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
# Details about the input tokens used in the Response.
|
|
15
|
+
# Details about the input tokens used in the Response. Cached tokens are tokens
|
|
16
|
+
# from previous turns in the conversation that are included as context for the
|
|
17
|
+
# current response. Cached tokens here are counted as a subset of input tokens,
|
|
18
|
+
# meaning input tokens will include cached and uncached tokens.
|
|
16
19
|
sig do
|
|
17
20
|
returns(
|
|
18
21
|
T.nilable(OpenAI::Realtime::RealtimeResponseUsageInputTokenDetails)
|
|
@@ -84,7 +87,10 @@ module OpenAI
|
|
|
84
87
|
).returns(T.attached_class)
|
|
85
88
|
end
|
|
86
89
|
def self.new(
|
|
87
|
-
# Details about the input tokens used in the Response.
|
|
90
|
+
# Details about the input tokens used in the Response. Cached tokens are tokens
|
|
91
|
+
# from previous turns in the conversation that are included as context for the
|
|
92
|
+
# current response. Cached tokens here are counted as a subset of input tokens,
|
|
93
|
+
# meaning input tokens will include cached and uncached tokens.
|
|
88
94
|
input_token_details: nil,
|
|
89
95
|
# The number of input tokens used in the Response, including text and audio
|
|
90
96
|
# tokens.
|