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

chore: release main #638

Merged
merged 7 commits into from
Dec 20, 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
6 changes: 3 additions & 3 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
".": "0.33.1",
"packages/vertex-sdk": "0.6.1",
"packages/bedrock-sdk": "0.12.0"
".": "0.34.0",
"packages/vertex-sdk": "0.6.2",
"packages/bedrock-sdk": "0.12.1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 19
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-be055148d227480fcacc9086c37ac8009dcb487731069ada51af35044f65bee4.yml
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fd67aea6883f1ee9e46f31a42d3940f0acb1749e787055bd9b9f278b20fa53ec.yml
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 0.34.0 (2024-12-20)

Full Changelog: [sdk-v0.33.1...sdk-v0.34.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.33.1...sdk-v0.34.0)

### Features

* **api:** add message batch delete endpoint ([#640](https://github.com/anthropics/anthropic-sdk-typescript/issues/640)) ([54f7e1f](https://github.com/anthropics/anthropic-sdk-typescript/commit/54f7e1ffb9a2956ee27a4a715b84717aa681eb7c))


### Bug Fixes

* **client:** normalize method ([#639](https://github.com/anthropics/anthropic-sdk-typescript/issues/639)) ([384bb04](https://github.com/anthropics/anthropic-sdk-typescript/commit/384bb042dd854ed753c6bd8e25f522d0e042bfbf))


### Chores

* bump testing data uri ([#637](https://github.com/anthropics/anthropic-sdk-typescript/issues/637)) ([3f23530](https://github.com/anthropics/anthropic-sdk-typescript/commit/3f23530fb55d9fec7278967ea02600e44e9f58e2))
* **internal:** temporary revert commit ([#643](https://github.com/anthropics/anthropic-sdk-typescript/issues/643)) ([8057b1e](https://github.com/anthropics/anthropic-sdk-typescript/commit/8057b1eb67ccccee042a45f2efe53cccced15682))


### Documentation

* minor formatting changes ([#641](https://github.com/anthropics/anthropic-sdk-typescript/issues/641)) ([8b362ee](https://github.com/anthropics/anthropic-sdk-typescript/commit/8b362ee72954b31b4de920b35aed97255efa5e2e))
* **readme:** add alpha callout ([#646](https://github.com/anthropics/anthropic-sdk-typescript/issues/646)) ([640304c](https://github.com/anthropics/anthropic-sdk-typescript/commit/640304c7c7e8bc67cbf799a646169736d89ad4c8))

## 0.33.1 (2024-12-17)

Full Changelog: [sdk-v0.33.0...sdk-v0.33.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.33.0...sdk-v0.33.1)
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Setting up the environment

This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable).
This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install).
Other package managers may work but are not officially supported for development.

To set up the repository, run:
Expand Down Expand Up @@ -29,10 +29,10 @@ All files in the `examples/` directory are not modified by the generator and can
```

```
chmod +x examples/<your-example>.ts
```sh
$ chmod +x examples/<your-example>.ts
# run the example against your api
yarn tsn -T examples/<your-example>.ts
$ yarn tsn -T examples/<your-example>.ts
```

## Using the repository from source
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
> [!IMPORTANT]
> We're actively working on a new alpha version that migrates from `node-fetch` to builtin fetch.
>
> Please try it out and let us know if you run into any issues!
> https://github.com/anthropics/anthropic-sdk-typescript/issues/645

# Anthropic TypeScript API Library

[![NPM version](https://img.shields.io/npm/v/@anthropic-ai/sdk.svg)](https://npmjs.org/package/@anthropic-ai/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@anthropic-ai/sdk)
Expand Down
4 changes: 4 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Methods:

Types:

- <code><a href="./src/resources/messages/batches.ts">DeletedMessageBatch</a></code>
- <code><a href="./src/resources/messages/batches.ts">MessageBatch</a></code>
- <code><a href="./src/resources/messages/batches.ts">MessageBatchCanceledResult</a></code>
- <code><a href="./src/resources/messages/batches.ts">MessageBatchErroredResult</a></code>
Expand All @@ -84,6 +85,7 @@ Methods:
- <code title="post /v1/messages/batches">client.messages.batches.<a href="./src/resources/messages/batches.ts">create</a>({ ...params }) -> MessageBatch</code>
- <code title="get /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/resources/messages/batches.ts">retrieve</a>(messageBatchId) -> MessageBatch</code>
- <code title="get /v1/messages/batches">client.messages.batches.<a href="./src/resources/messages/batches.ts">list</a>({ ...params }) -> MessageBatchesPage</code>
- <code title="delete /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/resources/messages/batches.ts">delete</a>(messageBatchId) -> DeletedMessageBatch</code>
- <code title="post /v1/messages/batches/{message_batch_id}/cancel">client.messages.batches.<a href="./src/resources/messages/batches.ts">cancel</a>(messageBatchId) -> MessageBatch</code>
- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> Response</code>

Expand Down Expand Up @@ -175,6 +177,7 @@ Methods:

Types:

- <code><a href="./src/resources/beta/messages/batches.ts">BetaDeletedMessageBatch</a></code>
- <code><a href="./src/resources/beta/messages/batches.ts">BetaMessageBatch</a></code>
- <code><a href="./src/resources/beta/messages/batches.ts">BetaMessageBatchCanceledResult</a></code>
- <code><a href="./src/resources/beta/messages/batches.ts">BetaMessageBatchErroredResult</a></code>
Expand All @@ -189,5 +192,6 @@ Methods:
- <code title="post /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">create</a>({ ...params }) -> BetaMessageBatch</code>
- <code title="get /v1/messages/batches/{message_batch_id}?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">retrieve</a>(messageBatchId, { ...params }) -> BetaMessageBatch</code>
- <code title="get /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">list</a>({ ...params }) -> BetaMessageBatchesPage</code>
- <code title="delete /v1/messages/batches/{message_batch_id}?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">delete</a>(messageBatchId, { ...params }) -> BetaDeletedMessageBatch</code>
- <code title="post /v1/messages/batches/{message_batch_id}/cancel?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">cancel</a>(messageBatchId, { ...params }) -> BetaMessageBatch</code>
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">results</a>(messageBatchId, { ...params }) -> Response</code>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anthropic-ai/sdk",
"version": "0.33.1",
"version": "0.34.0",
"description": "The official TypeScript library for the Anthropic API",
"author": "Anthropic <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/bedrock-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.12.1 (2024-12-20)

Full Changelog: [bedrock-sdk-v0.12.0...bedrock-sdk-v0.12.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.0...bedrock-sdk-v0.12.1)

### Chores

* **internal:** temporary revert commit ([#643](https://github.com/anthropics/anthropic-sdk-typescript/issues/643)) ([8057b1e](https://github.com/anthropics/anthropic-sdk-typescript/commit/8057b1eb67ccccee042a45f2efe53cccced15682))

## 0.12.0 (2024-12-17)

Full Changelog: [bedrock-sdk-v0.11.2...bedrock-sdk-v0.12.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.11.2...bedrock-sdk-v0.12.0)
Expand Down
2 changes: 1 addition & 1 deletion packages/bedrock-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anthropic-ai/bedrock-sdk",
"version": "0.12.0",
"version": "0.12.1",
"description": "The official TypeScript library for the Anthropic Bedrock API",
"author": "Anthropic <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/bedrock-sdk/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"@anthropic-ai/sdk@file:../../dist":
# x-release-please-start-version
version "0.33.1"
version "0.34.0"
# x-release-please-end-version
dependencies:
"@types/node" "^18.11.18"
Expand Down
8 changes: 8 additions & 0 deletions packages/vertex-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.6.2 (2024-12-20)

Full Changelog: [vertex-sdk-v0.6.1...vertex-sdk-v0.6.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.1...vertex-sdk-v0.6.2)

### Chores

* **internal:** temporary revert commit ([#643](https://github.com/anthropics/anthropic-sdk-typescript/issues/643)) ([8057b1e](https://github.com/anthropics/anthropic-sdk-typescript/commit/8057b1eb67ccccee042a45f2efe53cccced15682))

## 0.6.1 (2024-12-17)

Full Changelog: [vertex-sdk-v0.6.0...vertex-sdk-v0.6.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.0...vertex-sdk-v0.6.1)
Expand Down
2 changes: 1 addition & 1 deletion packages/vertex-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anthropic-ai/vertex-sdk",
"version": "0.6.1",
"version": "0.6.2",
"description": "The official TypeScript library for the Anthropic Vertex API",
"author": "Anthropic <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/vertex-sdk/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"@anthropic-ai/sdk@file:../../dist":
# x-release-please-start-version
version "0.33.1"
version "0.34.0"
# x-release-please-end-version
dependencies:
"@types/node" "^18.11.18"
Expand Down
12 changes: 11 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,19 @@ export abstract class APIClient {

const timeout = setTimeout(() => controller.abort(), ms);

const fetchOptions = {
signal: controller.signal as any,
...options,
};
if (fetchOptions.method) {
// Custom methods like 'patch' need to be uppercased
// See https://github.com/nodejs/undici/issues/2294
fetchOptions.method = fetchOptions.method.toUpperCase();
}

return (
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
this.fetch.call(undefined, url, { signal: controller.signal as any, ...options }).finally(() => {
this.fetch.call(undefined, url, fetchOptions).finally(() => {
clearTimeout(timeout);
})
);
Expand Down
52 changes: 52 additions & 0 deletions src/resources/beta/messages/batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,35 @@ 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, make a request to the
* `results_url` field in the response.
*/
delete(
messageBatchId: string,
params?: BatchDeleteParams,
options?: Core.RequestOptions,
): Core.APIPromise<BetaDeletedMessageBatch>;
delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<BetaDeletedMessageBatch>;
delete(
messageBatchId: string,
params: BatchDeleteParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<BetaDeletedMessageBatch> {
if (isRequestOptions(params)) {
return this.delete(messageBatchId, {}, params);
}
const { betas } = params;
return this._client.delete(`/v1/messages/batches/${messageBatchId}?beta=true`, {
...options,
headers: {
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
...options?.headers,
},
});
}

/**
* 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
Expand Down Expand Up @@ -168,6 +197,20 @@ export class Batches extends APIResource {

export class BetaMessageBatchesPage extends Page<BetaMessageBatch> {}

export interface BetaDeletedMessageBatch {
/**
* ID of the Message Batch.
*/
id: string;

/**
* Deleted object type.
*
* For Message Batches, this is always `"message_batch_deleted"`.
*/
type: 'message_batch_deleted';
}

export interface BetaMessageBatch {
/**
* Unique object identifier.
Expand Down Expand Up @@ -374,6 +417,13 @@ export interface BatchListParams extends PageParams {
betas?: Array<BetaAPI.AnthropicBeta>;
}

export interface BatchDeleteParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
}

export interface BatchCancelParams {
/**
* Optional header to specify the beta version(s) you want to use.
Expand All @@ -392,6 +442,7 @@ Batches.BetaMessageBatchesPage = BetaMessageBatchesPage;

export declare namespace Batches {
export {
type BetaDeletedMessageBatch as BetaDeletedMessageBatch,
type BetaMessageBatch as BetaMessageBatch,
type BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult as BetaMessageBatchErroredResult,
Expand All @@ -404,6 +455,7 @@ export declare namespace Batches {
type BatchCreateParams as BatchCreateParams,
type BatchRetrieveParams as BatchRetrieveParams,
type BatchListParams as BatchListParams,
type BatchDeleteParams as BatchDeleteParams,
type BatchCancelParams as BatchCancelParams,
type BatchResultsParams as BatchResultsParams,
};
Expand Down
2 changes: 2 additions & 0 deletions src/resources/beta/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export {
BetaMessageBatchesPage,
Batches,
type BetaDeletedMessageBatch,
type BetaMessageBatch,
type BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult,
Expand All @@ -14,6 +15,7 @@ export {
type BatchCreateParams,
type BatchRetrieveParams,
type BatchListParams,
type BatchDeleteParams,
type BatchCancelParams,
type BatchResultsParams,
} from './batches';
Expand Down
4 changes: 4 additions & 0 deletions src/resources/beta/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import * as BatchesAPI from './batches';
import {
BatchCancelParams,
BatchCreateParams,
BatchDeleteParams,
BatchListParams,
BatchResultsParams,
BatchRetrieveParams,
Batches,
BetaDeletedMessageBatch,
BetaMessageBatch,
BetaMessageBatchCanceledResult,
BetaMessageBatchErroredResult,
Expand Down Expand Up @@ -1115,6 +1117,7 @@ export declare namespace Messages {

export {
Batches as Batches,
type BetaDeletedMessageBatch as BetaDeletedMessageBatch,
type BetaMessageBatch as BetaMessageBatch,
type BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult,
type BetaMessageBatchErroredResult as BetaMessageBatchErroredResult,
Expand All @@ -1127,6 +1130,7 @@ export declare namespace Messages {
type BatchCreateParams as BatchCreateParams,
type BatchRetrieveParams as BatchRetrieveParams,
type BatchListParams as BatchListParams,
type BatchDeleteParams as BatchDeleteParams,
type BatchCancelParams as BatchCancelParams,
type BatchResultsParams as BatchResultsParams,
};
Expand Down
24 changes: 24 additions & 0 deletions src/resources/messages/batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export class Batches extends APIResource {
return this._client.getAPIList('/v1/messages/batches', MessageBatchesPage, { query, ...options });
}

/**
* This endpoint is idempotent and can be used to poll for Message Batch
* completion. To access the results of a Message Batch, make a request to the
* `results_url` field in the response.
*/
delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<DeletedMessageBatch> {
return this._client.delete(`/v1/messages/batches/${messageBatchId}`, options);
}

/**
* 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
Expand Down Expand Up @@ -90,6 +99,20 @@ export class Batches extends APIResource {

export class MessageBatchesPage extends Page<MessageBatch> {}

export interface DeletedMessageBatch {
/**
* ID of the Message Batch.
*/
id: string;

/**
* Deleted object type.
*
* For Message Batches, this is always `"message_batch_deleted"`.
*/
type: 'message_batch_deleted';
}

export interface MessageBatch {
/**
* Unique object identifier.
Expand Down Expand Up @@ -283,6 +306,7 @@ Batches.MessageBatchesPage = MessageBatchesPage;

export declare namespace Batches {
export {
type DeletedMessageBatch as DeletedMessageBatch,
type MessageBatch as MessageBatch,
type MessageBatchCanceledResult as MessageBatchCanceledResult,
type MessageBatchErroredResult as MessageBatchErroredResult,
Expand Down
1 change: 1 addition & 0 deletions src/resources/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export {
MessageBatchesPage,
Batches,
type DeletedMessageBatch,
type MessageBatch,
type MessageBatchCanceledResult,
type MessageBatchErroredResult,
Expand Down
2 changes: 2 additions & 0 deletions src/resources/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
BatchCreateParams,
BatchListParams,
Batches,
DeletedMessageBatch,
MessageBatch,
MessageBatchCanceledResult,
MessageBatchErroredResult,
Expand Down Expand Up @@ -1114,6 +1115,7 @@ export declare namespace Messages {

export {
Batches as Batches,
type DeletedMessageBatch as DeletedMessageBatch,
type MessageBatch as MessageBatch,
type MessageBatchCanceledResult as MessageBatchCanceledResult,
type MessageBatchErroredResult as MessageBatchErroredResult,
Expand Down
Loading
Loading