From 08a8928fb1fa701f4330720ea2e9d4db81b6b17a Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Tue, 22 Oct 2024 11:44:15 +0100 Subject: [PATCH] feat(vertex): add beta.messages.create() --- packages/vertex-sdk/src/client.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/vertex-sdk/src/client.ts b/packages/vertex-sdk/src/client.ts index 6328d2b3..30258db6 100644 --- a/packages/vertex-sdk/src/client.ts +++ b/packages/vertex-sdk/src/client.ts @@ -83,6 +83,7 @@ export class AnthropicVertex extends Core.APIClient { } messages: Resources.Messages = new Resources.Messages(this); + beta: BetaResource = makeBetaResource(this); protected override defaultQuery(): Core.DefaultQuery | undefined { return this._options.defaultQuery; @@ -142,3 +143,22 @@ export class AnthropicVertex extends Core.APIClient { return super.buildRequest(options); } } + +/** + * The Vertex API does not currently support prompt caching or the Batch API. + */ +type BetaResource = Omit & { + messages: Omit; +}; + +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; + + return resource; +}