Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add required tool_choice #803

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,9 @@ export interface Run {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down Expand Up @@ -713,8 +714,9 @@ export interface RunCreateParamsBase {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down Expand Up @@ -964,8 +966,9 @@ export interface RunCreateAndPollParams {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down Expand Up @@ -1168,8 +1171,9 @@ export interface RunCreateAndStreamParams {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down Expand Up @@ -1372,8 +1376,9 @@ export interface RunStreamParams {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down
22 changes: 13 additions & 9 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ export interface AssistantToolChoiceFunction {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
export type AssistantToolChoiceOption = 'none' | 'auto' | AssistantToolChoice;
export type AssistantToolChoiceOption = 'none' | 'auto' | 'required' | AssistantToolChoice;

/**
* Represents a thread that contains
Expand Down Expand Up @@ -551,8 +552,9 @@ export interface ThreadCreateAndRunParamsBase {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down Expand Up @@ -900,8 +902,9 @@ export interface ThreadCreateAndRunPollParams {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down Expand Up @@ -1228,8 +1231,9 @@ export interface ThreadCreateAndRunStreamParams {
/**
* Controls which (if any) tool is called by the model. `none` means the model will
* not call any tools and instead generates a message. `auto` is the default value
* and means the model can pick between generating a message or calling a tool.
* Specifying a particular tool like `{"type": "file_search"}` or
* and means the model can pick between generating a message or calling one or more
* tools. `required` means the model must call one or more tools before responding
* to the user. Specifying a particular tool like `{"type": "file_search"}` or
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
* call that tool.
*/
Expand Down
30 changes: 15 additions & 15 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,17 +598,17 @@ export interface ChatCompletionTool {
}

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

export interface ChatCompletionToolMessageParam {
/**
Expand Down Expand Up @@ -796,15 +796,15 @@ export interface ChatCompletionCreateParamsBase {
temperature?: number | null;

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

Expand Down