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): support disabling parallel tool use #540

Merged
merged 1 commit into from
Oct 3, 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
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 3
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fb94a03f85580f7eacef034518becfb463502e6d74b0f7932f6153239de23a5b.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-209cf750b141ebe030a31486ce555fa23b87436cd4235e997b989dfe70dd1b0b.yml
24 changes: 24 additions & 0 deletions src/resources/beta/prompt-caching/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,29 @@ export namespace MessageCreateParams {
*/
export interface ToolChoiceAuto {
type: 'auto';

/**
* Whether to disable parallel tool use.
*
* Defaults to `false`. If set to `true`, the model will output at most one tool
* use.
*/
disable_parallel_tool_use?: boolean;
}

/**
* The model will use any available tools.
*/
export interface ToolChoiceAny {
type: 'any';

/**
* Whether to disable parallel tool use.
*
* Defaults to `false`. If set to `true`, the model will output exactly one tool
* use.
*/
disable_parallel_tool_use?: boolean;
}

/**
Expand All @@ -592,6 +608,14 @@ export namespace MessageCreateParams {
name: string;

type: 'tool';

/**
* Whether to disable parallel tool use.
*
* Defaults to `false`. If set to `true`, the model will output exactly one tool
* use.
*/
disable_parallel_tool_use?: boolean;
}

export type MessageCreateParamsNonStreaming = PromptCachingMessagesAPI.MessageCreateParamsNonStreaming;
Expand Down
24 changes: 24 additions & 0 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,13 +659,29 @@ export namespace MessageCreateParams {
*/
export interface ToolChoiceAuto {
type: 'auto';

/**
* Whether to disable parallel tool use.
*
* Defaults to `false`. If set to `true`, the model will output at most one tool
* use.
*/
disable_parallel_tool_use?: boolean;
}

/**
* The model will use any available tools.
*/
export interface ToolChoiceAny {
type: 'any';

/**
* Whether to disable parallel tool use.
*
* Defaults to `false`. If set to `true`, the model will output exactly one tool
* use.
*/
disable_parallel_tool_use?: boolean;
}

/**
Expand All @@ -678,6 +694,14 @@ export namespace MessageCreateParams {
name: string;

type: 'tool';

/**
* Whether to disable parallel tool use.
*
* Defaults to `false`. If set to `true`, the model will output exactly one tool
* use.
*/
disable_parallel_tool_use?: boolean;
}

export type MessageCreateParamsNonStreaming = MessagesAPI.MessageCreateParamsNonStreaming;
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/beta/prompt-caching/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('resource messages', () => {
stream: false,
system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
temperature: 1,
tool_choice: { type: 'auto' },
tool_choice: { type: 'auto', disable_parallel_tool_use: true },
tools: [
{
input_schema: {
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('resource messages', () => {
stream: false,
system: [{ text: "Today's date is 2024-06-01.", type: 'text' }],
temperature: 1,
tool_choice: { type: 'auto' },
tool_choice: { type: 'auto', disable_parallel_tool_use: true },
tools: [
{
input_schema: {
Expand Down