Skip to content

Commit

Permalink
fix(vertex): add beta.messages.countTokens method
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored and stainless-app[bot] committed Jan 21, 2025
1 parent e670066 commit 2cbeabc
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/vertex-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,17 @@ function makeMessagesResource(client: AnthropicVertex): MessagesResource {
}

/**
* The Vertex API does not currently support prompt caching, token counting or the Batch API.
* The Vertex API does not currently support the Batch API.
*/
type BetaResource = Omit<Resources.Beta, 'promptCaching' | 'messages'> & {
messages: Omit<Resources.Beta['messages'], 'batches' | 'countTokens'>;
type BetaResource = Omit<Resources.Beta, 'messages'> & {
messages: Omit<Resources.Beta['messages'], 'batches'>;
};

function makeBetaResource(client: AnthropicVertex): BetaResource {
const resource = new Resources.Beta(client);

// @ts-expect-error we're deleting non-optional properties
delete resource.promptCaching;

// @ts-expect-error we're deleting non-optional properties
delete resource.messages.batches;

// @ts-expect-error we're deleting non-optional properties
delete resource.messages.countTokens;

return resource;
}

0 comments on commit 2cbeabc

Please sign in to comment.