@llumiverse/drivers 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/anthropic/index.js +64 -0
- package/lib/cjs/anthropic/index.js.map +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/openai/index.js +12 -6
- package/lib/cjs/openai/index.js.map +1 -1
- package/lib/cjs/shared/claude-messages.js +737 -0
- package/lib/cjs/shared/claude-messages.js.map +1 -0
- package/lib/cjs/vertexai/index.js.map +1 -1
- package/lib/cjs/vertexai/models/claude.js +27 -872
- package/lib/cjs/vertexai/models/claude.js.map +1 -1
- package/lib/cjs/vertexai/models/gemini.js +18 -12
- package/lib/cjs/vertexai/models/gemini.js.map +1 -1
- package/lib/esm/anthropic/index.js +57 -0
- package/lib/esm/anthropic/index.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/openai/index.js +12 -7
- package/lib/esm/openai/index.js.map +1 -1
- package/lib/esm/shared/claude-messages.js +716 -0
- package/lib/esm/shared/claude-messages.js.map +1 -0
- package/lib/esm/vertexai/index.js.map +1 -1
- package/lib/esm/vertexai/models/claude.js +27 -865
- package/lib/esm/vertexai/models/claude.js.map +1 -1
- package/lib/esm/vertexai/models/gemini.js +18 -12
- package/lib/esm/vertexai/models/gemini.js.map +1 -1
- package/lib/types/anthropic/index.d.ts +21 -0
- package/lib/types/anthropic/index.d.ts.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/openai/index.d.ts +1 -0
- package/lib/types/openai/index.d.ts.map +1 -1
- package/lib/types/shared/claude-messages.d.ts +75 -0
- package/lib/types/shared/claude-messages.d.ts.map +1 -0
- package/lib/types/vertexai/index.d.ts +4 -4
- package/lib/types/vertexai/index.d.ts.map +1 -1
- package/lib/types/vertexai/models/claude.d.ts +3 -106
- package/lib/types/vertexai/models/claude.d.ts.map +1 -1
- package/lib/types/vertexai/models/gemini.d.ts +1 -1
- package/lib/types/vertexai/models/gemini.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/anthropic/index.ts +104 -0
- package/src/index.ts +1 -0
- package/src/openai/index.ts +13 -8
- package/src/shared/claude-messages.ts +879 -0
- package/src/vertexai/index.ts +18 -19
- package/src/vertexai/models/claude-error-handling.test.ts +3 -3
- package/src/vertexai/models/claude.ts +44 -1016
- package/src/vertexai/models/gemini.ts +27 -14
package/src/vertexai/index.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import type { ClientOptions as AnthropicVertexClientOptions } from "@anthropic-ai/vertex-sdk";
|
|
2
1
|
import { AnthropicVertex } from "@anthropic-ai/vertex-sdk";
|
|
3
2
|
import { PredictionServiceClient, v1beta1 } from "@google-cloud/aiplatform";
|
|
4
|
-
import { Content, GoogleGenAI, Model } from "@google/genai";
|
|
3
|
+
import { type Content, GoogleGenAI, type Model } from "@google/genai";
|
|
5
4
|
import {
|
|
6
|
-
AIModel,
|
|
5
|
+
type AIModel,
|
|
7
6
|
AbstractDriver,
|
|
8
|
-
Completion,
|
|
9
|
-
CompletionChunkObject,
|
|
10
|
-
CompletionResult,
|
|
11
|
-
DriverOptions,
|
|
12
|
-
EmbeddingsOptions,
|
|
13
|
-
EmbeddingsResult,
|
|
14
|
-
ExecutionOptions,
|
|
15
|
-
LlumiverseError,
|
|
16
|
-
LlumiverseErrorContext,
|
|
17
|
-
ModelSearchPayload,
|
|
18
|
-
PromptSegment,
|
|
7
|
+
type Completion,
|
|
8
|
+
type CompletionChunkObject,
|
|
9
|
+
type CompletionResult,
|
|
10
|
+
type DriverOptions,
|
|
11
|
+
type EmbeddingsOptions,
|
|
12
|
+
type EmbeddingsResult,
|
|
13
|
+
type ExecutionOptions,
|
|
14
|
+
type LlumiverseError,
|
|
15
|
+
type LlumiverseErrorContext,
|
|
16
|
+
type ModelSearchPayload,
|
|
17
|
+
type PromptSegment,
|
|
19
18
|
getConversationMeta,
|
|
20
19
|
getModelCapabilities,
|
|
21
20
|
incrementConversationTurn,
|
|
@@ -25,12 +24,12 @@ import {
|
|
|
25
24
|
truncateLargeTextInConversation,
|
|
26
25
|
} from "@llumiverse/core";
|
|
27
26
|
import { FetchClient } from "@vertesia/api-fetch-client";
|
|
28
|
-
import { AuthClient, GoogleAuth, GoogleAuthOptions } from "google-auth-library";
|
|
27
|
+
import { type AuthClient, GoogleAuth, type GoogleAuthOptions } from "google-auth-library";
|
|
29
28
|
import { getEmbeddingsForImages } from "./embeddings/embeddings-image.js";
|
|
30
|
-
import { TextEmbeddingsOptions, getEmbeddingsForText } from "./embeddings/embeddings-text.js";
|
|
29
|
+
import { type TextEmbeddingsOptions, getEmbeddingsForText } from "./embeddings/embeddings-text.js";
|
|
31
30
|
import { getModelDefinition } from "./models.js";
|
|
32
31
|
import { ANTHROPIC_REGIONS, NON_GLOBAL_ANTHROPIC_MODELS } from "./models/claude.js";
|
|
33
|
-
import { ImagenModelDefinition, ImagenPrompt } from "./models/imagen.js";
|
|
32
|
+
import { ImagenModelDefinition, type ImagenPrompt } from "./models/imagen.js";
|
|
34
33
|
|
|
35
34
|
export interface VertexAIDriverOptions extends DriverOptions {
|
|
36
35
|
project: string;
|
|
@@ -173,7 +172,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
173
172
|
timeout: 20 * 60 * 10000, // Set to 20 minutes, 10 minute default, setting this disables long request error: https://github.com/anthropics/anthropic-sdk-typescript?#long-requests
|
|
174
173
|
region: mappedRegion,
|
|
175
174
|
projectId: this.options.project,
|
|
176
|
-
authClient: authClient
|
|
175
|
+
authClient: authClient,
|
|
177
176
|
});
|
|
178
177
|
}
|
|
179
178
|
|
|
@@ -183,7 +182,7 @@ export class VertexAIDriver extends AbstractDriver<VertexAIDriverOptions, Vertex
|
|
|
183
182
|
timeout: 20 * 60 * 10000, // Set to 20 minutes, 10 minute default, setting this disables long request error: https://github.com/anthropics/anthropic-sdk-typescript?#long-requests
|
|
184
183
|
region: mappedRegion,
|
|
185
184
|
projectId: this.options.project,
|
|
186
|
-
authClient: authClient
|
|
185
|
+
authClient: authClient,
|
|
187
186
|
});
|
|
188
187
|
}
|
|
189
188
|
return this.anthropicClient;
|
|
@@ -157,7 +157,7 @@ describe('ClaudeModelDefinition Error Handling', () => {
|
|
|
157
157
|
expect(error.name).toBe('NotFoundError');
|
|
158
158
|
});
|
|
159
159
|
|
|
160
|
-
it('should handle ConflictError as
|
|
160
|
+
it('should handle ConflictError as retryable (lock timeout)', () => {
|
|
161
161
|
const anthropicError = new ConflictError(
|
|
162
162
|
409,
|
|
163
163
|
{ type: 'error', error: { type: 'conflict_error', message: 'Resource conflict' } },
|
|
@@ -172,7 +172,7 @@ describe('ClaudeModelDefinition Error Handling', () => {
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
expect(error.code).toBe(409);
|
|
175
|
-
expect(error.retryable).toBe(
|
|
175
|
+
expect(error.retryable).toBe(true);
|
|
176
176
|
expect(error.name).toBe('ConflictError');
|
|
177
177
|
});
|
|
178
178
|
|
|
@@ -303,6 +303,7 @@ describe('ClaudeModelDefinition Error Handling', () => {
|
|
|
303
303
|
new RateLimitError(429, {}, 'Rate limit', new Headers()),
|
|
304
304
|
new InternalServerError(500, {}, 'Server error', new Headers()),
|
|
305
305
|
new APIConnectionTimeoutError({ message: 'Timeout' }),
|
|
306
|
+
new ConflictError(409, {}, 'Conflict / lock timeout', new Headers()),
|
|
306
307
|
];
|
|
307
308
|
|
|
308
309
|
for (const error of retryableErrors) {
|
|
@@ -317,7 +318,6 @@ describe('ClaudeModelDefinition Error Handling', () => {
|
|
|
317
318
|
new AuthenticationError(401, {}, 'Auth error', new Headers()),
|
|
318
319
|
new PermissionDeniedError(403, {}, 'Permission denied', new Headers()),
|
|
319
320
|
new NotFoundError(404, {}, 'Not found', new Headers()),
|
|
320
|
-
new ConflictError(409, {}, 'Conflict', new Headers()),
|
|
321
321
|
new UnprocessableEntityError(422, {}, 'Validation error', new Headers()),
|
|
322
322
|
];
|
|
323
323
|
|