Skip to content

Commit b9fa45a

Browse files
RobertCraigiestainless-app[bot]
authored andcommitted
feat(api): add new model and computer-use-2024-10-22 beta
https://www.anthropic.com/news/3-5-models-and-computer-use
1 parent 36fb9c1 commit b9fa45a

File tree

11 files changed

+117
-23
lines changed

11 files changed

+117
-23
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 9
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-b1f4e59681c4caad9ee2926c2e889d673290a831947c91f231ff7a1d5630d208.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-bcf4ba8fcea38089a259c148cdedd0154fa6b4a280c022abf4a038192835cefd.yml

api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ Types:
8383
- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlockParam</a></code>
8484
- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextDelta</a></code>
8585
- <code><a href="./src/resources/beta/messages/messages.ts">BetaTool</a></code>
86+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolBash20241022</a></code>
8687
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoice</a></code>
8788
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoiceAny</a></code>
8889
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoiceAuto</a></code>
8990
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoiceTool</a></code>
91+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolComputerUse20241022</a></code>
9092
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolResultBlockParam</a></code>
93+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolTextEditor20241022</a></code>
94+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUnion</a></code>
9195
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUseBlock</a></code>
9296
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUseBlockParam</a></code>
9397
- <code><a href="./src/resources/beta/messages/messages.ts">BetaUsage</a></code>

src/resources/beta/beta.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ export class Beta extends APIResource {
1010
promptCaching: PromptCachingAPI.PromptCaching = new PromptCachingAPI.PromptCaching(this._client);
1111
}
1212

13-
export type AnthropicBeta = (string & {}) | 'message-batches-2024-09-24' | 'prompt-caching-2024-07-31';
13+
export type AnthropicBeta =
14+
| (string & {})
15+
| 'message-batches-2024-09-24'
16+
| 'prompt-caching-2024-07-31'
17+
| 'computer-use-2024-10-22';
1418

1519
export interface BetaAPIError {
1620
message: string;
@@ -101,11 +105,15 @@ export namespace Beta {
101105
export import BetaTextBlockParam = MessagesAPI.BetaTextBlockParam;
102106
export import BetaTextDelta = MessagesAPI.BetaTextDelta;
103107
export import BetaTool = MessagesAPI.BetaTool;
108+
export import BetaToolBash20241022 = MessagesAPI.BetaToolBash20241022;
104109
export import BetaToolChoice = MessagesAPI.BetaToolChoice;
105110
export import BetaToolChoiceAny = MessagesAPI.BetaToolChoiceAny;
106111
export import BetaToolChoiceAuto = MessagesAPI.BetaToolChoiceAuto;
107112
export import BetaToolChoiceTool = MessagesAPI.BetaToolChoiceTool;
113+
export import BetaToolComputerUse20241022 = MessagesAPI.BetaToolComputerUse20241022;
108114
export import BetaToolResultBlockParam = MessagesAPI.BetaToolResultBlockParam;
115+
export import BetaToolTextEditor20241022 = MessagesAPI.BetaToolTextEditor20241022;
116+
export import BetaToolUnion = MessagesAPI.BetaToolUnion;
109117
export import BetaToolUseBlock = MessagesAPI.BetaToolUseBlock;
110118
export import BetaToolUseBlockParam = MessagesAPI.BetaToolUseBlockParam;
111119
export import BetaUsage = MessagesAPI.BetaUsage;

src/resources/beta/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ export {
3434
BetaTextBlockParam,
3535
BetaTextDelta,
3636
BetaTool,
37+
BetaToolBash20241022,
3738
BetaToolChoice,
3839
BetaToolChoiceAny,
3940
BetaToolChoiceAuto,
4041
BetaToolChoiceTool,
42+
BetaToolComputerUse20241022,
4143
BetaToolResultBlockParam,
44+
BetaToolTextEditor20241022,
45+
BetaToolUnion,
4246
BetaToolUseBlock,
4347
BetaToolUseBlockParam,
4448
BetaUsage,

src/resources/beta/messages/batches.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import { AnthropicError } from '../../../error';
1212

1313
export class Batches extends APIResource {
1414
/**
15-
* Send a batch of requests to create Messages.
15+
* Send a batch of Message creation requests.
1616
*
17-
* The Messages Batch API can be used to process multiple Messages API requests at
18-
* once. Once a Message Batch is created, it begins processing immediately.
17+
* The Message Batches API can be used to process multiple Messages API requests at
18+
* once. Once a Message Batch is created, it begins processing immediately. Batches
19+
* can take up to 24 hours to complete.
1920
*/
2021
create(params: BatchCreateParams, options?: Core.RequestOptions): Core.APIPromise<BetaMessageBatch> {
2122
const { betas, ...body } = params;
@@ -31,8 +32,8 @@ export class Batches extends APIResource {
3132

3233
/**
3334
* This endpoint is idempotent and can be used to poll for Message Batch
34-
* completion. To access the results of a Message Batch, use the `responses_url`
35-
* field in the response.
35+
* completion. To access the results of a Message Batch, make a request to the
36+
* `results_url` field in the response.
3637
*/
3738
retrieve(
3839
messageBatchId: string,
@@ -59,7 +60,8 @@ export class Batches extends APIResource {
5960
}
6061

6162
/**
62-
* List all Message Batches within a Workspace.
63+
* List all Message Batches within a Workspace. Most recently created batches are
64+
* returned first.
6365
*/
6466
list(
6567
params?: BatchListParams,
@@ -85,8 +87,15 @@ export class Batches extends APIResource {
8587
}
8688

8789
/**
88-
* Batches may be canceled any time before processing ends. The system may complete
89-
* any in-progress, non-interruptible operations before finalizing cancellation.
90+
* Batches may be canceled any time before processing ends. Once cancellation is
91+
* initiated, the batch enters a `canceling` state, at which time the system may
92+
* complete any in-progress, non-interruptible requests before finalizing
93+
* cancellation.
94+
*
95+
* The number of canceled requests is specified in `request_counts`. To determine
96+
* which requests were canceled, check the individual results within the batch.
97+
* Note that cancellation may not result in any canceled requests if they were
98+
* non-interruptible.
9099
*/
91100
cancel(
92101
messageBatchId: string,
@@ -168,6 +177,12 @@ export interface BetaMessageBatch {
168177
*/
169178
id: string;
170179

180+
/**
181+
* RFC 3339 datetime string representing the time at which the Message Batch was
182+
* archived and its results became unavailable.
183+
*/
184+
archived_at: string | null;
185+
171186
/**
172187
* RFC 3339 datetime string representing the time at which cancellation was
173188
* initiated for the Message Batch. Specified only if cancellation was initiated.
@@ -197,16 +212,15 @@ export interface BetaMessageBatch {
197212

198213
/**
199214
* Processing status of the Message Batch.
200-
*
201-
* This is one of: `in_progress`, `canceling`, or `ended`.
202215
*/
203216
processing_status: 'in_progress' | 'canceling' | 'ended';
204217

205218
/**
206-
* Overview of the number of requests within the Message Batch and their statuses.
219+
* Tallies requests within the Message Batch, categorized by their status.
207220
*
208221
* Requests start as `processing` and move to one of the other statuses only once
209-
* processing of entire batch ends.
222+
* processing of the entire batch ends. The sum of all values always matches the
223+
* total number of requests in the batch.
210224
*/
211225
request_counts: BetaMessageBatchRequestCounts;
212226

@@ -244,7 +258,7 @@ export interface BetaMessageBatchExpiredResult {
244258
export interface BetaMessageBatchIndividualResponse {
245259
/**
246260
* Developer-provided ID created for each request in a Message Batch. Useful for
247-
* matching results to requests.
261+
* matching results to requests, as results may be given out of request order.
248262
*
249263
* Must be unique for each request within the Message Batch.
250264
*/
@@ -331,7 +345,7 @@ export namespace BatchCreateParams {
331345
export interface Request {
332346
/**
333347
* Developer-provided ID created for each request in a Message Batch. Useful for
334-
* matching results to requests.
348+
* matching results to requests, as results may be given out of request order.
335349
*
336350
* Must be unique for each request within the Message Batch.
337351
*/

src/resources/beta/messages/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ export {
2121
BetaTextBlockParam,
2222
BetaTextDelta,
2323
BetaTool,
24+
BetaToolBash20241022,
2425
BetaToolChoice,
2526
BetaToolChoiceAny,
2627
BetaToolChoiceAuto,
2728
BetaToolChoiceTool,
29+
BetaToolComputerUse20241022,
2830
BetaToolResultBlockParam,
31+
BetaToolTextEditor20241022,
32+
BetaToolUnion,
2933
BetaToolUseBlock,
3034
BetaToolUseBlockParam,
3135
BetaUsage,

src/resources/beta/messages/messages.ts

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ export interface BetaTool {
323323
* aspects of the tool input JSON schema.
324324
*/
325325
description?: string;
326+
327+
type?: 'custom' | null;
326328
}
327329

328330
export namespace BetaTool {
@@ -340,6 +342,14 @@ export namespace BetaTool {
340342
}
341343
}
342344

345+
export interface BetaToolBash20241022 {
346+
name: 'bash';
347+
348+
type: 'bash_20241022';
349+
350+
cache_control?: BetaCacheControlEphemeral | null;
351+
}
352+
343353
/**
344354
* How the model should use the provided tools. The model can use a specific tool,
345355
* any available tool, or decide by itself.
@@ -396,6 +406,20 @@ export interface BetaToolChoiceTool {
396406
disable_parallel_tool_use?: boolean;
397407
}
398408

409+
export interface BetaToolComputerUse20241022 {
410+
display_height_px: number;
411+
412+
display_width_px: number;
413+
414+
name: 'computer';
415+
416+
type: 'computer_20241022';
417+
418+
cache_control?: BetaCacheControlEphemeral | null;
419+
420+
display_number?: number | null;
421+
}
422+
399423
export interface BetaToolResultBlockParam {
400424
tool_use_id: string;
401425

@@ -408,6 +432,20 @@ export interface BetaToolResultBlockParam {
408432
is_error?: boolean;
409433
}
410434

435+
export interface BetaToolTextEditor20241022 {
436+
name: 'str_replace_editor';
437+
438+
type: 'text_editor_20241022';
439+
440+
cache_control?: BetaCacheControlEphemeral | null;
441+
}
442+
443+
export type BetaToolUnion =
444+
| BetaTool
445+
| BetaToolComputerUse20241022
446+
| BetaToolBash20241022
447+
| BetaToolTextEditor20241022;
448+
411449
export interface BetaToolUseBlock {
412450
id: string;
413451

@@ -472,11 +510,12 @@ export interface MessageCreateParamsBase {
472510
* Our models are trained to operate on alternating `user` and `assistant`
473511
* conversational turns. When creating a new `Message`, you specify the prior
474512
* conversational turns with the `messages` parameter, and the model then generates
475-
* the next `Message` in the conversation.
513+
* the next `Message` in the conversation. Consecutive `user` or `assistant` turns
514+
* in your request will be combined into a single turn.
476515
*
477516
* Each input message must be an object with a `role` and `content`. You can
478517
* specify a single `user`-role message, or you can include multiple `user` and
479-
* `assistant` messages. The first message must always use the `user` role.
518+
* `assistant` messages.
480519
*
481520
* If the final message uses the `assistant` role, the response content will
482521
* continue immediately from the content in that message. This can be used to
@@ -686,7 +725,7 @@ export interface MessageCreateParamsBase {
686725
*
687726
* See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
688727
*/
689-
tools?: Array<BetaTool>;
728+
tools?: Array<BetaToolUnion>;
690729

691730
/**
692731
* Body param: Only sample from the top K options for each subsequent token.
@@ -766,11 +805,15 @@ export namespace Messages {
766805
export import BetaTextBlockParam = MessagesMessagesAPI.BetaTextBlockParam;
767806
export import BetaTextDelta = MessagesMessagesAPI.BetaTextDelta;
768807
export import BetaTool = MessagesMessagesAPI.BetaTool;
808+
export import BetaToolBash20241022 = MessagesMessagesAPI.BetaToolBash20241022;
769809
export import BetaToolChoice = MessagesMessagesAPI.BetaToolChoice;
770810
export import BetaToolChoiceAny = MessagesMessagesAPI.BetaToolChoiceAny;
771811
export import BetaToolChoiceAuto = MessagesMessagesAPI.BetaToolChoiceAuto;
772812
export import BetaToolChoiceTool = MessagesMessagesAPI.BetaToolChoiceTool;
813+
export import BetaToolComputerUse20241022 = MessagesMessagesAPI.BetaToolComputerUse20241022;
773814
export import BetaToolResultBlockParam = MessagesMessagesAPI.BetaToolResultBlockParam;
815+
export import BetaToolTextEditor20241022 = MessagesMessagesAPI.BetaToolTextEditor20241022;
816+
export import BetaToolUnion = MessagesMessagesAPI.BetaToolUnion;
774817
export import BetaToolUseBlock = MessagesMessagesAPI.BetaToolUseBlock;
775818
export import BetaToolUseBlockParam = MessagesMessagesAPI.BetaToolUseBlockParam;
776819
export import BetaUsage = MessagesMessagesAPI.BetaUsage;

src/resources/beta/prompt-caching/messages.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,12 @@ export interface MessageCreateParamsBase {
323323
* Our models are trained to operate on alternating `user` and `assistant`
324324
* conversational turns. When creating a new `Message`, you specify the prior
325325
* conversational turns with the `messages` parameter, and the model then generates
326-
* the next `Message` in the conversation.
326+
* the next `Message` in the conversation. Consecutive `user` or `assistant` turns
327+
* in your request will be combined into a single turn.
327328
*
328329
* Each input message must be an object with a `role` and `content`. You can
329330
* specify a single `user`-role message, or you can include multiple `user` and
330-
* `assistant` messages. The first message must always use the `user` role.
331+
* `assistant` messages.
331332
*
332333
* If the final message uses the `assistant` role, the response content will
333334
* continue immediately from the content in that message. This can be used to

src/resources/messages.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ export interface Metadata {
229229
*/
230230
export type Model =
231231
| (string & {})
232+
| 'claude-3-5-sonnet-latest'
233+
| 'claude-3-5-sonnet-20241022'
232234
| 'claude-3-5-sonnet-20240620'
235+
| 'claude-3-opus-latest'
233236
| 'claude-3-opus-20240229'
234237
| 'claude-3-sonnet-20240229'
235238
| 'claude-3-haiku-20240307'
@@ -492,11 +495,12 @@ export interface MessageCreateParamsBase {
492495
* Our models are trained to operate on alternating `user` and `assistant`
493496
* conversational turns. When creating a new `Message`, you specify the prior
494497
* conversational turns with the `messages` parameter, and the model then generates
495-
* the next `Message` in the conversation.
498+
* the next `Message` in the conversation. Consecutive `user` or `assistant` turns
499+
* in your request will be combined into a single turn.
496500
*
497501
* Each input message must be an object with a `role` and `content`. You can
498502
* specify a single `user`-role message, or you can include multiple `user` and
499-
* `assistant` messages. The first message must always use the `user` role.
503+
* `assistant` messages.
500504
*
501505
* If the final message uses the `assistant` role, the response content will
502506
* continue immediately from the content in that message. This can be used to

0 commit comments

Comments
 (0)