openai 0.16.0 → 0.17.1
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 +33 -0
- data/README.md +14 -20
- data/lib/openai/internal/transport/base_client.rb +1 -1
- data/lib/openai/internal/type/array_of.rb +1 -0
- data/lib/openai/internal/type/base_model.rb +3 -1
- data/lib/openai/internal/type/converter.rb +27 -0
- data/lib/openai/internal/type/enum.rb +6 -6
- data/lib/openai/internal/type/hash_of.rb +1 -0
- data/lib/openai/internal/type/union.rb +22 -24
- data/lib/openai/models/beta/assistant_create_params.rb +4 -5
- data/lib/openai/models/beta/assistant_update_params.rb +22 -5
- data/lib/openai/models/beta/threads/run_create_params.rb +4 -5
- data/lib/openai/models/chat/chat_completion_allowed_tool_choice.rb +33 -0
- data/lib/openai/models/chat/chat_completion_allowed_tools.rb +64 -0
- data/lib/openai/models/chat/chat_completion_assistant_message_param.rb +3 -5
- data/lib/openai/models/chat/chat_completion_custom_tool.rb +163 -0
- data/lib/openai/models/chat/chat_completion_function_tool.rb +29 -0
- data/lib/openai/models/chat/chat_completion_message.rb +3 -5
- data/lib/openai/models/chat/chat_completion_message_custom_tool_call.rb +60 -0
- data/lib/openai/models/chat/chat_completion_message_function_tool_call.rb +73 -0
- data/lib/openai/models/chat/chat_completion_message_tool_call.rb +10 -56
- data/lib/openai/models/chat/chat_completion_named_tool_choice.rb +2 -2
- data/lib/openai/models/chat/chat_completion_named_tool_choice_custom.rb +42 -0
- data/lib/openai/models/chat/chat_completion_stream_options.rb +14 -1
- data/lib/openai/models/chat/chat_completion_tool.rb +12 -14
- data/lib/openai/models/chat/chat_completion_tool_choice_option.rb +7 -1
- data/lib/openai/models/chat/completion_create_params.rb +35 -12
- data/lib/openai/models/chat_model.rb +7 -0
- data/lib/openai/models/custom_tool_input_format.rb +76 -0
- data/lib/openai/models/evals/create_eval_completions_run_data_source.rb +3 -3
- data/lib/openai/models/evals/run_cancel_response.rb +2 -2
- data/lib/openai/models/evals/run_create_params.rb +2 -2
- data/lib/openai/models/evals/run_create_response.rb +2 -2
- data/lib/openai/models/evals/run_list_response.rb +2 -2
- data/lib/openai/models/evals/run_retrieve_response.rb +2 -2
- data/lib/openai/models/reasoning.rb +4 -5
- data/lib/openai/models/reasoning_effort.rb +4 -4
- data/lib/openai/models/response_format_text_grammar.rb +27 -0
- data/lib/openai/models/response_format_text_python.rb +20 -0
- data/lib/openai/models/responses/custom_tool.rb +48 -0
- data/lib/openai/models/responses/response.rb +20 -12
- data/lib/openai/models/responses/response_create_params.rb +48 -10
- data/lib/openai/models/responses/response_custom_tool_call.rb +55 -0
- data/lib/openai/models/responses/response_custom_tool_call_input_delta_event.rb +52 -0
- data/lib/openai/models/responses/response_custom_tool_call_input_done_event.rb +52 -0
- data/lib/openai/models/responses/response_custom_tool_call_output.rb +47 -0
- data/lib/openai/models/responses/response_input_item.rb +7 -1
- data/lib/openai/models/responses/response_output_item.rb +4 -1
- data/lib/openai/models/responses/response_output_item_added_event.rb +2 -2
- data/lib/openai/models/responses/response_output_item_done_event.rb +2 -2
- data/lib/openai/models/responses/response_reasoning_item.rb +36 -5
- data/lib/openai/models/responses/response_reasoning_text_delta_event.rb +63 -0
- data/lib/openai/models/responses/response_reasoning_text_done_event.rb +63 -0
- data/lib/openai/models/responses/response_retrieve_params.rb +14 -1
- data/lib/openai/models/responses/response_stream_event.rb +13 -11
- data/lib/openai/models/responses/response_text_config.rb +27 -1
- data/lib/openai/models/responses/tool.rb +5 -1
- data/lib/openai/models/responses/tool_choice_allowed.rb +73 -0
- data/lib/openai/models/responses/tool_choice_custom.rb +28 -0
- data/lib/openai/models/vector_store_search_params.rb +6 -1
- data/lib/openai/models.rb +6 -0
- data/lib/openai/resources/beta/assistants.rb +2 -2
- data/lib/openai/resources/beta/threads/runs.rb +2 -2
- data/lib/openai/resources/chat/completions.rb +16 -10
- data/lib/openai/resources/responses.rb +38 -22
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +19 -2
- data/rbi/openai/internal/transport/base_client.rbi +1 -1
- data/rbi/openai/internal/type/converter.rbi +46 -0
- data/rbi/openai/internal/type/union.rbi +7 -2
- data/rbi/openai/models/beta/assistant_create_params.rbi +6 -8
- data/rbi/openai/models/beta/assistant_update_params.rbi +36 -8
- data/rbi/openai/models/beta/threads/run_create_params.rbi +6 -8
- data/rbi/openai/models/chat/chat_completion_allowed_tool_choice.rbi +60 -0
- data/rbi/openai/models/chat/chat_completion_allowed_tools.rbi +118 -0
- data/rbi/openai/models/chat/chat_completion_assistant_message_param.rbi +27 -4
- data/rbi/openai/models/chat/chat_completion_custom_tool.rbi +335 -0
- data/rbi/openai/models/chat/chat_completion_function_tool.rbi +51 -0
- data/rbi/openai/models/chat/chat_completion_message.rbi +17 -4
- data/rbi/openai/models/chat/chat_completion_message_custom_tool_call.rbi +105 -0
- data/rbi/openai/models/chat/chat_completion_message_function_tool_call.rbi +118 -0
- data/rbi/openai/models/chat/chat_completion_message_tool_call.rbi +9 -92
- data/rbi/openai/models/chat/chat_completion_named_tool_choice.rbi +2 -2
- data/rbi/openai/models/chat/chat_completion_named_tool_choice_custom.rbi +89 -0
- data/rbi/openai/models/chat/chat_completion_stream_options.rbi +30 -2
- data/rbi/openai/models/chat/chat_completion_tool.rbi +11 -30
- data/rbi/openai/models/chat/chat_completion_tool_choice_option.rbi +3 -1
- data/rbi/openai/models/chat/completion_create_params.rbi +106 -25
- data/rbi/openai/models/chat_model.rbi +11 -0
- data/rbi/openai/models/custom_tool_input_format.rbi +136 -0
- data/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi +8 -4
- data/rbi/openai/models/evals/run_cancel_response.rbi +2 -0
- data/rbi/openai/models/evals/run_create_params.rbi +4 -0
- data/rbi/openai/models/evals/run_create_response.rbi +2 -0
- data/rbi/openai/models/evals/run_list_response.rbi +2 -0
- data/rbi/openai/models/evals/run_retrieve_response.rbi +2 -0
- data/rbi/openai/models/reasoning.rbi +6 -8
- data/rbi/openai/models/reasoning_effort.rbi +4 -4
- data/rbi/openai/models/response_format_text_grammar.rbi +35 -0
- data/rbi/openai/models/response_format_text_python.rbi +30 -0
- data/rbi/openai/models/responses/custom_tool.rbi +96 -0
- data/rbi/openai/models/responses/response.rbi +15 -5
- data/rbi/openai/models/responses/response_create_params.rbi +94 -7
- data/rbi/openai/models/responses/response_custom_tool_call.rbi +78 -0
- data/rbi/openai/models/responses/response_custom_tool_call_input_delta_event.rbi +75 -0
- data/rbi/openai/models/responses/response_custom_tool_call_input_done_event.rbi +75 -0
- data/rbi/openai/models/responses/response_custom_tool_call_output.rbi +65 -0
- data/rbi/openai/models/responses/response_input_item.rbi +2 -0
- data/rbi/openai/models/responses/response_output_item.rbi +2 -1
- data/rbi/openai/models/responses/response_output_item_added_event.rbi +2 -1
- data/rbi/openai/models/responses/response_output_item_done_event.rbi +2 -1
- data/rbi/openai/models/responses/response_reasoning_item.rbi +63 -4
- data/rbi/openai/models/responses/response_reasoning_text_delta_event.rbi +83 -0
- data/rbi/openai/models/responses/{response_reasoning_summary_done_event.rbi → response_reasoning_text_done_event.rbi} +20 -20
- data/rbi/openai/models/responses/response_retrieve_params.rbi +21 -0
- data/rbi/openai/models/responses/response_stream_event.rbi +4 -2
- data/rbi/openai/models/responses/response_text_config.rbi +64 -1
- data/rbi/openai/models/responses/tool.rbi +1 -0
- data/rbi/openai/models/responses/tool_choice_allowed.rbi +124 -0
- data/rbi/openai/models/responses/tool_choice_custom.rbi +39 -0
- data/rbi/openai/models/vector_store_search_params.rbi +12 -1
- data/rbi/openai/models.rbi +6 -0
- data/rbi/openai/resources/beta/assistants.rbi +6 -8
- data/rbi/openai/resources/beta/threads/runs.rbi +8 -10
- data/rbi/openai/resources/chat/completions.rbi +44 -19
- data/rbi/openai/resources/responses.rbi +215 -41
- data/sig/openai/internal/transport/base_client.rbs +1 -1
- data/sig/openai/internal/type/converter.rbs +17 -0
- data/sig/openai/internal/type/union.rbs +2 -2
- data/sig/openai/models/beta/assistant_update_params.rbs +12 -0
- data/sig/openai/models/chat/chat_completion_allowed_tool_choice.rbs +29 -0
- data/sig/openai/models/chat/chat_completion_allowed_tools.rbs +38 -0
- data/sig/openai/models/chat/chat_completion_assistant_message_param.rbs +6 -6
- data/sig/openai/models/chat/chat_completion_custom_tool.rbs +137 -0
- data/sig/openai/models/chat/chat_completion_function_tool.rbs +26 -0
- data/sig/openai/models/chat/chat_completion_message.rbs +6 -6
- data/sig/openai/models/chat/chat_completion_message_custom_tool_call.rbs +46 -0
- data/sig/openai/models/chat/chat_completion_message_function_tool_call.rbs +46 -0
- data/sig/openai/models/chat/chat_completion_message_tool_call.rbs +6 -35
- data/sig/openai/models/chat/chat_completion_named_tool_choice_custom.rbs +39 -0
- data/sig/openai/models/chat/chat_completion_stream_options.rbs +11 -3
- data/sig/openai/models/chat/chat_completion_tool.rbs +6 -15
- data/sig/openai/models/chat/chat_completion_tool_choice_option.rbs +2 -0
- data/sig/openai/models/chat/completion_create_params.rbs +23 -6
- data/sig/openai/models/chat_model.rbs +15 -1
- data/sig/openai/models/custom_tool_input_format.rbs +61 -0
- data/sig/openai/models/evals/create_eval_completions_run_data_source.rbs +6 -6
- data/sig/openai/models/reasoning_effort.rbs +2 -1
- data/sig/openai/models/response_format_text_grammar.rbs +15 -0
- data/sig/openai/models/response_format_text_python.rbs +13 -0
- data/sig/openai/models/responses/custom_tool.rbs +43 -0
- data/sig/openai/models/responses/response.rbs +2 -0
- data/sig/openai/models/responses/response_create_params.rbs +19 -0
- data/sig/openai/models/responses/response_custom_tool_call.rbs +44 -0
- data/sig/openai/models/responses/response_custom_tool_call_input_delta_event.rbs +42 -0
- data/sig/openai/models/responses/response_custom_tool_call_input_done_event.rbs +42 -0
- data/sig/openai/models/responses/response_custom_tool_call_output.rbs +39 -0
- data/sig/openai/models/responses/response_input_item.rbs +2 -0
- data/sig/openai/models/responses/response_output_item.rbs +1 -0
- data/sig/openai/models/responses/response_reasoning_item.rbs +21 -0
- data/sig/openai/models/responses/{response_reasoning_summary_delta_event.rbs → response_reasoning_text_delta_event.rbs} +15 -15
- data/sig/openai/models/responses/{response_reasoning_summary_done_event.rbs → response_reasoning_text_done_event.rbs} +11 -11
- data/sig/openai/models/responses/response_retrieve_params.rbs +7 -0
- data/sig/openai/models/responses/response_stream_event.rbs +4 -2
- data/sig/openai/models/responses/response_text_config.rbs +22 -3
- data/sig/openai/models/responses/tool.rbs +1 -0
- data/sig/openai/models/responses/tool_choice_allowed.rbs +43 -0
- data/sig/openai/models/responses/tool_choice_custom.rbs +17 -0
- data/sig/openai/models/vector_store_search_params.rbs +2 -1
- data/sig/openai/models.rbs +6 -0
- data/sig/openai/resources/chat/completions.rbs +4 -2
- data/sig/openai/resources/responses.rbs +32 -0
- metadata +59 -8
- data/lib/openai/models/responses/response_reasoning_summary_delta_event.rb +0 -65
- data/lib/openai/models/responses/response_reasoning_summary_done_event.rb +0 -60
- data/rbi/openai/models/responses/response_reasoning_summary_delta_event.rbi +0 -85
@@ -0,0 +1,118 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module OpenAI
|
4
|
+
module Models
|
5
|
+
module Chat
|
6
|
+
class ChatCompletionAllowedTools < OpenAI::Internal::Type::BaseModel
|
7
|
+
OrHash =
|
8
|
+
T.type_alias do
|
9
|
+
T.any(
|
10
|
+
OpenAI::Chat::ChatCompletionAllowedTools,
|
11
|
+
OpenAI::Internal::AnyHash
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Constrains the tools available to the model to a pre-defined set.
|
16
|
+
#
|
17
|
+
# `auto` allows the model to pick from among the allowed tools and generate a
|
18
|
+
# message.
|
19
|
+
#
|
20
|
+
# `required` requires the model to call one or more of the allowed tools.
|
21
|
+
sig do
|
22
|
+
returns(OpenAI::Chat::ChatCompletionAllowedTools::Mode::OrSymbol)
|
23
|
+
end
|
24
|
+
attr_accessor :mode
|
25
|
+
|
26
|
+
# A list of tool definitions that the model should be allowed to call.
|
27
|
+
#
|
28
|
+
# For the Chat Completions API, the list of tool definitions might look like:
|
29
|
+
#
|
30
|
+
# ```json
|
31
|
+
# [
|
32
|
+
# { "type": "function", "function": { "name": "get_weather" } },
|
33
|
+
# { "type": "function", "function": { "name": "get_time" } }
|
34
|
+
# ]
|
35
|
+
# ```
|
36
|
+
sig { returns(T::Array[T::Hash[Symbol, T.anything]]) }
|
37
|
+
attr_accessor :tools
|
38
|
+
|
39
|
+
# Constrains the tools available to the model to a pre-defined set.
|
40
|
+
sig do
|
41
|
+
params(
|
42
|
+
mode: OpenAI::Chat::ChatCompletionAllowedTools::Mode::OrSymbol,
|
43
|
+
tools: T::Array[T::Hash[Symbol, T.anything]]
|
44
|
+
).returns(T.attached_class)
|
45
|
+
end
|
46
|
+
def self.new(
|
47
|
+
# Constrains the tools available to the model to a pre-defined set.
|
48
|
+
#
|
49
|
+
# `auto` allows the model to pick from among the allowed tools and generate a
|
50
|
+
# message.
|
51
|
+
#
|
52
|
+
# `required` requires the model to call one or more of the allowed tools.
|
53
|
+
mode:,
|
54
|
+
# A list of tool definitions that the model should be allowed to call.
|
55
|
+
#
|
56
|
+
# For the Chat Completions API, the list of tool definitions might look like:
|
57
|
+
#
|
58
|
+
# ```json
|
59
|
+
# [
|
60
|
+
# { "type": "function", "function": { "name": "get_weather" } },
|
61
|
+
# { "type": "function", "function": { "name": "get_time" } }
|
62
|
+
# ]
|
63
|
+
# ```
|
64
|
+
tools:
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
sig do
|
69
|
+
override.returns(
|
70
|
+
{
|
71
|
+
mode: OpenAI::Chat::ChatCompletionAllowedTools::Mode::OrSymbol,
|
72
|
+
tools: T::Array[T::Hash[Symbol, T.anything]]
|
73
|
+
}
|
74
|
+
)
|
75
|
+
end
|
76
|
+
def to_hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# Constrains the tools available to the model to a pre-defined set.
|
80
|
+
#
|
81
|
+
# `auto` allows the model to pick from among the allowed tools and generate a
|
82
|
+
# message.
|
83
|
+
#
|
84
|
+
# `required` requires the model to call one or more of the allowed tools.
|
85
|
+
module Mode
|
86
|
+
extend OpenAI::Internal::Type::Enum
|
87
|
+
|
88
|
+
TaggedSymbol =
|
89
|
+
T.type_alias do
|
90
|
+
T.all(Symbol, OpenAI::Chat::ChatCompletionAllowedTools::Mode)
|
91
|
+
end
|
92
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
93
|
+
|
94
|
+
AUTO =
|
95
|
+
T.let(
|
96
|
+
:auto,
|
97
|
+
OpenAI::Chat::ChatCompletionAllowedTools::Mode::TaggedSymbol
|
98
|
+
)
|
99
|
+
REQUIRED =
|
100
|
+
T.let(
|
101
|
+
:required,
|
102
|
+
OpenAI::Chat::ChatCompletionAllowedTools::Mode::TaggedSymbol
|
103
|
+
)
|
104
|
+
|
105
|
+
sig do
|
106
|
+
override.returns(
|
107
|
+
T::Array[
|
108
|
+
OpenAI::Chat::ChatCompletionAllowedTools::Mode::TaggedSymbol
|
109
|
+
]
|
110
|
+
)
|
111
|
+
end
|
112
|
+
def self.values
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -85,7 +85,14 @@ module OpenAI
|
|
85
85
|
# The tool calls generated by the model, such as function calls.
|
86
86
|
sig do
|
87
87
|
returns(
|
88
|
-
T.nilable(
|
88
|
+
T.nilable(
|
89
|
+
T::Array[
|
90
|
+
T.any(
|
91
|
+
OpenAI::Chat::ChatCompletionMessageFunctionToolCall,
|
92
|
+
OpenAI::Chat::ChatCompletionMessageCustomToolCall
|
93
|
+
)
|
94
|
+
]
|
95
|
+
)
|
89
96
|
)
|
90
97
|
end
|
91
98
|
attr_reader :tool_calls
|
@@ -93,7 +100,12 @@ module OpenAI
|
|
93
100
|
sig do
|
94
101
|
params(
|
95
102
|
tool_calls:
|
96
|
-
T::Array[
|
103
|
+
T::Array[
|
104
|
+
T.any(
|
105
|
+
OpenAI::Chat::ChatCompletionMessageFunctionToolCall::OrHash,
|
106
|
+
OpenAI::Chat::ChatCompletionMessageCustomToolCall::OrHash
|
107
|
+
)
|
108
|
+
]
|
97
109
|
).void
|
98
110
|
end
|
99
111
|
attr_writer :tool_calls
|
@@ -116,7 +128,12 @@ module OpenAI
|
|
116
128
|
name: String,
|
117
129
|
refusal: T.nilable(String),
|
118
130
|
tool_calls:
|
119
|
-
T::Array[
|
131
|
+
T::Array[
|
132
|
+
T.any(
|
133
|
+
OpenAI::Chat::ChatCompletionMessageFunctionToolCall::OrHash,
|
134
|
+
OpenAI::Chat::ChatCompletionMessageCustomToolCall::OrHash
|
135
|
+
)
|
136
|
+
],
|
120
137
|
role: Symbol
|
121
138
|
).returns(T.attached_class)
|
122
139
|
end
|
@@ -160,7 +177,13 @@ module OpenAI
|
|
160
177
|
),
|
161
178
|
name: String,
|
162
179
|
refusal: T.nilable(String),
|
163
|
-
tool_calls:
|
180
|
+
tool_calls:
|
181
|
+
T::Array[
|
182
|
+
T.any(
|
183
|
+
OpenAI::Chat::ChatCompletionMessageFunctionToolCall,
|
184
|
+
OpenAI::Chat::ChatCompletionMessageCustomToolCall
|
185
|
+
)
|
186
|
+
]
|
164
187
|
}
|
165
188
|
)
|
166
189
|
end
|
@@ -0,0 +1,335 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module OpenAI
|
4
|
+
module Models
|
5
|
+
ChatCompletionCustomTool = Chat::ChatCompletionCustomTool
|
6
|
+
|
7
|
+
module Chat
|
8
|
+
class ChatCompletionCustomTool < OpenAI::Internal::Type::BaseModel
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
OpenAI::Chat::ChatCompletionCustomTool,
|
13
|
+
OpenAI::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Properties of the custom tool.
|
18
|
+
sig { returns(OpenAI::Chat::ChatCompletionCustomTool::Custom) }
|
19
|
+
attr_reader :custom
|
20
|
+
|
21
|
+
sig do
|
22
|
+
params(
|
23
|
+
custom: OpenAI::Chat::ChatCompletionCustomTool::Custom::OrHash
|
24
|
+
).void
|
25
|
+
end
|
26
|
+
attr_writer :custom
|
27
|
+
|
28
|
+
# The type of the custom tool. Always `custom`.
|
29
|
+
sig { returns(Symbol) }
|
30
|
+
attr_accessor :type
|
31
|
+
|
32
|
+
# A custom tool that processes input using a specified format.
|
33
|
+
sig do
|
34
|
+
params(
|
35
|
+
custom: OpenAI::Chat::ChatCompletionCustomTool::Custom::OrHash,
|
36
|
+
type: Symbol
|
37
|
+
).returns(T.attached_class)
|
38
|
+
end
|
39
|
+
def self.new(
|
40
|
+
# Properties of the custom tool.
|
41
|
+
custom:,
|
42
|
+
# The type of the custom tool. Always `custom`.
|
43
|
+
type: :custom
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
sig do
|
48
|
+
override.returns(
|
49
|
+
{
|
50
|
+
custom: OpenAI::Chat::ChatCompletionCustomTool::Custom,
|
51
|
+
type: Symbol
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
def to_hash
|
56
|
+
end
|
57
|
+
|
58
|
+
class Custom < OpenAI::Internal::Type::BaseModel
|
59
|
+
OrHash =
|
60
|
+
T.type_alias do
|
61
|
+
T.any(
|
62
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom,
|
63
|
+
OpenAI::Internal::AnyHash
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
# The name of the custom tool, used to identify it in tool calls.
|
68
|
+
sig { returns(String) }
|
69
|
+
attr_accessor :name
|
70
|
+
|
71
|
+
# Optional description of the custom tool, used to provide more context.
|
72
|
+
sig { returns(T.nilable(String)) }
|
73
|
+
attr_reader :description
|
74
|
+
|
75
|
+
sig { params(description: String).void }
|
76
|
+
attr_writer :description
|
77
|
+
|
78
|
+
# The input format for the custom tool. Default is unconstrained text.
|
79
|
+
sig do
|
80
|
+
returns(
|
81
|
+
T.nilable(
|
82
|
+
T.any(
|
83
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Text,
|
84
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar
|
85
|
+
)
|
86
|
+
)
|
87
|
+
)
|
88
|
+
end
|
89
|
+
attr_reader :format_
|
90
|
+
|
91
|
+
sig do
|
92
|
+
params(
|
93
|
+
format_:
|
94
|
+
T.any(
|
95
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Text::OrHash,
|
96
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::OrHash
|
97
|
+
)
|
98
|
+
).void
|
99
|
+
end
|
100
|
+
attr_writer :format_
|
101
|
+
|
102
|
+
# Properties of the custom tool.
|
103
|
+
sig do
|
104
|
+
params(
|
105
|
+
name: String,
|
106
|
+
description: String,
|
107
|
+
format_:
|
108
|
+
T.any(
|
109
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Text::OrHash,
|
110
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::OrHash
|
111
|
+
)
|
112
|
+
).returns(T.attached_class)
|
113
|
+
end
|
114
|
+
def self.new(
|
115
|
+
# The name of the custom tool, used to identify it in tool calls.
|
116
|
+
name:,
|
117
|
+
# Optional description of the custom tool, used to provide more context.
|
118
|
+
description: nil,
|
119
|
+
# The input format for the custom tool. Default is unconstrained text.
|
120
|
+
format_: nil
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
sig do
|
125
|
+
override.returns(
|
126
|
+
{
|
127
|
+
name: String,
|
128
|
+
description: String,
|
129
|
+
format_:
|
130
|
+
T.any(
|
131
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Text,
|
132
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar
|
133
|
+
)
|
134
|
+
}
|
135
|
+
)
|
136
|
+
end
|
137
|
+
def to_hash
|
138
|
+
end
|
139
|
+
|
140
|
+
# The input format for the custom tool. Default is unconstrained text.
|
141
|
+
module Format
|
142
|
+
extend OpenAI::Internal::Type::Union
|
143
|
+
|
144
|
+
Variants =
|
145
|
+
T.type_alias do
|
146
|
+
T.any(
|
147
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Text,
|
148
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
class Text < OpenAI::Internal::Type::BaseModel
|
153
|
+
OrHash =
|
154
|
+
T.type_alias do
|
155
|
+
T.any(
|
156
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Text,
|
157
|
+
OpenAI::Internal::AnyHash
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Unconstrained text format. Always `text`.
|
162
|
+
sig { returns(Symbol) }
|
163
|
+
attr_accessor :type
|
164
|
+
|
165
|
+
# Unconstrained free-form text.
|
166
|
+
sig { params(type: Symbol).returns(T.attached_class) }
|
167
|
+
def self.new(
|
168
|
+
# Unconstrained text format. Always `text`.
|
169
|
+
type: :text
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
sig { override.returns({ type: Symbol }) }
|
174
|
+
def to_hash
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
class Grammar < OpenAI::Internal::Type::BaseModel
|
179
|
+
OrHash =
|
180
|
+
T.type_alias do
|
181
|
+
T.any(
|
182
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar,
|
183
|
+
OpenAI::Internal::AnyHash
|
184
|
+
)
|
185
|
+
end
|
186
|
+
|
187
|
+
# Your chosen grammar.
|
188
|
+
sig do
|
189
|
+
returns(
|
190
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar
|
191
|
+
)
|
192
|
+
end
|
193
|
+
attr_reader :grammar
|
194
|
+
|
195
|
+
sig do
|
196
|
+
params(
|
197
|
+
grammar:
|
198
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::OrHash
|
199
|
+
).void
|
200
|
+
end
|
201
|
+
attr_writer :grammar
|
202
|
+
|
203
|
+
# Grammar format. Always `grammar`.
|
204
|
+
sig { returns(Symbol) }
|
205
|
+
attr_accessor :type
|
206
|
+
|
207
|
+
# A grammar defined by the user.
|
208
|
+
sig do
|
209
|
+
params(
|
210
|
+
grammar:
|
211
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::OrHash,
|
212
|
+
type: Symbol
|
213
|
+
).returns(T.attached_class)
|
214
|
+
end
|
215
|
+
def self.new(
|
216
|
+
# Your chosen grammar.
|
217
|
+
grammar:,
|
218
|
+
# Grammar format. Always `grammar`.
|
219
|
+
type: :grammar
|
220
|
+
)
|
221
|
+
end
|
222
|
+
|
223
|
+
sig do
|
224
|
+
override.returns(
|
225
|
+
{
|
226
|
+
grammar:
|
227
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar,
|
228
|
+
type: Symbol
|
229
|
+
}
|
230
|
+
)
|
231
|
+
end
|
232
|
+
def to_hash
|
233
|
+
end
|
234
|
+
|
235
|
+
class Grammar < OpenAI::Internal::Type::BaseModel
|
236
|
+
OrHash =
|
237
|
+
T.type_alias do
|
238
|
+
T.any(
|
239
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar,
|
240
|
+
OpenAI::Internal::AnyHash
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
# The grammar definition.
|
245
|
+
sig { returns(String) }
|
246
|
+
attr_accessor :definition
|
247
|
+
|
248
|
+
# The syntax of the grammar definition. One of `lark` or `regex`.
|
249
|
+
sig do
|
250
|
+
returns(
|
251
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::Syntax::OrSymbol
|
252
|
+
)
|
253
|
+
end
|
254
|
+
attr_accessor :syntax
|
255
|
+
|
256
|
+
# Your chosen grammar.
|
257
|
+
sig do
|
258
|
+
params(
|
259
|
+
definition: String,
|
260
|
+
syntax:
|
261
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::Syntax::OrSymbol
|
262
|
+
).returns(T.attached_class)
|
263
|
+
end
|
264
|
+
def self.new(
|
265
|
+
# The grammar definition.
|
266
|
+
definition:,
|
267
|
+
# The syntax of the grammar definition. One of `lark` or `regex`.
|
268
|
+
syntax:
|
269
|
+
)
|
270
|
+
end
|
271
|
+
|
272
|
+
sig do
|
273
|
+
override.returns(
|
274
|
+
{
|
275
|
+
definition: String,
|
276
|
+
syntax:
|
277
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::Syntax::OrSymbol
|
278
|
+
}
|
279
|
+
)
|
280
|
+
end
|
281
|
+
def to_hash
|
282
|
+
end
|
283
|
+
|
284
|
+
# The syntax of the grammar definition. One of `lark` or `regex`.
|
285
|
+
module Syntax
|
286
|
+
extend OpenAI::Internal::Type::Enum
|
287
|
+
|
288
|
+
TaggedSymbol =
|
289
|
+
T.type_alias do
|
290
|
+
T.all(
|
291
|
+
Symbol,
|
292
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::Syntax
|
293
|
+
)
|
294
|
+
end
|
295
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
296
|
+
|
297
|
+
LARK =
|
298
|
+
T.let(
|
299
|
+
:lark,
|
300
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::Syntax::TaggedSymbol
|
301
|
+
)
|
302
|
+
REGEX =
|
303
|
+
T.let(
|
304
|
+
:regex,
|
305
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::Syntax::TaggedSymbol
|
306
|
+
)
|
307
|
+
|
308
|
+
sig do
|
309
|
+
override.returns(
|
310
|
+
T::Array[
|
311
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Grammar::Grammar::Syntax::TaggedSymbol
|
312
|
+
]
|
313
|
+
)
|
314
|
+
end
|
315
|
+
def self.values
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
sig do
|
322
|
+
override.returns(
|
323
|
+
T::Array[
|
324
|
+
OpenAI::Chat::ChatCompletionCustomTool::Custom::Format::Variants
|
325
|
+
]
|
326
|
+
)
|
327
|
+
end
|
328
|
+
def self.variants
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module OpenAI
|
4
|
+
module Models
|
5
|
+
ChatCompletionFunctionTool = Chat::ChatCompletionFunctionTool
|
6
|
+
|
7
|
+
module Chat
|
8
|
+
class ChatCompletionFunctionTool < OpenAI::Internal::Type::BaseModel
|
9
|
+
OrHash =
|
10
|
+
T.type_alias do
|
11
|
+
T.any(
|
12
|
+
OpenAI::Chat::ChatCompletionFunctionTool,
|
13
|
+
OpenAI::Internal::AnyHash
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { returns(OpenAI::FunctionDefinition) }
|
18
|
+
attr_reader :function
|
19
|
+
|
20
|
+
sig { params(function: OpenAI::FunctionDefinition::OrHash).void }
|
21
|
+
attr_writer :function
|
22
|
+
|
23
|
+
# The type of the tool. Currently, only `function` is supported.
|
24
|
+
sig { returns(Symbol) }
|
25
|
+
attr_accessor :type
|
26
|
+
|
27
|
+
# A function tool that can be used to generate a response.
|
28
|
+
sig do
|
29
|
+
params(
|
30
|
+
function: OpenAI::FunctionDefinition::OrHash,
|
31
|
+
type: Symbol
|
32
|
+
).returns(T.attached_class)
|
33
|
+
end
|
34
|
+
def self.new(
|
35
|
+
function:,
|
36
|
+
# The type of the tool. Currently, only `function` is supported.
|
37
|
+
type: :function
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
sig do
|
42
|
+
override.returns(
|
43
|
+
{ function: OpenAI::FunctionDefinition, type: Symbol }
|
44
|
+
)
|
45
|
+
end
|
46
|
+
def to_hash
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -78,7 +78,9 @@ module OpenAI
|
|
78
78
|
# The tool calls generated by the model, such as function calls.
|
79
79
|
sig do
|
80
80
|
returns(
|
81
|
-
T.nilable(
|
81
|
+
T.nilable(
|
82
|
+
T::Array[OpenAI::Chat::ChatCompletionMessageToolCall::Variants]
|
83
|
+
)
|
82
84
|
)
|
83
85
|
end
|
84
86
|
attr_reader :tool_calls
|
@@ -86,7 +88,12 @@ module OpenAI
|
|
86
88
|
sig do
|
87
89
|
params(
|
88
90
|
tool_calls:
|
89
|
-
T::Array[
|
91
|
+
T::Array[
|
92
|
+
T.any(
|
93
|
+
OpenAI::Chat::ChatCompletionMessageFunctionToolCall::OrHash,
|
94
|
+
OpenAI::Chat::ChatCompletionMessageCustomToolCall::OrHash
|
95
|
+
)
|
96
|
+
]
|
90
97
|
).void
|
91
98
|
end
|
92
99
|
attr_writer :tool_calls
|
@@ -102,7 +109,12 @@ module OpenAI
|
|
102
109
|
function_call:
|
103
110
|
OpenAI::Chat::ChatCompletionMessage::FunctionCall::OrHash,
|
104
111
|
tool_calls:
|
105
|
-
T::Array[
|
112
|
+
T::Array[
|
113
|
+
T.any(
|
114
|
+
OpenAI::Chat::ChatCompletionMessageFunctionToolCall::OrHash,
|
115
|
+
OpenAI::Chat::ChatCompletionMessageCustomToolCall::OrHash
|
116
|
+
)
|
117
|
+
],
|
106
118
|
role: Symbol
|
107
119
|
).returns(T.attached_class)
|
108
120
|
end
|
@@ -138,7 +150,8 @@ module OpenAI
|
|
138
150
|
T::Array[OpenAI::Chat::ChatCompletionMessage::Annotation],
|
139
151
|
audio: T.nilable(OpenAI::Chat::ChatCompletionAudio),
|
140
152
|
function_call: OpenAI::Chat::ChatCompletionMessage::FunctionCall,
|
141
|
-
tool_calls:
|
153
|
+
tool_calls:
|
154
|
+
T::Array[OpenAI::Chat::ChatCompletionMessageToolCall::Variants]
|
142
155
|
}
|
143
156
|
)
|
144
157
|
end
|