utilitas 1998.2.66 → 1999.1.2
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/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +13 -9
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -488,7 +488,8 @@ const init = async (options = {}) => {
|
|
|
488
488
|
case OPENAI:
|
|
489
489
|
assertApiKey(provider, options);
|
|
490
490
|
ais.push({
|
|
491
|
-
id, provider, model,
|
|
491
|
+
id, provider, model, priority: 0, initOrder: ais.length,
|
|
492
|
+
client: await OpenAI(options),
|
|
492
493
|
prompt: async (cnt, opts) => await promptOpenAI(id, cnt, opts),
|
|
493
494
|
embedding: async (i, o) => await createOpenAIEmbedding(id, i, o),
|
|
494
495
|
});
|
|
@@ -498,7 +499,8 @@ const init = async (options = {}) => {
|
|
|
498
499
|
assert(options.endpoint,
|
|
499
500
|
`${provider} api endpoint and deployment are required.`);
|
|
500
501
|
ais.push({
|
|
501
|
-
id, provider, model,
|
|
502
|
+
id, provider, model, priority: 0, initOrder: ais.length,
|
|
503
|
+
client: await AzureOpenAI({
|
|
502
504
|
apiVersion: '2025-01-01-preview',
|
|
503
505
|
deployment: model.name, ...options,
|
|
504
506
|
}),
|
|
@@ -509,7 +511,8 @@ const init = async (options = {}) => {
|
|
|
509
511
|
assertApiKey(provider, options);
|
|
510
512
|
assert(options.baseURL, `${provider} api endpoint is required.`);
|
|
511
513
|
ais.push({
|
|
512
|
-
id, provider, model,
|
|
514
|
+
id, provider, model, priority: 0, initOrder: ais.length,
|
|
515
|
+
client: await OpenAI(options),
|
|
513
516
|
prompt: async (cnt, opts) => await promptOpenAI(id, cnt, opts),
|
|
514
517
|
});
|
|
515
518
|
break;
|
|
@@ -517,7 +520,7 @@ const init = async (options = {}) => {
|
|
|
517
520
|
assertApiKey(provider, options);
|
|
518
521
|
const { GoogleGenerativeAI } = await need('@google/generative-ai');
|
|
519
522
|
ais.push({
|
|
520
|
-
id, provider, model,
|
|
523
|
+
id, provider, model, priority: 0, initOrder: ais.length,
|
|
521
524
|
client: new GoogleGenerativeAI(options.apiKey),
|
|
522
525
|
prompt: async (cnt, opts) => await promptGemini(id, cnt, opts),
|
|
523
526
|
embedding: async (i, o) => await createGeminiEmbedding(id, i, o),
|
|
@@ -527,7 +530,8 @@ const init = async (options = {}) => {
|
|
|
527
530
|
assertApiKey(provider, options);
|
|
528
531
|
const Anthropic = (await need('@anthropic-ai/sdk')).Anthropic;
|
|
529
532
|
ais.push({
|
|
530
|
-
id, provider, model,
|
|
533
|
+
id, provider, model, priority: 0, initOrder: ais.length,
|
|
534
|
+
client: new Anthropic(options),
|
|
531
535
|
prompt: async (cnt, opts) => await promptAnthropic(id, cnt, opts),
|
|
532
536
|
});
|
|
533
537
|
break;
|
|
@@ -538,7 +542,7 @@ const init = async (options = {}) => {
|
|
|
538
542
|
process.env['GOOGLE_APPLICATION_CREDENTIALS'] = options.credentials;
|
|
539
543
|
process.env['ANTHROPIC_VERTEX_PROJECT_ID'] = options.projectId;
|
|
540
544
|
ais.push({
|
|
541
|
-
id, provider, model,
|
|
545
|
+
id, provider, model, priority: 0, initOrder: ais.length,
|
|
542
546
|
client: new AnthropicVertex({ region: options?.region || 'us-east5' }),
|
|
543
547
|
prompt: async (cnt, opts) => await promptAnthropic(id, cnt, opts),
|
|
544
548
|
});
|
|
@@ -547,9 +551,8 @@ const init = async (options = {}) => {
|
|
|
547
551
|
// https://github.com/ollama/ollama/blob/main/docs/openai.md
|
|
548
552
|
const baseURL = 'http://localhost:11434/v1/';
|
|
549
553
|
ais.push({
|
|
550
|
-
id, provider, model,
|
|
551
|
-
|
|
552
|
-
}),
|
|
554
|
+
id, provider, model, priority: 0, initOrder: ais.length,
|
|
555
|
+
client: await OpenAI({ baseURL, apiKey: 'ollama', ...options }),
|
|
553
556
|
prompt: async (cnt, opts) => await promptOpenAI(id, cnt, opts),
|
|
554
557
|
});
|
|
555
558
|
const phLog = m => log(`Ollama preheat: ${m?.message || m}`);
|
|
@@ -564,6 +567,7 @@ const init = async (options = {}) => {
|
|
|
564
567
|
default:
|
|
565
568
|
throwError(`Invalid AI provider: ${options.provider || 'null'}.`);
|
|
566
569
|
}
|
|
570
|
+
ais.sort((a, b) => a.priority - b.priority || a.initOrder - b.initOrder);
|
|
567
571
|
return ais.find(x => x.id === id);
|
|
568
572
|
};
|
|
569
573
|
|
package/lib/manifest.mjs
CHANGED