Skip to content

Commit

Permalink
feat(api): add message token counting & PDFs support (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Nov 1, 2024
1 parent 029e485 commit affdd31
Show file tree
Hide file tree
Showing 12 changed files with 390 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .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-134649e8f68418dc1cde6589ef6c63f79f65d8cbcc8732a6652354ade6548d16.yml
configured_endpoints: 10
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-d95f5b98650cf1d0a75bd514eaa6705bef41aa89e8fe37e849ccdde57a91aaa2.yml
4 changes: 4 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Types:

Types:

- <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFBlock</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFSource</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheControlEphemeral</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlock</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockParam</a></code>
Expand All @@ -71,6 +73,7 @@ Types:
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMessage</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageDeltaUsage</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageParam</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageTokensCount</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMetadata</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockDeltaEvent</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockStartEvent</a></code>
Expand Down Expand Up @@ -99,6 +102,7 @@ Types:
Methods:

- <code title="post /v1/messages?beta=true">client.beta.messages.<a href="./src/resources/beta/messages/messages.ts">create</a>({ ...params }) -> BetaMessage</code>
- <code title="post /v1/messages/count_tokens?beta=true">client.beta.messages.<a href="./src/resources/beta/messages/messages.ts">countTokens</a>({ ...params }) -> BetaMessageTokensCount</code>

### Batches

Expand Down
11 changes: 10 additions & 1 deletion src/resources/beta/beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import { APIResource } from '../../resource';
import * as MessagesAPI from './messages/messages';
import {
BetaBase64PDFBlock,
BetaBase64PDFSource,
BetaCacheControlEphemeral,
BetaContentBlock,
BetaContentBlockParam,
Expand All @@ -11,6 +13,7 @@ import {
BetaMessage,
BetaMessageDeltaUsage,
BetaMessageParam,
BetaMessageTokensCount,
BetaMetadata,
BetaRawContentBlockDeltaEvent,
BetaRawContentBlockStartEvent,
Expand All @@ -35,6 +38,7 @@ import {
BetaToolUseBlock,
BetaToolUseBlockParam,
BetaUsage,
MessageCountTokensParams,
MessageCreateParams,
MessageCreateParamsNonStreaming,
MessageCreateParamsStreaming,
Expand All @@ -52,7 +56,8 @@ export type AnthropicBeta =
| (string & {})
| 'message-batches-2024-09-24'
| 'prompt-caching-2024-07-31'
| 'computer-use-2024-10-22';
| 'computer-use-2024-10-22'
| 'pdfs-2024-09-25';

export interface BetaAPIError {
message: string;
Expand Down Expand Up @@ -130,6 +135,8 @@ export declare namespace Beta {

export {
Messages as Messages,
type BetaBase64PDFBlock as BetaBase64PDFBlock,
type BetaBase64PDFSource as BetaBase64PDFSource,
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
type BetaContentBlock as BetaContentBlock,
type BetaContentBlockParam as BetaContentBlockParam,
Expand All @@ -138,6 +145,7 @@ export declare namespace Beta {
type BetaMessage as BetaMessage,
type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
type BetaMessageParam as BetaMessageParam,
type BetaMessageTokensCount as BetaMessageTokensCount,
type BetaMetadata as BetaMetadata,
type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
Expand Down Expand Up @@ -165,6 +173,7 @@ export declare namespace Beta {
type MessageCreateParams as MessageCreateParams,
type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
type MessageCountTokensParams as MessageCountTokensParams,
};

export { PromptCaching as PromptCaching };
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 @@ -15,6 +15,8 @@ export {
} from './beta';
export {
Messages,
type BetaBase64PDFBlock,
type BetaBase64PDFSource,
type BetaCacheControlEphemeral,
type BetaContentBlock,
type BetaContentBlockParam,
Expand All @@ -23,6 +25,7 @@ export {
type BetaMessage,
type BetaMessageDeltaUsage,
type BetaMessageParam,
type BetaMessageTokensCount,
type BetaMetadata,
type BetaRawContentBlockDeltaEvent,
type BetaRawContentBlockStartEvent,
Expand Down Expand Up @@ -50,5 +53,6 @@ export {
type MessageCreateParams,
type MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming,
type MessageCountTokensParams,
} from './messages/index';
export { PromptCaching } from './prompt-caching/index';
4 changes: 4 additions & 0 deletions src/resources/beta/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export {
} from './batches';
export {
Messages,
type BetaBase64PDFBlock,
type BetaBase64PDFSource,
type BetaCacheControlEphemeral,
type BetaContentBlock,
type BetaContentBlockParam,
Expand All @@ -27,6 +29,7 @@ export {
type BetaMessage,
type BetaMessageDeltaUsage,
type BetaMessageParam,
type BetaMessageTokensCount,
type BetaMetadata,
type BetaRawContentBlockDeltaEvent,
type BetaRawContentBlockStartEvent,
Expand Down Expand Up @@ -54,4 +57,5 @@ export {
type MessageCreateParams,
type MessageCreateParamsNonStreaming,
type MessageCreateParamsStreaming,
type MessageCountTokensParams,
} from './messages';
Loading

0 comments on commit affdd31

Please sign in to comment.