Skip to content

Commit 11d3f0d

Browse files
committed
feat(api): add required tool_choice (#803)
1 parent 75afedc commit 11d3f0d

File tree

3 files changed

+43
-34
lines changed

3 files changed

+43
-34
lines changed

Diff for: src/resources/beta/threads/runs/runs.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,9 @@ export interface Run {
445445
/**
446446
* Controls which (if any) tool is called by the model. `none` means the model will
447447
* not call any tools and instead generates a message. `auto` is the default value
448-
* and means the model can pick between generating a message or calling a tool.
449-
* Specifying a particular tool like `{"type": "file_search"}` or
448+
* and means the model can pick between generating a message or calling one or more
449+
* tools. `required` means the model must call one or more tools before responding
450+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
450451
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
451452
* call that tool.
452453
*/
@@ -713,8 +714,9 @@ export interface RunCreateParamsBase {
713714
/**
714715
* Controls which (if any) tool is called by the model. `none` means the model will
715716
* not call any tools and instead generates a message. `auto` is the default value
716-
* and means the model can pick between generating a message or calling a tool.
717-
* Specifying a particular tool like `{"type": "file_search"}` or
717+
* and means the model can pick between generating a message or calling one or more
718+
* tools. `required` means the model must call one or more tools before responding
719+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
718720
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
719721
* call that tool.
720722
*/
@@ -964,8 +966,9 @@ export interface RunCreateAndPollParams {
964966
/**
965967
* Controls which (if any) tool is called by the model. `none` means the model will
966968
* not call any tools and instead generates a message. `auto` is the default value
967-
* and means the model can pick between generating a message or calling a tool.
968-
* Specifying a particular tool like `{"type": "file_search"}` or
969+
* and means the model can pick between generating a message or calling one or more
970+
* tools. `required` means the model must call one or more tools before responding
971+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
969972
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
970973
* call that tool.
971974
*/
@@ -1168,8 +1171,9 @@ export interface RunCreateAndStreamParams {
11681171
/**
11691172
* Controls which (if any) tool is called by the model. `none` means the model will
11701173
* not call any tools and instead generates a message. `auto` is the default value
1171-
* and means the model can pick between generating a message or calling a tool.
1172-
* Specifying a particular tool like `{"type": "file_search"}` or
1174+
* and means the model can pick between generating a message or calling one or more
1175+
* tools. `required` means the model must call one or more tools before responding
1176+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
11731177
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
11741178
* call that tool.
11751179
*/
@@ -1372,8 +1376,9 @@ export interface RunStreamParams {
13721376
/**
13731377
* Controls which (if any) tool is called by the model. `none` means the model will
13741378
* not call any tools and instead generates a message. `auto` is the default value
1375-
* and means the model can pick between generating a message or calling a tool.
1376-
* Specifying a particular tool like `{"type": "file_search"}` or
1379+
* and means the model can pick between generating a message or calling one or more
1380+
* tools. `required` means the model must call one or more tools before responding
1381+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
13771382
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
13781383
* call that tool.
13791384
*/

Diff for: src/resources/beta/threads/threads.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,13 @@ export interface AssistantToolChoiceFunction {
169169
/**
170170
* Controls which (if any) tool is called by the model. `none` means the model will
171171
* not call any tools and instead generates a message. `auto` is the default value
172-
* and means the model can pick between generating a message or calling a tool.
173-
* Specifying a particular tool like `{"type": "file_search"}` or
172+
* and means the model can pick between generating a message or calling one or more
173+
* tools. `required` means the model must call one or more tools before responding
174+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
174175
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
175176
* call that tool.
176177
*/
177-
export type AssistantToolChoiceOption = 'none' | 'auto' | AssistantToolChoice;
178+
export type AssistantToolChoiceOption = 'none' | 'auto' | 'required' | AssistantToolChoice;
178179

179180
/**
180181
* Represents a thread that contains
@@ -551,8 +552,9 @@ export interface ThreadCreateAndRunParamsBase {
551552
/**
552553
* Controls which (if any) tool is called by the model. `none` means the model will
553554
* not call any tools and instead generates a message. `auto` is the default value
554-
* and means the model can pick between generating a message or calling a tool.
555-
* Specifying a particular tool like `{"type": "file_search"}` or
555+
* and means the model can pick between generating a message or calling one or more
556+
* tools. `required` means the model must call one or more tools before responding
557+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
556558
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
557559
* call that tool.
558560
*/
@@ -900,8 +902,9 @@ export interface ThreadCreateAndRunPollParams {
900902
/**
901903
* Controls which (if any) tool is called by the model. `none` means the model will
902904
* not call any tools and instead generates a message. `auto` is the default value
903-
* and means the model can pick between generating a message or calling a tool.
904-
* Specifying a particular tool like `{"type": "file_search"}` or
905+
* and means the model can pick between generating a message or calling one or more
906+
* tools. `required` means the model must call one or more tools before responding
907+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
905908
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
906909
* call that tool.
907910
*/
@@ -1228,8 +1231,9 @@ export interface ThreadCreateAndRunStreamParams {
12281231
/**
12291232
* Controls which (if any) tool is called by the model. `none` means the model will
12301233
* not call any tools and instead generates a message. `auto` is the default value
1231-
* and means the model can pick between generating a message or calling a tool.
1232-
* Specifying a particular tool like `{"type": "file_search"}` or
1234+
* and means the model can pick between generating a message or calling one or more
1235+
* tools. `required` means the model must call one or more tools before responding
1236+
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
12331237
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
12341238
* call that tool.
12351239
*/

Diff for: src/resources/chat/completions.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,17 @@ export interface ChatCompletionTool {
598598
}
599599

600600
/**
601-
* Controls which (if any) function is called by the model. `none` means the model
602-
* will not call a function and instead generates a message. `auto` means the model
603-
* can pick between generating a message or calling a function. Specifying a
604-
* particular function via
601+
* Controls which (if any) tool is called by the model. `none` means the model will
602+
* not call any tool and instead generates a message. `auto` means the model can
603+
* pick between generating a message or calling one or more tools. `required` means
604+
* the model must call one or more tools. Specifying a particular tool via
605605
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
606-
* call that function.
606+
* call that tool.
607607
*
608-
* `none` is the default when no functions are present. `auto` is the default if
609-
* functions are present.
608+
* `none` is the default when no tools are present. `auto` is the default if tools
609+
* are present.
610610
*/
611-
export type ChatCompletionToolChoiceOption = 'none' | 'auto' | ChatCompletionNamedToolChoice;
611+
export type ChatCompletionToolChoiceOption = 'none' | 'auto' | 'required' | ChatCompletionNamedToolChoice;
612612

613613
export interface ChatCompletionToolMessageParam {
614614
/**
@@ -796,15 +796,15 @@ export interface ChatCompletionCreateParamsBase {
796796
temperature?: number | null;
797797

798798
/**
799-
* Controls which (if any) function is called by the model. `none` means the model
800-
* will not call a function and instead generates a message. `auto` means the model
801-
* can pick between generating a message or calling a function. Specifying a
802-
* particular function via
799+
* Controls which (if any) tool is called by the model. `none` means the model will
800+
* not call any tool and instead generates a message. `auto` means the model can
801+
* pick between generating a message or calling one or more tools. `required` means
802+
* the model must call one or more tools. Specifying a particular tool via
803803
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
804-
* call that function.
804+
* call that tool.
805805
*
806-
* `none` is the default when no functions are present. `auto` is the default if
807-
* functions are present.
806+
* `none` is the default when no tools are present. `auto` is the default if tools
807+
* are present.
808808
*/
809809
tool_choice?: ChatCompletionToolChoiceOption;
810810

0 commit comments

Comments
 (0)