Skip to content

Commit

Permalink
feat(api): add new model and computer-use-2024-10-22 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored and stainless-app[bot] committed Oct 22, 2024
1 parent 36fb9c1 commit b9fa45a
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 23 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: 9
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-b1f4e59681c4caad9ee2926c2e889d673290a831947c91f231ff7a1d5630d208.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-bcf4ba8fcea38089a259c148cdedd0154fa6b4a280c022abf4a038192835cefd.yml
4 changes: 4 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ Types:
- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlockParam</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextDelta</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaTool</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolBash20241022</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoice</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoiceAny</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoiceAuto</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolChoiceTool</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolComputerUse20241022</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolResultBlockParam</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolTextEditor20241022</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUnion</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUseBlock</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUseBlockParam</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaUsage</a></code>
Expand Down
10 changes: 9 additions & 1 deletion src/resources/beta/beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export class Beta extends APIResource {
promptCaching: PromptCachingAPI.PromptCaching = new PromptCachingAPI.PromptCaching(this._client);
}

export type AnthropicBeta = (string & {}) | 'message-batches-2024-09-24' | 'prompt-caching-2024-07-31';
export type AnthropicBeta =
| (string & {})
| 'message-batches-2024-09-24'
| 'prompt-caching-2024-07-31'
| 'computer-use-2024-10-22';

export interface BetaAPIError {
message: string;
Expand Down Expand Up @@ -101,11 +105,15 @@ export namespace Beta {
export import BetaTextBlockParam = MessagesAPI.BetaTextBlockParam;
export import BetaTextDelta = MessagesAPI.BetaTextDelta;
export import BetaTool = MessagesAPI.BetaTool;
export import BetaToolBash20241022 = MessagesAPI.BetaToolBash20241022;
export import BetaToolChoice = MessagesAPI.BetaToolChoice;
export import BetaToolChoiceAny = MessagesAPI.BetaToolChoiceAny;
export import BetaToolChoiceAuto = MessagesAPI.BetaToolChoiceAuto;
export import BetaToolChoiceTool = MessagesAPI.BetaToolChoiceTool;
export import BetaToolComputerUse20241022 = MessagesAPI.BetaToolComputerUse20241022;
export import BetaToolResultBlockParam = MessagesAPI.BetaToolResultBlockParam;
export import BetaToolTextEditor20241022 = MessagesAPI.BetaToolTextEditor20241022;
export import BetaToolUnion = MessagesAPI.BetaToolUnion;
export import BetaToolUseBlock = MessagesAPI.BetaToolUseBlock;
export import BetaToolUseBlockParam = MessagesAPI.BetaToolUseBlockParam;
export import BetaUsage = MessagesAPI.BetaUsage;
Expand Down
4 changes: 4 additions & 0 deletions src/resources/beta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ export {
BetaTextBlockParam,
BetaTextDelta,
BetaTool,
BetaToolBash20241022,
BetaToolChoice,
BetaToolChoiceAny,
BetaToolChoiceAuto,
BetaToolChoiceTool,
BetaToolComputerUse20241022,
BetaToolResultBlockParam,
BetaToolTextEditor20241022,
BetaToolUnion,
BetaToolUseBlock,
BetaToolUseBlockParam,
BetaUsage,
Expand Down
42 changes: 28 additions & 14 deletions src/resources/beta/messages/batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { AnthropicError } from '../../../error';

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

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

/**
* List all Message Batches within a Workspace.
* List all Message Batches within a Workspace. Most recently created batches are
* returned first.
*/
list(
params?: BatchListParams,
Expand All @@ -85,8 +87,15 @@ export class Batches extends APIResource {
}

/**
* Batches may be canceled any time before processing ends. The system may complete
* any in-progress, non-interruptible operations before finalizing cancellation.
* Batches may be canceled any time before processing ends. Once cancellation is
* initiated, the batch enters a `canceling` state, at which time the system may
* complete any in-progress, non-interruptible requests before finalizing
* cancellation.
*
* The number of canceled requests is specified in `request_counts`. To determine
* which requests were canceled, check the individual results within the batch.
* Note that cancellation may not result in any canceled requests if they were
* non-interruptible.
*/
cancel(
messageBatchId: string,
Expand Down Expand Up @@ -168,6 +177,12 @@ export interface BetaMessageBatch {
*/
id: string;

/**
* RFC 3339 datetime string representing the time at which the Message Batch was
* archived and its results became unavailable.
*/
archived_at: string | null;

/**
* RFC 3339 datetime string representing the time at which cancellation was
* initiated for the Message Batch. Specified only if cancellation was initiated.
Expand Down Expand Up @@ -197,16 +212,15 @@ export interface BetaMessageBatch {

/**
* Processing status of the Message Batch.
*
* This is one of: `in_progress`, `canceling`, or `ended`.
*/
processing_status: 'in_progress' | 'canceling' | 'ended';

/**
* Overview of the number of requests within the Message Batch and their statuses.
* Tallies requests within the Message Batch, categorized by their status.
*
* Requests start as `processing` and move to one of the other statuses only once
* processing of entire batch ends.
* processing of the entire batch ends. The sum of all values always matches the
* total number of requests in the batch.
*/
request_counts: BetaMessageBatchRequestCounts;

Expand Down Expand Up @@ -244,7 +258,7 @@ export interface BetaMessageBatchExpiredResult {
export interface BetaMessageBatchIndividualResponse {
/**
* Developer-provided ID created for each request in a Message Batch. Useful for
* matching results to requests.
* matching results to requests, as results may be given out of request order.
*
* Must be unique for each request within the Message Batch.
*/
Expand Down Expand Up @@ -331,7 +345,7 @@ export namespace BatchCreateParams {
export interface Request {
/**
* Developer-provided ID created for each request in a Message Batch. Useful for
* matching results to requests.
* matching results to requests, as results may be given out of request order.
*
* Must be unique for each request within the Message Batch.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/resources/beta/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ export {
BetaTextBlockParam,
BetaTextDelta,
BetaTool,
BetaToolBash20241022,
BetaToolChoice,
BetaToolChoiceAny,
BetaToolChoiceAuto,
BetaToolChoiceTool,
BetaToolComputerUse20241022,
BetaToolResultBlockParam,
BetaToolTextEditor20241022,
BetaToolUnion,
BetaToolUseBlock,
BetaToolUseBlockParam,
BetaUsage,
Expand Down
49 changes: 46 additions & 3 deletions src/resources/beta/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ export interface BetaTool {
* aspects of the tool input JSON schema.
*/
description?: string;

type?: 'custom' | null;
}

export namespace BetaTool {
Expand All @@ -340,6 +342,14 @@ export namespace BetaTool {
}
}

export interface BetaToolBash20241022 {
name: 'bash';

type: 'bash_20241022';

cache_control?: BetaCacheControlEphemeral | null;
}

/**
* How the model should use the provided tools. The model can use a specific tool,
* any available tool, or decide by itself.
Expand Down Expand Up @@ -396,6 +406,20 @@ export interface BetaToolChoiceTool {
disable_parallel_tool_use?: boolean;
}

export interface BetaToolComputerUse20241022 {
display_height_px: number;

display_width_px: number;

name: 'computer';

type: 'computer_20241022';

cache_control?: BetaCacheControlEphemeral | null;

display_number?: number | null;
}

export interface BetaToolResultBlockParam {
tool_use_id: string;

Expand All @@ -408,6 +432,20 @@ export interface BetaToolResultBlockParam {
is_error?: boolean;
}

export interface BetaToolTextEditor20241022 {
name: 'str_replace_editor';

type: 'text_editor_20241022';

cache_control?: BetaCacheControlEphemeral | null;
}

export type BetaToolUnion =
| BetaTool
| BetaToolComputerUse20241022
| BetaToolBash20241022
| BetaToolTextEditor20241022;

export interface BetaToolUseBlock {
id: string;

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

/**
* Body param: Only sample from the top K options for each subsequent token.
Expand Down Expand Up @@ -766,11 +805,15 @@ export namespace Messages {
export import BetaTextBlockParam = MessagesMessagesAPI.BetaTextBlockParam;
export import BetaTextDelta = MessagesMessagesAPI.BetaTextDelta;
export import BetaTool = MessagesMessagesAPI.BetaTool;
export import BetaToolBash20241022 = MessagesMessagesAPI.BetaToolBash20241022;
export import BetaToolChoice = MessagesMessagesAPI.BetaToolChoice;
export import BetaToolChoiceAny = MessagesMessagesAPI.BetaToolChoiceAny;
export import BetaToolChoiceAuto = MessagesMessagesAPI.BetaToolChoiceAuto;
export import BetaToolChoiceTool = MessagesMessagesAPI.BetaToolChoiceTool;
export import BetaToolComputerUse20241022 = MessagesMessagesAPI.BetaToolComputerUse20241022;
export import BetaToolResultBlockParam = MessagesMessagesAPI.BetaToolResultBlockParam;
export import BetaToolTextEditor20241022 = MessagesMessagesAPI.BetaToolTextEditor20241022;
export import BetaToolUnion = MessagesMessagesAPI.BetaToolUnion;
export import BetaToolUseBlock = MessagesMessagesAPI.BetaToolUseBlock;
export import BetaToolUseBlockParam = MessagesMessagesAPI.BetaToolUseBlockParam;
export import BetaUsage = MessagesMessagesAPI.BetaUsage;
Expand Down
5 changes: 3 additions & 2 deletions src/resources/beta/prompt-caching/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,12 @@ export interface MessageCreateParamsBase {
* Our models are trained to operate on alternating `user` and `assistant`
* conversational turns. When creating a new `Message`, you specify the prior
* conversational turns with the `messages` parameter, and the model then generates
* the next `Message` in the conversation.
* the next `Message` in the conversation. Consecutive `user` or `assistant` turns
* in your request will be combined into a single turn.
*
* Each input message must be an object with a `role` and `content`. You can
* specify a single `user`-role message, or you can include multiple `user` and
* `assistant` messages. The first message must always use the `user` role.
* `assistant` messages.
*
* If the final message uses the `assistant` role, the response content will
* continue immediately from the content in that message. This can be used to
Expand Down
8 changes: 6 additions & 2 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ export interface Metadata {
*/
export type Model =
| (string & {})
| 'claude-3-5-sonnet-latest'
| 'claude-3-5-sonnet-20241022'
| 'claude-3-5-sonnet-20240620'
| 'claude-3-opus-latest'
| 'claude-3-opus-20240229'
| 'claude-3-sonnet-20240229'
| 'claude-3-haiku-20240307'
Expand Down Expand Up @@ -492,11 +495,12 @@ export interface MessageCreateParamsBase {
* Our models are trained to operate on alternating `user` and `assistant`
* conversational turns. When creating a new `Message`, you specify the prior
* conversational turns with the `messages` parameter, and the model then generates
* the next `Message` in the conversation.
* the next `Message` in the conversation. Consecutive `user` or `assistant` turns
* in your request will be combined into a single turn.
*
* Each input message must be an object with a `role` and `content`. You can
* specify a single `user`-role message, or you can include multiple `user` and
* `assistant` messages. The first message must always use the `user` role.
* `assistant` messages.
*
* If the final message uses the `assistant` role, the response content will
* continue immediately from the content in that message. This can be used to
Expand Down
Loading

0 comments on commit b9fa45a

Please sign in to comment.