@llumiverse/drivers 0.22.1 → 0.23.0-dev.20251121

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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/lib/esm/src/adobe/firefly.js +2 -2
  3. package/lib/esm/src/adobe/firefly.js.map +1 -1
  4. package/lib/esm/src/azure/azure_foundry.js +11 -11
  5. package/lib/esm/src/azure/azure_foundry.js.map +1 -1
  6. package/lib/esm/src/bedrock/index.js +4 -4
  7. package/lib/esm/src/bedrock/index.js.map +1 -1
  8. package/lib/esm/src/groq/index.js +2 -2
  9. package/lib/esm/src/groq/index.js.map +1 -1
  10. package/lib/esm/src/huggingface_ie.js +2 -2
  11. package/lib/esm/src/huggingface_ie.js.map +1 -1
  12. package/lib/esm/src/mistral/index.js +2 -2
  13. package/lib/esm/src/mistral/index.js.map +1 -1
  14. package/lib/esm/src/openai/azure_openai.js +1 -1
  15. package/lib/esm/src/openai/azure_openai.js.map +1 -1
  16. package/lib/esm/src/openai/index.js +3 -3
  17. package/lib/esm/src/openai/index.js.map +1 -1
  18. package/lib/esm/src/replicate.js +3 -3
  19. package/lib/esm/src/replicate.js.map +1 -1
  20. package/lib/esm/src/togetherai/index.js +2 -2
  21. package/lib/esm/src/togetherai/index.js.map +1 -1
  22. package/lib/esm/src/vertexai/models/claude.js +2 -2
  23. package/lib/esm/src/vertexai/models/claude.js.map +1 -1
  24. package/lib/esm/src/vertexai/models/imagen.js +1 -1
  25. package/lib/esm/src/vertexai/models/imagen.js.map +1 -1
  26. package/lib/esm/src/watsonx/index.js +3 -3
  27. package/lib/esm/src/watsonx/index.js.map +1 -1
  28. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  29. package/lib/types/src/bedrock/nova-image-payload.d.ts +1 -1
  30. package/lib/types/src/huggingface_ie.d.ts +4 -4
  31. package/package.json +85 -85
  32. package/src/adobe/firefly.ts +2 -2
  33. package/src/azure/azure_foundry.ts +11 -11
  34. package/src/bedrock/index.ts +4 -4
  35. package/src/groq/index.ts +2 -2
  36. package/src/huggingface_ie.ts +9 -10
  37. package/src/index.ts +2 -2
  38. package/src/mistral/index.ts +2 -2
  39. package/src/openai/azure_openai.ts +5 -5
  40. package/src/openai/index.ts +3 -3
  41. package/src/replicate.ts +7 -7
  42. package/src/togetherai/index.ts +2 -2
  43. package/src/vertexai/index.ts +41 -37
  44. package/src/vertexai/models/claude.ts +4 -4
  45. package/src/vertexai/models/imagen.ts +4 -4
  46. package/src/watsonx/index.ts +3 -3
  47. /package/src/{test → test-driver}/TestErrorCompletionStream.ts +0 -0
  48. /package/src/{test → test-driver}/TestValidationErrorCompletionStream.ts +0 -0
  49. /package/src/{test → test-driver}/index.ts +0 -0
  50. /package/src/{test → test-driver}/utils.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import { ExecutionOptions } from "@llumiverse/core";
2
2
  import { NovaMessagesPrompt } from "@llumiverse/core/formatters";
3
- export declare function formatNovaImageGenerationPayload(taskType: string, prompt: NovaMessagesPrompt, options: ExecutionOptions): Promise<NovaTextToImagePayload> | Promise<NovaImageVariationPayload> | Promise<NovaColorGuidedGenerationPayload> | Promise<NovaBackgroundRemovalPayload> | Promise<NovaInpaintingPayload> | Promise<NovaOutpaintingPayload>;
3
+ export declare function formatNovaImageGenerationPayload(taskType: string, prompt: NovaMessagesPrompt, options: ExecutionOptions): Promise<NovaTextToImagePayload> | Promise<NovaColorGuidedGenerationPayload> | Promise<NovaImageVariationPayload> | Promise<NovaInpaintingPayload> | Promise<NovaOutpaintingPayload> | Promise<NovaBackgroundRemovalPayload>;
4
4
  export interface InvokeModelPayloadBase {
5
5
  taskType: NovaImageGenerationTaskType;
6
6
  imageGenerationConfig: {
@@ -15,18 +15,18 @@ export declare class HuggingFaceIEDriver extends AbstractDriver<HuggingFaceIEDri
15
15
  url: string;
16
16
  status: string;
17
17
  }>;
18
- getExecutor(model: string): Promise<any>;
18
+ getExecutor(model: string): Promise<InferenceClient>;
19
19
  requestTextCompletionStream(prompt: string, options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>>;
20
20
  requestTextCompletion(prompt: string, options: ExecutionOptions): Promise<{
21
21
  result: {
22
22
  type: "text";
23
- value: any;
23
+ value: string;
24
24
  }[];
25
25
  finish_reason: string;
26
26
  token_usage: {
27
- result: any;
27
+ result: number | undefined;
28
28
  };
29
- original_response: any;
29
+ original_response: import("@huggingface/inference").TextGenerationOutput | undefined;
30
30
  }>;
31
31
  listModels(): Promise<AIModel[]>;
32
32
  validateConnection(): Promise<boolean>;
package/package.json CHANGED
@@ -1,87 +1,87 @@
1
1
  {
2
- "name": "@llumiverse/drivers",
3
- "version": "0.22.1",
4
- "type": "module",
5
- "description": "LLM driver implementations. Currently supported are: openai, huggingface, bedrock, replicate.",
6
- "files": [
7
- "lib",
8
- "src"
9
- ],
2
+ "name": "@llumiverse/drivers",
3
+ "version": "0.23.0-dev.20251121",
4
+ "type": "module",
5
+ "description": "LLM driver implementations. Currently supported are: openai, huggingface, bedrock, replicate.",
6
+ "files": [
7
+ "lib",
8
+ "src"
9
+ ],
10
+ "types": "./lib/types/index.d.ts",
11
+ "exports": {
10
12
  "types": "./lib/types/index.d.ts",
11
- "exports": {
12
- "types": "./lib/types/index.d.ts",
13
- "import": "./lib/esm/index.js",
14
- "require": "./lib/cjs/index.js"
15
- },
16
- "scripts": {
17
- "test": "vitest run --retry 3",
18
- "build": "pnpm exec tsmod build",
19
- "clean": "rimraf ./lib tsconfig.tsbuildinfo"
20
- },
21
- "author": "Llumiverse",
22
- "license": "Apache-2.0",
23
- "homepage": "https://github.com/vertesia/llumiverse",
24
- "repository": {
25
- "type": "git",
26
- "url": "git+ssh://git@github.com/vertesia/llumiverse.git"
27
- },
28
- "keywords": [
29
- "llm",
30
- "ai",
31
- "prompt",
32
- "prompt engineering",
33
- "ml",
34
- "machine learning",
35
- "embeddings",
36
- "training",
37
- "model",
38
- "universal",
39
- "api",
40
- "chatgpt",
41
- "openai",
42
- "vertexai",
43
- "bedrock",
44
- "replicate",
45
- "huggingface",
46
- "togetherai"
47
- ],
48
- "devDependencies": {
49
- "dotenv": "^16.6.1",
50
- "rimraf": "^6.0.1",
51
- "ts-dual-module": "^0.6.3",
52
- "typescript": "^5.9.2",
53
- "vitest": "^3.2.4"
54
- },
55
- "dependencies": {
56
- "@anthropic-ai/sdk": "^0.66.0",
57
- "@anthropic-ai/vertex-sdk": "^0.14.0",
58
- "@aws-sdk/client-bedrock": "^3.840.0",
59
- "@aws-sdk/client-bedrock-runtime": "^3.840.0",
60
- "@aws-sdk/client-s3": "^3.840.0",
61
- "@aws-sdk/credential-providers": "^3.840.0",
62
- "@aws-sdk/lib-storage": "^3.840.0",
63
- "@aws-sdk/types": "^3.840.0",
64
- "@azure-rest/ai-inference": "1.0.0-beta.6",
65
- "@azure/ai-projects": "1.0.0-beta.10",
66
- "@azure/core-auth": "^1.10.0",
67
- "@azure/core-sse": "^2.3.0",
68
- "@azure/identity": "^4.10.1",
69
- "@azure/openai": "2.0.0",
70
- "@google-cloud/aiplatform": "^3.35.0",
71
- "@google/genai": "^1.25.0",
72
- "@huggingface/inference": "2.6.7",
73
- "@llumiverse/common": "workspace:*",
74
- "@llumiverse/core": "workspace:*",
75
- "@vertesia/api-fetch-client": "^0.74.0",
76
- "eventsource": "^4.0.0",
77
- "google-auth-library": "^9.15.1",
78
- "groq-sdk": "^0.34.0",
79
- "mnemonist": "^0.40.3",
80
- "node-web-stream-adapters": "^0.2.1",
81
- "openai": "^4.104.0",
82
- "replicate": "^1.0.1"
83
- },
84
- "ts_dual_module": {
85
- "outDir": "lib"
86
- }
87
- }
13
+ "import": "./lib/esm/index.js",
14
+ "require": "./lib/cjs/index.js"
15
+ },
16
+ "author": "Llumiverse",
17
+ "license": "Apache-2.0",
18
+ "homepage": "https://github.com/vertesia/llumiverse",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+ssh://git@github.com/vertesia/llumiverse.git"
22
+ },
23
+ "keywords": [
24
+ "llm",
25
+ "ai",
26
+ "prompt",
27
+ "prompt engineering",
28
+ "ml",
29
+ "machine learning",
30
+ "embeddings",
31
+ "training",
32
+ "model",
33
+ "universal",
34
+ "api",
35
+ "chatgpt",
36
+ "openai",
37
+ "vertexai",
38
+ "bedrock",
39
+ "replicate",
40
+ "huggingface",
41
+ "togetherai"
42
+ ],
43
+ "devDependencies": {
44
+ "dotenv": "^16.6.1",
45
+ "rimraf": "^6.1.2",
46
+ "ts-dual-module": "^0.6.3",
47
+ "typescript": "^5.9.3",
48
+ "vitest": "^3.2.4"
49
+ },
50
+ "dependencies": {
51
+ "@anthropic-ai/sdk": "^0.68.0",
52
+ "@anthropic-ai/vertex-sdk": "^0.14.0",
53
+ "@aws-sdk/client-bedrock": "^3.922.0",
54
+ "@aws-sdk/client-bedrock-runtime": "^3.922.0",
55
+ "@aws-sdk/client-s3": "^3.922.0",
56
+ "@aws-sdk/credential-providers": "^3.922.0",
57
+ "@aws-sdk/lib-storage": "^3.922.0",
58
+ "@aws-sdk/types": "^3.922.0",
59
+ "@azure-rest/ai-inference": "1.0.0-beta.6",
60
+ "@azure/ai-projects": "1.0.0-beta.10",
61
+ "@azure/core-auth": "^1.10.1",
62
+ "@azure/core-sse": "^2.3.0",
63
+ "@azure/identity": "^4.13.0",
64
+ "@azure/openai": "2.0.0",
65
+ "@google-cloud/aiplatform": "^5.12.0",
66
+ "@google/genai": "^1.28.0",
67
+ "@huggingface/inference": "4.13.0",
68
+ "@vertesia/api-fetch-client": "^0.79.1",
69
+ "eventsource": "^4.1.0",
70
+ "google-auth-library": "^10.5.0",
71
+ "groq-sdk": "^0.34.0",
72
+ "mnemonist": "^0.40.3",
73
+ "node-web-stream-adapters": "^0.2.1",
74
+ "openai": "^4.104.0",
75
+ "replicate": "^1.3.1",
76
+ "@llumiverse/core": "0.23.0-dev.20251121",
77
+ "@llumiverse/common": "0.23.0-dev.20251121"
78
+ },
79
+ "ts_dual_module": {
80
+ "outDir": "lib"
81
+ },
82
+ "scripts": {
83
+ "test": "vitest run --retry 3",
84
+ "build": "pnpm exec tsmod build",
85
+ "clean": "rimraf ./lib tsconfig.tsbuildinfo"
86
+ }
87
+ }
@@ -134,7 +134,7 @@ export class FireflyDriver extends AbstractDriver<FireflyDriverOptions> {
134
134
  };
135
135
 
136
136
  } catch (error: any) {
137
- this.logger.error("[Firefly] Image generation failed", { error });
137
+ this.logger.error({ error }, "[Firefly] Image generation failed");
138
138
  return {
139
139
  result: [],
140
140
  error: {
@@ -188,7 +188,7 @@ export class FireflyDriver extends AbstractDriver<FireflyDriverOptions> {
188
188
  });
189
189
  return response.ok;
190
190
  } catch (error) {
191
- this.logger.error("[Firefly] Connection validation failed", { error });
191
+ this.logger.error({ error }, "[Firefly] Connection validation failed");
192
192
  return false;
193
193
  }
194
194
  }
@@ -54,7 +54,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
54
54
  opts.azureADTokenProvider = new DefaultAzureCredential();
55
55
  }
56
56
  } catch (error) {
57
- this.logger.error("Failed to initialize Azure AD token provider:", error);
57
+ this.logger.error({ error }, "Failed to initialize Azure AD token provider:");
58
58
  throw new Error("Failed to initialize Azure AD token provider");
59
59
  }
60
60
 
@@ -89,7 +89,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
89
89
  deployment = await this.service.deployments.get(deploymentName);
90
90
  this.logger.debug(`[Azure Foundry] Deployment ${deploymentName} found`);
91
91
  } catch (deploymentError) {
92
- this.logger.error(`[Azure Foundry] Deployment ${deploymentName} not found:`, deploymentError);
92
+ this.logger.error({ deploymentError }, `[Azure Foundry] Deployment ${deploymentName} not found:`);
93
93
  }
94
94
 
95
95
  return (deployment as ModelDeployment).modelPublisher == "OpenAI";
@@ -131,7 +131,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
131
131
  }
132
132
  });
133
133
  if (response.status !== "200") {
134
- this.logger.error(`[Azure Foundry] Chat completion request failed:`, response);
134
+ this.logger.error({ response }, `[Azure Foundry] Chat completion request failed:`);
135
135
  throw new Error(`Chat completion request failed with status ${response.status}: ${response.body}`);
136
136
  }
137
137
 
@@ -213,12 +213,12 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
213
213
 
214
214
  yield chunk;
215
215
  } catch (parseError) {
216
- this.logger.warn(`[Azure Foundry] Failed to parse streaming response:`, parseError);
216
+ this.logger.warn({ parseError }, `[Azure Foundry] Failed to parse streaming response:`);
217
217
  continue;
218
218
  }
219
219
  }
220
220
  } catch (error) {
221
- this.logger.error(`[Azure Foundry] Streaming error:`, error);
221
+ this.logger.error({ error }, `[Azure Foundry] Streaming error:`);
222
222
  throw error;
223
223
  }
224
224
  }
@@ -233,7 +233,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
233
233
 
234
234
  const choice = result.choices?.[0];
235
235
  if (!choice) {
236
- this.logger?.error("[Azure Foundry] No choices in response", result);
236
+ this.logger.error({ result }, "[Azure Foundry] No choices in response");
237
237
  throw new Error("No choices in response");
238
238
  }
239
239
 
@@ -241,7 +241,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
241
241
  const toolCalls = choice.message?.tool_calls;
242
242
 
243
243
  if (!data && !toolCalls) {
244
- this.logger?.error("[Azure Foundry] Response is not valid", result);
244
+ this.logger.error({ result }, "[Azure Foundry] Response is not valid");
245
245
  throw new Error("Response is not valid: no content or tool calls");
246
246
  }
247
247
 
@@ -291,7 +291,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
291
291
 
292
292
  return true;
293
293
  } catch (error) {
294
- this.logger.error("Azure Foundry connection validation failed:", error);
294
+ this.logger.error({ error }, "Azure Foundry connection validation failed:");
295
295
  return false;
296
296
  }
297
297
  }
@@ -328,7 +328,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
328
328
  }
329
329
  });
330
330
  } catch (error) {
331
- this.logger.error("Azure Foundry text embeddings error:", error);
331
+ this.logger.error({ error }, "Azure Foundry text embeddings error:");
332
332
  throw error;
333
333
  }
334
334
 
@@ -365,7 +365,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
365
365
  }
366
366
  });
367
367
  } catch (error) {
368
- this.logger.error("Azure Foundry image embeddings error:", error);
368
+ this.logger.error({ error }, "Azure Foundry image embeddings error:");
369
369
  throw error;
370
370
  }
371
371
  if (isUnexpected(response)) {
@@ -395,7 +395,7 @@ export class AzureFoundryDriver extends AbstractDriver<AzureFoundryDriverOptions
395
395
  // List all deployments in the Azure AI Foundry project
396
396
  deploymentsIterable = this.service.deployments.list();
397
397
  } catch (error) {
398
- this.logger.error("Failed to list deployments:", error);
398
+ this.logger.error({ error }, "Failed to list deployments:");
399
399
  throw new Error("Failed to list deployments in Azure AI Foundry project");
400
400
  }
401
401
  const deployments: DeploymentUnion[] = [];
@@ -169,7 +169,7 @@ export class BedrockDriver extends AbstractDriver<BedrockDriverOptions, BedrockP
169
169
  const type = Object.keys(content).find(
170
170
  key => key !== '$unknown' && content[key as keyof typeof content] !== undefined
171
171
  );
172
- this.logger.info("[Bedrock] Unsupported content response type:", type);
172
+ this.logger.info({ type }, "[Bedrock] Unsupported content response type:");
173
173
  }
174
174
  }
175
175
 
@@ -235,7 +235,7 @@ export class BedrockDriver extends AbstractDriver<BedrockDriverOptions, BedrockP
235
235
  const type = Object.keys(delta).find(
236
236
  key => key !== '$unknown' && (delta as any)[key] !== undefined
237
237
  );
238
- this.logger.info("[Bedrock] Unsupported content response type:", type);
238
+ this.logger.info({ type }, "[Bedrock] Unsupported content response type:");
239
239
  }
240
240
  }
241
241
 
@@ -512,7 +512,7 @@ export class BedrockDriver extends AbstractDriver<BedrockDriverOptions, BedrockP
512
512
  });
513
513
 
514
514
  }).catch((err) => {
515
- this.logger.error("[Bedrock] Failed to stream", { error: err });
515
+ this.logger.error({ error: err }, "[Bedrock] Failed to stream");
516
516
  throw err;
517
517
  });
518
518
  }
@@ -673,7 +673,7 @@ export class BedrockDriver extends AbstractDriver<BedrockDriverOptions, BedrockP
673
673
  throw new Error(`Image generation requires image output_modality`);
674
674
  }
675
675
  if (options.model_options?._option_id !== "bedrock-nova-canvas") {
676
- this.logger.warn("Invalid model options", { options: options.model_options });
676
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
677
677
  }
678
678
  const model_options = options.model_options as NovaCanvasOptions;
679
679
 
package/src/groq/index.ts CHANGED
@@ -195,7 +195,7 @@ export class GroqDriver extends AbstractDriver<GroqDriverOptions, ChatCompletion
195
195
 
196
196
  async requestTextCompletion(messages: ChatCompletionMessageParam[], options: ExecutionOptions): Promise<Completion> {
197
197
  if (options.model_options?._option_id !== "text-fallback" && options.model_options?._option_id !== "groq-deepseek-thinking") {
198
- this.logger.warn("Invalid model options", { options: options.model_options });
198
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
199
199
  }
200
200
  options.model_options = options.model_options as TextFallbackOptions;
201
201
 
@@ -251,7 +251,7 @@ export class GroqDriver extends AbstractDriver<GroqDriverOptions, ChatCompletion
251
251
 
252
252
  async requestTextCompletionStream(messages: ChatCompletionMessageParam[], options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>> {
253
253
  if (options.model_options?._option_id !== "text-fallback") {
254
- this.logger.warn("Invalid model options", { options: options.model_options });
254
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
255
255
  }
256
256
  options.model_options = options.model_options as TextFallbackOptions;
257
257
 
@@ -1,7 +1,6 @@
1
1
  import {
2
- HfInference,
3
- HfInferenceEndpoint,
4
- TextGenerationStreamOutput
2
+ InferenceClient,
3
+ TextGenerationStreamOutput,
5
4
  } from "@huggingface/inference";
6
5
  import {
7
6
  AIModel,
@@ -25,7 +24,7 @@ export class HuggingFaceIEDriver extends AbstractDriver<HuggingFaceIEDriverOptio
25
24
  static PROVIDER = "huggingface_ie";
26
25
  provider = HuggingFaceIEDriver.PROVIDER;
27
26
  service: FetchClient;
28
- _executor?: HfInferenceEndpoint;
27
+ _executor?: InferenceClient;
29
28
 
30
29
  constructor(
31
30
  options: HuggingFaceIEDriverOptions
@@ -60,7 +59,8 @@ export class HuggingFaceIEDriver extends AbstractDriver<HuggingFaceIEDriverOptio
60
59
  `Endpoint ${model} is not running - current status: ${endpoint.status}`
61
60
  );
62
61
 
63
- this._executor = new HfInference(this.options.apiKey).endpoint(
62
+ // Use the new InferenceClient and bind it to the endpoint URL
63
+ this._executor = new InferenceClient(this.options.apiKey).endpoint(
64
64
  endpoint.url
65
65
  );
66
66
  }
@@ -69,7 +69,7 @@ export class HuggingFaceIEDriver extends AbstractDriver<HuggingFaceIEDriverOptio
69
69
 
70
70
  async requestTextCompletionStream(prompt: string, options: ExecutionOptions) {
71
71
  if (options.model_options?._option_id !== "text-fallback") {
72
- this.logger.warn("Invalid model options", { options: options.model_options });
72
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
73
73
  }
74
74
  options.model_options = options.model_options as TextFallbackOptions;
75
75
 
@@ -82,8 +82,7 @@ export class HuggingFaceIEDriver extends AbstractDriver<HuggingFaceIEDriverOptio
82
82
  },
83
83
  });
84
84
 
85
-
86
- return transformAsyncIterator(req, (val: TextGenerationStreamOutput) => {
85
+ return transformAsyncIterator(req, (val: TextGenerationStreamOutput): CompletionChunkObject => {
87
86
  //special like <s> are not part of the result
88
87
  if (val.token.special) return { result: [] };
89
88
  let finish_reason = val.details?.finish_reason as string;
@@ -96,13 +95,13 @@ export class HuggingFaceIEDriver extends AbstractDriver<HuggingFaceIEDriverOptio
96
95
  token_usage: {
97
96
  result: val.details?.generated_tokens ?? 0,
98
97
  }
99
- } as CompletionChunkObject;
98
+ };
100
99
  });
101
100
  }
102
101
 
103
102
  async requestTextCompletion(prompt: string, options: ExecutionOptions) {
104
103
  if (options.model_options?._option_id !== "text-fallback") {
105
- this.logger.warn("Invalid model options", { options: options.model_options });
104
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
106
105
  }
107
106
  options.model_options = options.model_options as TextFallbackOptions;
108
107
 
package/src/index.ts CHANGED
@@ -1,12 +1,12 @@
1
+ export * from "./azure/azure_foundry.js";
1
2
  export * from "./bedrock/index.js";
2
3
  export * from "./groq/index.js";
3
4
  export * from "./huggingface_ie.js";
4
5
  export * from "./mistral/index.js";
5
6
  export * from "./openai/azure_openai.js";
6
- export * from "./azure/azure_foundry.js";
7
7
  export * from "./openai/openai.js";
8
8
  export * from "./replicate.js";
9
- export * from "./test/index.js";
9
+ export * from "./test-driver/index.js";
10
10
  export * from "./togetherai/index.js";
11
11
  export * from "./vertexai/index.js";
12
12
  export * from "./watsonx/index.js";
@@ -64,7 +64,7 @@ export class MistralAIDriver extends AbstractDriver<MistralAIDriverOptions, Open
64
64
 
65
65
  async requestTextCompletion(messages: OpenAITextMessage[], options: ExecutionOptions): Promise<Completion> {
66
66
  if (options.model_options?._option_id !== "text-fallback") {
67
- this.logger.warn("Invalid model options", { options: options.model_options });
67
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
68
68
  }
69
69
  options.model_options = options.model_options as TextFallbackOptions;
70
70
 
@@ -95,7 +95,7 @@ export class MistralAIDriver extends AbstractDriver<MistralAIDriverOptions, Open
95
95
 
96
96
  async requestTextCompletionStream(messages: OpenAITextMessage[], options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>> {
97
97
  if (options.model_options?._option_id !== "text-fallback") {
98
- this.logger.warn("Invalid model options", { options: options.model_options });
98
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
99
99
  }
100
100
  options.model_options = options.model_options as TextFallbackOptions;
101
101
 
@@ -9,7 +9,7 @@ export interface AzureOpenAIDriverOptions extends DriverOptions {
9
9
  * The credentials to use to access Azure OpenAI
10
10
  */
11
11
  azureADTokenProvider?: any; //type with azure credentials
12
-
12
+
13
13
  apiKey?: string;
14
14
 
15
15
  endpoint?: string;
@@ -41,7 +41,7 @@ export class AzureOpenAIDriver extends BaseOpenAIDriver {
41
41
 
42
42
  this.service = new AzureOpenAI({
43
43
  apiKey: opts.apiKey,
44
- azureADTokenProvider: opts.azureADTokenProvider,
44
+ azureADTokenProvider: opts.azureADTokenProvider,
45
45
  endpoint: opts.endpoint,
46
46
  apiVersion: opts.apiVersion ?? "2024-10-21",
47
47
  deployment: opts.deployment
@@ -56,7 +56,7 @@ export class AzureOpenAIDriver extends BaseOpenAIDriver {
56
56
  const azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), scope);
57
57
  return azureADTokenProvider;
58
58
  }
59
-
59
+
60
60
  async listModels(): Promise<AIModel[]> {
61
61
  return this._listModels();
62
62
  }
@@ -65,7 +65,7 @@ export class AzureOpenAIDriver extends BaseOpenAIDriver {
65
65
  if (!this.service.deploymentName) {
66
66
  throw new Error("A specific deployment is not set. Azure OpenAI cannot list deployments. Update your endpoint URL to include the deployment name, e.g., https://your-resource.openai.azure.com/openai/deployments/your-deployment/chat/completions");
67
67
  }
68
-
68
+
69
69
  //Do a test execution to check if the model works and to get the model ID.
70
70
  let modelID = this.service.deploymentName;
71
71
  try {
@@ -76,7 +76,7 @@ export class AzureOpenAIDriver extends BaseOpenAIDriver {
76
76
  });
77
77
  modelID = testResponse.model;
78
78
  } catch (error) {
79
- this.logger.error("Failed to test model for Azure OpenAI listing :", error);
79
+ this.logger.error({ error }, "Failed to test model for Azure OpenAI listing :");
80
80
  }
81
81
  const modelCapability = getModelCapabilities(modelID, "openai");
82
82
  return [{
@@ -76,7 +76,7 @@ export abstract class BaseOpenAIDriver extends AbstractDriver<
76
76
  const data = choice.message.content ?? undefined;
77
77
 
78
78
  if (!data && !tools) {
79
- this.logger?.error("[OpenAI] Response is not valid", result);
79
+ this.logger.error({ result }, "[OpenAI] Response is not valid");
80
80
  throw new Error("Response is not valid: no data");
81
81
  }
82
82
 
@@ -90,7 +90,7 @@ export abstract class BaseOpenAIDriver extends AbstractDriver<
90
90
 
91
91
  async requestTextCompletionStream(prompt: ChatCompletionMessageParam[], options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>> {
92
92
  if (options.model_options?._option_id !== "openai-text" && options.model_options?._option_id !== "openai-thinking") {
93
- this.logger.warn("Invalid model options", { options: options.model_options });
93
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
94
94
  }
95
95
 
96
96
  const toolDefs = getToolDefinitions(options.tools);
@@ -163,7 +163,7 @@ export abstract class BaseOpenAIDriver extends AbstractDriver<
163
163
 
164
164
  async requestTextCompletion(prompt: ChatCompletionMessageParam[], options: ExecutionOptions): Promise<Completion> {
165
165
  if (options.model_options?._option_id !== "openai-text" && options.model_options?._option_id !== "openai-thinking") {
166
- this.logger.warn("Invalid model options", { options: options.model_options });
166
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
167
167
  }
168
168
 
169
169
  convertRoles(prompt, options.model);
package/src/replicate.ts CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  } from "@llumiverse/core";
16
16
  import { EventStream } from "@llumiverse/core/async";
17
17
  import { EventSource } from "eventsource";
18
- import Replicate, { Prediction } from "replicate";
18
+ import Replicate, { Prediction, Training } from "replicate";
19
19
 
20
20
  let cachedTrainableModels: AIModel[] | undefined;
21
21
  let cachedTrainableModelsTimestamp: number = 0;
@@ -66,7 +66,7 @@ export class ReplicateDriver extends AbstractDriver<DriverOptions, string> {
66
66
 
67
67
  async requestTextCompletionStream(prompt: string, options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>> {
68
68
  if (options.model_options?._option_id !== "text-fallback") {
69
- this.logger.warn("Invalid model options", { options: options.model_options });
69
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
70
70
  }
71
71
  options.model_options = options.model_options as TextFallbackOptions;
72
72
 
@@ -88,7 +88,7 @@ export class ReplicateDriver extends AbstractDriver<DriverOptions, string> {
88
88
 
89
89
  const source = new EventSource(prediction.urls.stream!);
90
90
  source.addEventListener("output", (e: any) => {
91
- stream.push({result: [{ type: "text", value: e.data }] });
91
+ stream.push({ result: [{ type: "text", value: e.data }] });
92
92
  });
93
93
  source.addEventListener("error", (e: any) => {
94
94
  let error: any;
@@ -97,7 +97,7 @@ export class ReplicateDriver extends AbstractDriver<DriverOptions, string> {
97
97
  } catch (error) {
98
98
  error = JSON.stringify(e);
99
99
  }
100
- this.logger?.error("Error in SSE stream", { e, error });
100
+ this.logger.error({ e, error }, "Error in SSE stream");
101
101
  });
102
102
  source.addEventListener("done", () => {
103
103
  try {
@@ -111,7 +111,7 @@ export class ReplicateDriver extends AbstractDriver<DriverOptions, string> {
111
111
 
112
112
  async requestTextCompletion(prompt: string, options: ExecutionOptions) {
113
113
  if (options.model_options?._option_id !== "text-fallback") {
114
- this.logger.warn("Invalid model options", { options: options.model_options });
114
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
115
115
  }
116
116
  options.model_options = options.model_options as TextFallbackOptions;
117
117
  const model = ReplicateDriver.parseModelId(options.model);
@@ -236,7 +236,7 @@ export class ReplicateDriver extends AbstractDriver<DriverOptions, string> {
236
236
  this.service.models.versions.list(owner, model),
237
237
  ]);
238
238
 
239
- if (!rModel || !versions || versions.length === 0) {
239
+ if (!rModel || !versions || (versions as any).results?.length === 0) {
240
240
  throw new Error("Model not found or no versions available");
241
241
  }
242
242
 
@@ -289,7 +289,7 @@ export class ReplicateDriver extends AbstractDriver<DriverOptions, string> {
289
289
 
290
290
  }
291
291
 
292
- function jobInfo(job: Prediction, modelName?: string): TrainingJob {
292
+ function jobInfo(job: Prediction | Training, modelName?: string): TrainingJob {
293
293
  // 'starting' | 'processing' | 'succeeded' | 'failed' | 'canceled'
294
294
  const jobStatus = job.status;
295
295
  let details: string | undefined;
@@ -31,7 +31,7 @@ export class TogetherAIDriver extends AbstractDriver<TogetherAIDriverOptions, st
31
31
 
32
32
  async requestTextCompletion(prompt: string, options: ExecutionOptions): Promise<Completion> {
33
33
  if (options.model_options?._option_id !== "text-fallback") {
34
- this.logger.warn("Invalid model options", { options: options.model_options });
34
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
35
35
  }
36
36
  options.model_options = options.model_options as TextFallbackOptions;
37
37
 
@@ -73,7 +73,7 @@ export class TogetherAIDriver extends AbstractDriver<TogetherAIDriverOptions, st
73
73
 
74
74
  async requestTextCompletionStream(prompt: string, options: ExecutionOptions): Promise<AsyncIterable<CompletionChunkObject>> {
75
75
  if (options.model_options?._option_id !== "text-fallback") {
76
- this.logger.warn("Invalid model options", { options: options.model_options });
76
+ this.logger.warn({ options: options.model_options }, "Invalid model options");
77
77
  }
78
78
  options.model_options = options.model_options as TextFallbackOptions;
79
79