@llumiverse/drivers 1.0.0-dev.20260202.145450Z → 1.0.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/adobe/firefly.js +120 -0
- package/lib/cjs/adobe/firefly.js.map +1 -0
- package/lib/cjs/azure/azure_foundry.js +432 -0
- package/lib/cjs/azure/azure_foundry.js.map +1 -0
- package/lib/cjs/bedrock/converse.js +359 -0
- package/lib/cjs/bedrock/converse.js.map +1 -0
- package/lib/cjs/bedrock/index.js +1441 -0
- package/lib/cjs/bedrock/index.js.map +1 -0
- package/lib/cjs/bedrock/nova-image-payload.js +207 -0
- package/lib/cjs/bedrock/nova-image-payload.js.map +1 -0
- package/lib/cjs/bedrock/payloads.js +3 -0
- package/lib/cjs/bedrock/payloads.js.map +1 -0
- package/lib/cjs/bedrock/s3.js +107 -0
- package/lib/cjs/bedrock/s3.js.map +1 -0
- package/lib/cjs/bedrock/twelvelabs.js +87 -0
- package/lib/cjs/bedrock/twelvelabs.js.map +1 -0
- package/lib/cjs/groq/index.js +326 -0
- package/lib/cjs/groq/index.js.map +1 -0
- package/lib/cjs/huggingface_ie.js +201 -0
- package/lib/cjs/huggingface_ie.js.map +1 -0
- package/lib/cjs/index.js +31 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/mistral/index.js +176 -0
- package/lib/cjs/mistral/index.js.map +1 -0
- package/lib/cjs/mistral/types.js +83 -0
- package/lib/cjs/mistral/types.js.map +1 -0
- package/lib/cjs/openai/azure_openai.js +72 -0
- package/lib/cjs/openai/azure_openai.js.map +1 -0
- package/lib/cjs/openai/index.js +1100 -0
- package/lib/cjs/openai/index.js.map +1 -0
- package/lib/cjs/openai/openai.js +21 -0
- package/lib/cjs/openai/openai.js.map +1 -0
- package/lib/cjs/openai/openai_compatible.js +63 -0
- package/lib/cjs/openai/openai_compatible.js.map +1 -0
- package/lib/cjs/openai/openai_format.js +131 -0
- package/lib/cjs/openai/openai_format.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/replicate.js +275 -0
- package/lib/cjs/replicate.js.map +1 -0
- package/lib/cjs/test-driver/TestErrorCompletionStream.js +20 -0
- package/lib/cjs/test-driver/TestErrorCompletionStream.js.map +1 -0
- package/lib/cjs/test-driver/TestValidationErrorCompletionStream.js +24 -0
- package/lib/cjs/test-driver/TestValidationErrorCompletionStream.js.map +1 -0
- package/lib/cjs/test-driver/index.js +109 -0
- package/lib/cjs/test-driver/index.js.map +1 -0
- package/lib/cjs/test-driver/utils.js +30 -0
- package/lib/cjs/test-driver/utils.js.map +1 -0
- package/lib/cjs/togetherai/index.js +126 -0
- package/lib/cjs/togetherai/index.js.map +1 -0
- package/lib/cjs/togetherai/interfaces.js +3 -0
- package/lib/cjs/togetherai/interfaces.js.map +1 -0
- package/lib/cjs/vertexai/debug.js +12 -0
- package/lib/cjs/vertexai/debug.js.map +1 -0
- package/lib/cjs/vertexai/embeddings/embeddings-image.js +27 -0
- package/lib/cjs/vertexai/embeddings/embeddings-image.js.map +1 -0
- package/lib/cjs/vertexai/embeddings/embeddings-text.js +23 -0
- package/lib/cjs/vertexai/embeddings/embeddings-text.js.map +1 -0
- package/lib/cjs/vertexai/index.js +635 -0
- package/lib/cjs/vertexai/index.js.map +1 -0
- package/lib/cjs/vertexai/models/claude.js +842 -0
- package/lib/cjs/vertexai/models/claude.js.map +1 -0
- package/lib/cjs/vertexai/models/gemini.js +1110 -0
- package/lib/cjs/vertexai/models/gemini.js.map +1 -0
- package/lib/cjs/vertexai/models/imagen.js +303 -0
- package/lib/cjs/vertexai/models/imagen.js.map +1 -0
- package/lib/cjs/vertexai/models/llama.js +183 -0
- package/lib/cjs/vertexai/models/llama.js.map +1 -0
- package/lib/cjs/vertexai/models.js +35 -0
- package/lib/cjs/vertexai/models.js.map +1 -0
- package/lib/cjs/watsonx/index.js +161 -0
- package/lib/cjs/watsonx/index.js.map +1 -0
- package/lib/cjs/watsonx/interfaces.js +3 -0
- package/lib/cjs/watsonx/interfaces.js.map +1 -0
- package/lib/cjs/xai/index.js +65 -0
- package/lib/cjs/xai/index.js.map +1 -0
- package/lib/esm/adobe/firefly.js +116 -0
- package/lib/esm/adobe/firefly.js.map +1 -0
- package/lib/esm/azure/azure_foundry.js +426 -0
- package/lib/esm/azure/azure_foundry.js.map +1 -0
- package/lib/esm/bedrock/converse.js +352 -0
- package/lib/esm/bedrock/converse.js.map +1 -0
- package/lib/esm/bedrock/index.js +1434 -0
- package/lib/esm/bedrock/index.js.map +1 -0
- package/lib/esm/bedrock/nova-image-payload.js +203 -0
- package/lib/esm/bedrock/nova-image-payload.js.map +1 -0
- package/lib/esm/bedrock/payloads.js +2 -0
- package/lib/esm/bedrock/payloads.js.map +1 -0
- package/lib/esm/bedrock/s3.js +99 -0
- package/lib/esm/bedrock/s3.js.map +1 -0
- package/lib/esm/bedrock/twelvelabs.js +84 -0
- package/lib/esm/bedrock/twelvelabs.js.map +1 -0
- package/lib/esm/groq/index.js +319 -0
- package/lib/esm/groq/index.js.map +1 -0
- package/lib/esm/huggingface_ie.js +197 -0
- package/lib/esm/huggingface_ie.js.map +1 -0
- package/lib/esm/index.js +15 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/mistral/index.js +172 -0
- package/lib/esm/mistral/index.js.map +1 -0
- package/lib/esm/mistral/types.js +80 -0
- package/lib/esm/mistral/types.js.map +1 -0
- package/lib/esm/openai/azure_openai.js +68 -0
- package/lib/esm/openai/azure_openai.js.map +1 -0
- package/lib/esm/openai/index.js +1093 -0
- package/lib/esm/openai/index.js.map +1 -0
- package/lib/esm/openai/openai.js +14 -0
- package/lib/esm/openai/openai.js.map +1 -0
- package/lib/esm/openai/openai_compatible.js +56 -0
- package/lib/esm/openai/openai_compatible.js.map +1 -0
- package/lib/esm/openai/openai_format.js +127 -0
- package/lib/esm/openai/openai_format.js.map +1 -0
- package/lib/esm/replicate.js +268 -0
- package/lib/esm/replicate.js.map +1 -0
- package/lib/esm/test-driver/TestErrorCompletionStream.js +16 -0
- package/lib/esm/test-driver/TestErrorCompletionStream.js.map +1 -0
- package/lib/esm/test-driver/TestValidationErrorCompletionStream.js +20 -0
- package/lib/esm/test-driver/TestValidationErrorCompletionStream.js.map +1 -0
- package/lib/esm/test-driver/index.js +91 -0
- package/lib/esm/test-driver/index.js.map +1 -0
- package/lib/esm/test-driver/utils.js +25 -0
- package/lib/esm/test-driver/utils.js.map +1 -0
- package/lib/esm/togetherai/index.js +122 -0
- package/lib/esm/togetherai/index.js.map +1 -0
- package/lib/esm/togetherai/interfaces.js +2 -0
- package/lib/esm/togetherai/interfaces.js.map +1 -0
- package/lib/esm/vertexai/debug.js +6 -0
- package/lib/esm/vertexai/debug.js.map +1 -0
- package/lib/esm/vertexai/embeddings/embeddings-image.js +24 -0
- package/lib/esm/vertexai/embeddings/embeddings-image.js.map +1 -0
- package/lib/esm/vertexai/embeddings/embeddings-text.js +20 -0
- package/lib/esm/vertexai/embeddings/embeddings-text.js.map +1 -0
- package/lib/esm/vertexai/index.js +630 -0
- package/lib/esm/vertexai/index.js.map +1 -0
- package/lib/esm/vertexai/models/claude.js +833 -0
- package/lib/esm/vertexai/models/claude.js.map +1 -0
- package/lib/esm/vertexai/models/gemini.js +1104 -0
- package/lib/esm/vertexai/models/gemini.js.map +1 -0
- package/lib/esm/vertexai/models/imagen.js +299 -0
- package/lib/esm/vertexai/models/imagen.js.map +1 -0
- package/lib/esm/vertexai/models/llama.js +179 -0
- package/lib/esm/vertexai/models/llama.js.map +1 -0
- package/lib/esm/vertexai/models.js +32 -0
- package/lib/esm/vertexai/models.js.map +1 -0
- package/lib/esm/watsonx/index.js +157 -0
- package/lib/esm/watsonx/index.js.map +1 -0
- package/lib/esm/watsonx/interfaces.js +2 -0
- package/lib/esm/watsonx/interfaces.js.map +1 -0
- package/lib/esm/xai/index.js +58 -0
- package/lib/esm/xai/index.js.map +1 -0
- package/lib/types/adobe/firefly.d.ts +30 -0
- package/lib/types/adobe/firefly.d.ts.map +1 -0
- package/lib/types/azure/azure_foundry.d.ts +52 -0
- package/lib/types/azure/azure_foundry.d.ts.map +1 -0
- package/lib/types/bedrock/converse.d.ts +8 -0
- package/lib/types/bedrock/converse.d.ts.map +1 -0
- package/lib/types/bedrock/index.d.ts +135 -0
- package/lib/types/bedrock/index.d.ts.map +1 -0
- package/lib/types/bedrock/nova-image-payload.d.ts +74 -0
- package/lib/types/bedrock/nova-image-payload.d.ts.map +1 -0
- package/lib/types/bedrock/payloads.d.ts +12 -0
- package/lib/types/bedrock/payloads.d.ts.map +1 -0
- package/lib/types/bedrock/s3.d.ts +23 -0
- package/lib/types/bedrock/s3.d.ts.map +1 -0
- package/lib/types/bedrock/twelvelabs.d.ts +50 -0
- package/lib/types/bedrock/twelvelabs.d.ts.map +1 -0
- package/lib/types/groq/index.d.ts +27 -0
- package/lib/types/groq/index.d.ts.map +1 -0
- package/lib/types/huggingface_ie.d.ts +35 -0
- package/lib/types/huggingface_ie.d.ts.map +1 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/mistral/index.d.ts +25 -0
- package/lib/types/mistral/index.d.ts.map +1 -0
- package/lib/types/mistral/types.d.ts +127 -0
- package/lib/types/mistral/types.d.ts.map +1 -0
- package/lib/types/openai/azure_openai.d.ts +25 -0
- package/lib/types/openai/azure_openai.d.ts.map +1 -0
- package/lib/types/openai/index.d.ts +126 -0
- package/lib/types/openai/index.d.ts.map +1 -0
- package/lib/types/openai/openai.d.ts +15 -0
- package/lib/types/openai/openai.d.ts.map +1 -0
- package/lib/types/openai/openai_compatible.d.ts +31 -0
- package/lib/types/openai/openai_compatible.d.ts.map +1 -0
- package/lib/types/openai/openai_format.d.ts +21 -0
- package/lib/types/openai/openai_format.d.ts.map +1 -0
- package/lib/types/replicate.d.ts +48 -0
- package/lib/types/replicate.d.ts.map +1 -0
- package/lib/types/test-driver/TestErrorCompletionStream.d.ts +9 -0
- package/lib/types/test-driver/TestErrorCompletionStream.d.ts.map +1 -0
- package/lib/types/test-driver/TestValidationErrorCompletionStream.d.ts +9 -0
- package/lib/types/test-driver/TestValidationErrorCompletionStream.d.ts.map +1 -0
- package/lib/types/test-driver/index.d.ts +24 -0
- package/lib/types/test-driver/index.d.ts.map +1 -0
- package/lib/types/test-driver/utils.d.ts +5 -0
- package/lib/types/test-driver/utils.d.ts.map +1 -0
- package/lib/types/togetherai/index.d.ts +23 -0
- package/lib/types/togetherai/index.d.ts.map +1 -0
- package/lib/types/togetherai/interfaces.d.ts +96 -0
- package/lib/types/togetherai/interfaces.d.ts.map +1 -0
- package/lib/types/vertexai/debug.d.ts +2 -0
- package/lib/types/vertexai/debug.d.ts.map +1 -0
- package/lib/types/vertexai/embeddings/embeddings-image.d.ts +11 -0
- package/lib/types/vertexai/embeddings/embeddings-image.d.ts.map +1 -0
- package/lib/types/vertexai/embeddings/embeddings-text.d.ts +10 -0
- package/lib/types/vertexai/embeddings/embeddings-text.d.ts.map +1 -0
- package/lib/types/vertexai/index.d.ts +79 -0
- package/lib/types/vertexai/index.d.ts.map +1 -0
- package/lib/types/vertexai/models/claude.d.ts +103 -0
- package/lib/types/vertexai/models/claude.d.ts.map +1 -0
- package/lib/types/vertexai/models/gemini.d.ts +78 -0
- package/lib/types/vertexai/models/gemini.d.ts.map +1 -0
- package/lib/types/vertexai/models/imagen.d.ts +75 -0
- package/lib/types/vertexai/models/imagen.d.ts.map +1 -0
- package/lib/types/vertexai/models/llama.d.ts +20 -0
- package/lib/types/vertexai/models/llama.d.ts.map +1 -0
- package/lib/types/vertexai/models.d.ts +20 -0
- package/lib/types/vertexai/models.d.ts.map +1 -0
- package/lib/types/watsonx/index.d.ts +27 -0
- package/lib/types/watsonx/index.d.ts.map +1 -0
- package/lib/types/watsonx/interfaces.d.ts +65 -0
- package/lib/types/watsonx/interfaces.d.ts.map +1 -0
- package/lib/types/xai/index.d.ts +18 -0
- package/lib/types/xai/index.d.ts.map +1 -0
- package/package.json +18 -18
- package/src/bedrock/converse.ts +85 -10
- package/src/bedrock/error-handling.test.ts +352 -0
- package/src/bedrock/index.ts +293 -16
- package/src/groq/index.ts +9 -4
- package/src/mistral/index.ts +25 -22
- package/src/mistral/types.ts +0 -5
- package/src/openai/error-handling.test.ts +567 -0
- package/src/openai/index.ts +513 -33
- package/src/openai/openai_compatible.ts +7 -0
- package/src/openai/openai_format.ts +1 -1
- package/src/vertexai/index.ts +61 -13
- package/src/vertexai/models/claude-error-handling.test.ts +432 -0
- package/src/vertexai/models/claude.ts +287 -10
- package/src/vertexai/models/gemini-error-handling.test.ts +353 -0
- package/src/vertexai/models/gemini.ts +329 -52
- package/src/vertexai/models.ts +7 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AIModel, AbstractDriver, Completion, CompletionChunkObject, DriverOptions, EmbeddingsOptions, EmbeddingsResult, ExecutionOptions } from "@llumiverse/core";
|
|
2
|
+
import { FetchClient } from "@vertesia/api-fetch-client";
|
|
3
|
+
import { WatsonAuthToken } from "./interfaces.js";
|
|
4
|
+
interface WatsonxDriverOptions extends DriverOptions {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
projectId: string;
|
|
7
|
+
endpointUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class WatsonxDriver extends AbstractDriver<WatsonxDriverOptions, string> {
|
|
10
|
+
static PROVIDER: string;
|
|
11
|
+
provider: string;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
endpoint_url: string;
|
|
14
|
+
projectId: string;
|
|
15
|
+
authToken?: WatsonAuthToken;
|
|
16
|
+
fetcher?: FetchClient;
|
|
17
|
+
fetchClient: FetchClient;
|
|
18
|
+
constructor(options: WatsonxDriverOptions);
|
|
19
|
+
requestTextCompletion(prompt: string, options: ExecutionOptions): Promise<Completion>;
|
|
20
|
+
requestTextCompletionStream(prompt: string, options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>>;
|
|
21
|
+
listModels(): Promise<AIModel<string>[]>;
|
|
22
|
+
getAuthToken(): Promise<string>;
|
|
23
|
+
validateConnection(): Promise<boolean>;
|
|
24
|
+
generateEmbeddings(options: EmbeddingsOptions): Promise<EmbeddingsResult>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/watsonx/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,qBAAqB,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AAEzL,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAuD,eAAe,EAA2G,MAAM,iBAAiB,CAAC;AAEhN,UAAU,oBAAqB,SAAQ,aAAa;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAID,qBAAa,aAAc,SAAQ,cAAc,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAC3E,MAAM,CAAC,QAAQ,SAAa;IAC5B,QAAQ,SAA0B;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,WAAW,EAAE,WAAW,CAAA;gBAEZ,OAAO,EAAE,oBAAoB;IAQnC,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAmCrF,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAwCrH,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IAoBxC,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAwB/B,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAStC,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAwBlF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface WatsonxTextGenerationPayload {
|
|
2
|
+
model_id: string;
|
|
3
|
+
input: string;
|
|
4
|
+
parameters: {
|
|
5
|
+
max_new_tokens?: number;
|
|
6
|
+
time_limit?: number;
|
|
7
|
+
stop_sequences?: string[];
|
|
8
|
+
temperature?: number;
|
|
9
|
+
top_k?: number;
|
|
10
|
+
top_p?: number;
|
|
11
|
+
};
|
|
12
|
+
project_id: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WatsonxTextGenerationResponse {
|
|
15
|
+
model_id: string;
|
|
16
|
+
created_at: string;
|
|
17
|
+
results: {
|
|
18
|
+
generated_text: string;
|
|
19
|
+
generated_token_count: number;
|
|
20
|
+
input_token_count: number;
|
|
21
|
+
stop_reason: string;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
export interface GenerateEmbeddingPayload {
|
|
25
|
+
model_id: string;
|
|
26
|
+
inputs: string[];
|
|
27
|
+
project_id: string;
|
|
28
|
+
}
|
|
29
|
+
export interface GenerateEmbeddingResponse {
|
|
30
|
+
model_id: string;
|
|
31
|
+
created_at: string;
|
|
32
|
+
results: {
|
|
33
|
+
embedding: number[];
|
|
34
|
+
}[];
|
|
35
|
+
input_token_count: number;
|
|
36
|
+
}
|
|
37
|
+
export interface WatsonxModelSpec {
|
|
38
|
+
model_id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
provider: string;
|
|
41
|
+
source: string;
|
|
42
|
+
short_description: string;
|
|
43
|
+
tasks: {
|
|
44
|
+
id: string;
|
|
45
|
+
ratings: {
|
|
46
|
+
quality: number;
|
|
47
|
+
};
|
|
48
|
+
}[];
|
|
49
|
+
min_shot_size: number;
|
|
50
|
+
tier: string;
|
|
51
|
+
number_params: string;
|
|
52
|
+
}
|
|
53
|
+
export interface WatsonxListModelResponse {
|
|
54
|
+
total_count: number;
|
|
55
|
+
limit: number;
|
|
56
|
+
resources: WatsonxModelSpec[];
|
|
57
|
+
}
|
|
58
|
+
export interface WatsonAuthToken {
|
|
59
|
+
access_token: string;
|
|
60
|
+
refresh_token: string;
|
|
61
|
+
token_type: string;
|
|
62
|
+
expire_in: number;
|
|
63
|
+
expiration: number;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/watsonx/interfaces.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,4BAA4B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACL,cAAc,EAAE,MAAM,CAAC;QACvB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,WAAW,EAAE,MAAM,CAAC;KACvB,EAAE,CAAA;CACN;AAED,MAAM,WAAW,wBAAwB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,yBAAyB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACL,SAAS,EAAE,MAAM,EAAE,CAAC;KACvB,EAAE,CAAA;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE;QACH,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE;YACL,OAAO,EAAE,MAAM,CAAC;SACnB,CAAA;KACJ,EAAE,CAAC;IACJ,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,wBAAwB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAGD,MAAM,WAAW,eAAe;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACrB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AIModel, DriverOptions, PromptOptions, PromptSegment, Providers } from "@llumiverse/core";
|
|
2
|
+
import { FetchClient } from "@vertesia/api-fetch-client";
|
|
3
|
+
import OpenAI from "openai";
|
|
4
|
+
import { BaseOpenAIDriver } from "../openai/index.js";
|
|
5
|
+
export interface xAiDriverOptions extends DriverOptions {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class xAIDriver extends BaseOpenAIDriver {
|
|
10
|
+
service: OpenAI;
|
|
11
|
+
readonly provider = Providers.xai;
|
|
12
|
+
xai_service: FetchClient;
|
|
13
|
+
DEFAULT_ENDPOINT: string;
|
|
14
|
+
constructor(opts: xAiDriverOptions);
|
|
15
|
+
_formatPrompt(segments: PromptSegment[], opts: PromptOptions): Promise<OpenAI.Chat.Completions.ChatCompletionMessageParam[]>;
|
|
16
|
+
listModels(): Promise<AIModel[]>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/xai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IAEnD,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,MAAM,CAAC;CAErB;AAED,qBAAa,SAAU,SAAQ,gBAAgB;IAE3C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,QAAQ,iBAAiB;IAClC,WAAW,EAAE,WAAW,CAAC;IACzB,gBAAgB,SAAyB;gBAE7B,IAAI,EAAE,gBAAgB;IAe5B,aAAa,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE,CAAC;IAkB5H,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CA6BzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llumiverse/drivers",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "LLM driver implementations. Currently supported are: openai, huggingface, bedrock, replicate.",
|
|
6
6
|
"files": [
|
|
@@ -45,36 +45,36 @@
|
|
|
45
45
|
"rimraf": "^6.1.2",
|
|
46
46
|
"ts-dual-module": "^0.6.3",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
|
-
"vitest": "^4.0.
|
|
48
|
+
"vitest": "^4.0.18"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@anthropic-ai/sdk": "^0.
|
|
52
|
-
"@anthropic-ai/vertex-sdk": "^0.14.
|
|
53
|
-
"@aws-sdk/client-bedrock": "^3.
|
|
54
|
-
"@aws-sdk/client-bedrock-runtime": "^3.
|
|
55
|
-
"@aws-sdk/client-s3": "^3.
|
|
56
|
-
"@aws-sdk/credential-providers": "^3.
|
|
57
|
-
"@aws-sdk/lib-storage": "^3.
|
|
58
|
-
"@aws-sdk/types": "^3.
|
|
51
|
+
"@anthropic-ai/sdk": "^0.78.0",
|
|
52
|
+
"@anthropic-ai/vertex-sdk": "^0.14.4",
|
|
53
|
+
"@aws-sdk/client-bedrock": "^3.985.0",
|
|
54
|
+
"@aws-sdk/client-bedrock-runtime": "^3.985.0",
|
|
55
|
+
"@aws-sdk/client-s3": "^3.985.0",
|
|
56
|
+
"@aws-sdk/credential-providers": "^3.985.0",
|
|
57
|
+
"@aws-sdk/lib-storage": "^3.985.0",
|
|
58
|
+
"@aws-sdk/types": "^3.973.1",
|
|
59
59
|
"@azure-rest/ai-inference": "1.0.0-beta.6",
|
|
60
60
|
"@azure/ai-projects": "1.0.0-beta.10",
|
|
61
61
|
"@azure/core-auth": "^1.10.1",
|
|
62
62
|
"@azure/core-sse": "^2.3.0",
|
|
63
63
|
"@azure/identity": "^4.13.0",
|
|
64
64
|
"@azure/openai": "2.0.0",
|
|
65
|
-
"@google-cloud/aiplatform": "^6.
|
|
66
|
-
"@google/genai": "^1.
|
|
67
|
-
"@huggingface/inference": "4.13.
|
|
68
|
-
"@vertesia/api-fetch-client": "^0.
|
|
65
|
+
"@google-cloud/aiplatform": "^6.5.0",
|
|
66
|
+
"@google/genai": "^1.46.0",
|
|
67
|
+
"@huggingface/inference": "4.13.11",
|
|
68
|
+
"@vertesia/api-fetch-client": "^0.82.4",
|
|
69
69
|
"eventsource": "^4.1.0",
|
|
70
70
|
"google-auth-library": "^10.5.0",
|
|
71
71
|
"groq-sdk": "^0.37.0",
|
|
72
72
|
"mnemonist": "^0.40.3",
|
|
73
73
|
"node-web-stream-adapters": "^0.2.1",
|
|
74
|
-
"openai": "^6.
|
|
75
|
-
"replicate": "^1.
|
|
76
|
-
"@llumiverse/common": "1.0.0
|
|
77
|
-
"@llumiverse/core": "1.0.0
|
|
74
|
+
"openai": "^6.22.0",
|
|
75
|
+
"replicate": "^1.4.0",
|
|
76
|
+
"@llumiverse/common": "1.0.0",
|
|
77
|
+
"@llumiverse/core": "1.0.0"
|
|
78
78
|
},
|
|
79
79
|
"ts_dual_module": {
|
|
80
80
|
"outDir": "lib"
|
package/src/bedrock/converse.ts
CHANGED
|
@@ -1,39 +1,110 @@
|
|
|
1
|
-
import { DataSource, ExecutionOptions, readStreamAsString, readStreamAsUint8Array } from "@llumiverse/core";
|
|
2
|
-
import { PromptSegment, PromptRole } from "@llumiverse/core";
|
|
3
1
|
import {
|
|
2
|
+
ContentBlock,
|
|
4
3
|
ConversationRole,
|
|
5
4
|
ConverseRequest,
|
|
6
5
|
Message,
|
|
7
6
|
SystemContentBlock,
|
|
8
|
-
ContentBlock,
|
|
9
7
|
ToolResultContentBlock,
|
|
10
8
|
} from "@aws-sdk/client-bedrock-runtime";
|
|
9
|
+
import { DataSource, ExecutionOptions, PromptRole, PromptSegment, readStreamAsString, readStreamAsUint8Array } from "@llumiverse/core";
|
|
11
10
|
import { parseS3UrlToUri } from "./s3.js";
|
|
12
11
|
|
|
13
12
|
function roleConversion(role: PromptRole): ConversationRole {
|
|
14
13
|
return role === PromptRole.assistant ? ConversationRole.ASSISTANT : ConversationRole.USER;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
type BedrockImageFormat = "png" | "jpeg" | "gif" | "webp";
|
|
17
|
+
const BEDROCK_IMAGE_FORMATS = new Set<string>(["png", "jpeg", "gif", "webp"]);
|
|
18
|
+
const mimeToImageMap: Record<string, BedrockImageFormat> = {
|
|
19
|
+
"image/png": "png",
|
|
20
|
+
"image/jpeg": "jpeg",
|
|
21
|
+
"image/gif": "gif",
|
|
22
|
+
"image/webp": "webp",
|
|
23
|
+
};
|
|
24
|
+
function mimeToImageType(mime: string): BedrockImageFormat {
|
|
25
|
+
const mapped = mimeToImageMap[mime];
|
|
26
|
+
if (mapped) return mapped;
|
|
18
27
|
if (mime.startsWith("image/")) {
|
|
19
|
-
|
|
28
|
+
const subtype = mime.split("/")[1];
|
|
29
|
+
if (subtype && BEDROCK_IMAGE_FORMATS.has(subtype)) {
|
|
30
|
+
return subtype as BedrockImageFormat;
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
33
|
return "png";
|
|
22
34
|
}
|
|
23
35
|
|
|
24
|
-
|
|
36
|
+
type BedrockDocFormat = "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
|
|
37
|
+
const BEDROCK_DOC_FORMATS = new Set<string>(["pdf", "csv", "doc", "docx", "xls", "xlsx", "html", "txt", "md"]);
|
|
38
|
+
const mimeToDocMap: Record<string, BedrockDocFormat> = {
|
|
39
|
+
"application/pdf": "pdf",
|
|
40
|
+
"text/csv": "csv",
|
|
41
|
+
"application/msword": "doc",
|
|
42
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
43
|
+
"application/vnd.ms-excel": "xls",
|
|
44
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
45
|
+
"text/html": "html",
|
|
46
|
+
"text/plain": "txt",
|
|
47
|
+
"text/markdown": "md",
|
|
48
|
+
};
|
|
49
|
+
function mimeToDocType(mime: string): BedrockDocFormat {
|
|
50
|
+
// 1. Exact map lookup (handles complex MIME types like vnd.openxmlformats-*)
|
|
51
|
+
const mapped = mimeToDocMap[mime];
|
|
52
|
+
if (mapped) return mapped;
|
|
53
|
+
// 2. Fallback: extract subtype for simple application/ or text/ MIME types
|
|
25
54
|
if (mime.startsWith("application/") || mime.startsWith("text/")) {
|
|
26
|
-
|
|
55
|
+
const subtype = mime.split("/")[1];
|
|
56
|
+
if (subtype && BEDROCK_DOC_FORMATS.has(subtype)) {
|
|
57
|
+
return subtype as BedrockDocFormat;
|
|
58
|
+
}
|
|
27
59
|
}
|
|
28
60
|
return "txt";
|
|
29
61
|
}
|
|
30
|
-
|
|
62
|
+
type BedrockVideoFormat = "mov" | "mkv" | "mp4" | "webm" | "flv" | "mpeg" | "mpg" | "wmv" | "three_gp";
|
|
63
|
+
const BEDROCK_VIDEO_FORMATS = new Set<string>(["mov", "mkv", "mp4", "webm", "flv", "mpeg", "mpg", "wmv", "three_gp"]);
|
|
64
|
+
const mimeToVideoMap: Record<string, BedrockVideoFormat> = {
|
|
65
|
+
"video/quicktime": "mov",
|
|
66
|
+
"video/x-matroska": "mkv",
|
|
67
|
+
"video/mp4": "mp4",
|
|
68
|
+
"video/webm": "webm",
|
|
69
|
+
"video/x-flv": "flv",
|
|
70
|
+
"video/mpeg": "mpeg",
|
|
71
|
+
"video/x-ms-wmv": "wmv",
|
|
72
|
+
"video/3gpp": "three_gp",
|
|
73
|
+
};
|
|
74
|
+
function mimeToVideoType(mime: string): BedrockVideoFormat {
|
|
75
|
+
const mapped = mimeToVideoMap[mime];
|
|
76
|
+
if (mapped) return mapped;
|
|
31
77
|
if (mime.startsWith("video/")) {
|
|
32
|
-
|
|
78
|
+
const subtype = mime.split("/")[1];
|
|
79
|
+
if (subtype && BEDROCK_VIDEO_FORMATS.has(subtype)) {
|
|
80
|
+
return subtype as BedrockVideoFormat;
|
|
81
|
+
}
|
|
33
82
|
}
|
|
34
83
|
return "mp4";
|
|
35
84
|
}
|
|
36
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Cleans a filename to conform to Bedrock's restrictions:
|
|
88
|
+
* - Alphanumeric characters, whitespace, hyphens, parentheses, square brackets.
|
|
89
|
+
* - No more than one consecutive whitespace character.
|
|
90
|
+
* - Decodes URI components (e.g., %20 -> space).
|
|
91
|
+
*/
|
|
92
|
+
function cleanBedrockFilename(name: string | undefined): string | undefined {
|
|
93
|
+
if (!name) return name;
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
// Decode URI components like %20
|
|
97
|
+
name = decodeURIComponent(name);
|
|
98
|
+
} catch {
|
|
99
|
+
// Ignore decoding errors
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return name
|
|
103
|
+
.replace(/[^\w\s\-()[\]]/g, " ") // Replace invalid characters with space
|
|
104
|
+
.replace(/\s+/g, " ") // Collapse consecutive whitespaces
|
|
105
|
+
.trim();
|
|
106
|
+
}
|
|
107
|
+
|
|
37
108
|
type FileProcessingMode = 'content' | 'tool';
|
|
38
109
|
|
|
39
110
|
async function processFile<T extends FileProcessingMode>(
|
|
@@ -78,7 +149,7 @@ async function processFile<T extends FileProcessingMode>(
|
|
|
78
149
|
const documentBlock = {
|
|
79
150
|
document: {
|
|
80
151
|
format: mimeToDocType(f.mime_type),
|
|
81
|
-
name: f.name,
|
|
152
|
+
name: cleanBedrockFilename(f.name),
|
|
82
153
|
source: { bytes: await readStreamAsUint8Array(source) },
|
|
83
154
|
},
|
|
84
155
|
};
|
|
@@ -235,6 +306,10 @@ export async function formatConversePrompt(segments: PromptSegment[], options: E
|
|
|
235
306
|
for (const file of segment.files ?? []) {
|
|
236
307
|
toolContentBlocks.push(await processFileToToolContentBlock(file));
|
|
237
308
|
}
|
|
309
|
+
// Bedrock requires at least one content block in toolResult
|
|
310
|
+
if (toolContentBlocks.length === 0) {
|
|
311
|
+
toolContentBlocks.push({ text: '[No output]' });
|
|
312
|
+
}
|
|
238
313
|
messages.push({
|
|
239
314
|
content: [{
|
|
240
315
|
toolResult: {
|