Skip to content

Commit

Permalink
feat(api): support disabling parallel tool use (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Oct 4, 2024
1 parent 556d460 commit 4618d3e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
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 @@ -583,13 +583,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 @@ -602,6 +618,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 @@ -690,13 +690,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 @@ -709,6 +725,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

0 comments on commit 4618d3e

Please sign in to comment.