utilitas 2001.1.85 → 2001.1.87
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/README.md +1 -1
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +31 -14
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -103,13 +103,13 @@ const MODEL_ICONS = {
|
|
|
103
103
|
|
|
104
104
|
const FEATURE_ICONS = {
|
|
105
105
|
audio: '🔊', deepsearch: '🔍', fast: '⚡️', hearing: '👂', hidden: '🙈',
|
|
106
|
-
image: '🎨',
|
|
106
|
+
image: '🎨', reasoning: '🧠', structured: '📊', tools: '🧰', video: '🎬',
|
|
107
107
|
vision: '👁️', // finetune: '🔧',
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
const GEMINI_RULES = {
|
|
111
111
|
source: GOOGLE, contextWindow: m(1.05), maxOutputTokens: k(65.5),
|
|
112
|
-
hearing: true,
|
|
112
|
+
hearing: true, reasoning: true, structured: true, tools: true, vision: true,
|
|
113
113
|
supportedMimeTypes: [
|
|
114
114
|
MIME_PNG, MIME_JPEG, MIME_MOV, MIME_MPEG, MIME_MP4, MIME_MPG, MIME_AVI,
|
|
115
115
|
MIME_WMV, MIME_MPEGPS, MIME_FLV, MIME_PDF, MIME_AAC, MIME_FLAC,
|
|
@@ -120,7 +120,7 @@ const GEMINI_RULES = {
|
|
|
120
120
|
|
|
121
121
|
const OPENAI_RULES = {
|
|
122
122
|
source: OPENAI, contextWindow: k(400), maxOutputTokens: k(128),
|
|
123
|
-
hearing: true,
|
|
123
|
+
hearing: true, reasoning: true, structured: true, tools: true, vision: true,
|
|
124
124
|
supportedMimeTypes: [
|
|
125
125
|
MIME_PNG, MIME_JPEG, MIME_GIF, MIME_WEBP, MIME_PDF, MIME_WAV
|
|
126
126
|
], defaultProvider: OPENROUTER,
|
|
@@ -128,7 +128,7 @@ const OPENAI_RULES = {
|
|
|
128
128
|
|
|
129
129
|
const DEEPSEEK_32_RULES = {
|
|
130
130
|
source: DEEPSEEK, contextWindow: k(163.8), maxOutputTokens: k(65.5),
|
|
131
|
-
|
|
131
|
+
structured: true, tools: true, reasoning: true,
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
// https://platform.openai.com/docs/models
|
|
@@ -137,7 +137,7 @@ const DEEPSEEK_32_RULES = {
|
|
|
137
137
|
const MODELS = {
|
|
138
138
|
// fast and balanced models
|
|
139
139
|
[GEMINI_30_FLASH]: { // https://gemini.google.com/app/c680748b3307790b
|
|
140
|
-
...GEMINI_RULES, fast: true,
|
|
140
|
+
...GEMINI_RULES, fast: true, structured: false, // issue with json output via OpenRouter
|
|
141
141
|
},
|
|
142
142
|
// strong and fast
|
|
143
143
|
[GPT_52]: { ...OPENAI_RULES, fast: true },
|
|
@@ -152,6 +152,10 @@ const MODELS = {
|
|
|
152
152
|
source: GOOGLE, maxInputTokens: 480,
|
|
153
153
|
image: true, defaultProvider: GOOGLE,
|
|
154
154
|
},
|
|
155
|
+
// [IMAGEN_4_UPSCALE]: {
|
|
156
|
+
// source: GOOGLE, maxInputTokens: 0, image: true,
|
|
157
|
+
// supportedMimeTypes: [MIME_PNG, MIME_JPEG], defaultProvider: GOOGLE,
|
|
158
|
+
// },
|
|
155
159
|
[VEO_31]: {
|
|
156
160
|
source: GOOGLE, maxInputTokens: 1024, attachmentTokenCost: 0,
|
|
157
161
|
video: true, vision: true,
|
|
@@ -165,7 +169,7 @@ const MODELS = {
|
|
|
165
169
|
[GPT_51_CODEX]: { ...OPENAI_RULES },
|
|
166
170
|
[CLOUD_OPUS_45]: {
|
|
167
171
|
source: ANTHROPIC, contextWindow: k(200), maxOutputTokens: k(64),
|
|
168
|
-
|
|
172
|
+
reasoning: true, structured: true, tools: true, vision: true,
|
|
169
173
|
supportedMimeTypes: [
|
|
170
174
|
MIME_TEXT, MIME_PNG, MIME_JPEG, MIME_GIF, MIME_WEBP, MIME_PDF,
|
|
171
175
|
], defaultProvider: OPENROUTER,
|
|
@@ -190,7 +194,7 @@ const MODELS = {
|
|
|
190
194
|
// models with deepsearch capabilities
|
|
191
195
|
[JINA_DEEPSEARCH]: { // @todo: parse more details from results, eg: "reed urls".
|
|
192
196
|
maxInputTokens: Infinity, attachmentTokenCost: 0,
|
|
193
|
-
deepsearch: true,
|
|
197
|
+
deepsearch: true, reasoning: true, structured: true, vision: true,
|
|
194
198
|
supportedMimeTypes: [MIME_PNG, MIME_JPEG, MIME_TEXT, MIME_WEBP, MIME_PDF],
|
|
195
199
|
defaultProvider: JINA,
|
|
196
200
|
},
|
|
@@ -200,7 +204,7 @@ const MODELS = {
|
|
|
200
204
|
// best local model
|
|
201
205
|
[GEMMA_3_27B]: {
|
|
202
206
|
source: GOOGLE, contextWindow: k(128), maxOutputTokens: k(8),
|
|
203
|
-
fast: true,
|
|
207
|
+
fast: true, structured: true, vision: true,
|
|
204
208
|
supportedMimeTypes: [MIME_PNG, MIME_JPEG, MIME_GIF],
|
|
205
209
|
defaultProvider: OLLAMA,
|
|
206
210
|
},
|
|
@@ -248,7 +252,7 @@ for (const n in MODELS) {
|
|
|
248
252
|
// }
|
|
249
253
|
// // for other features, if any model supports it, then AUTO supports it
|
|
250
254
|
// for (const key of [
|
|
251
|
-
// '
|
|
255
|
+
// 'structured', 'reasoning', 'tools', 'vision', 'fast', 'deepsearch', 'image',
|
|
252
256
|
// ]) {
|
|
253
257
|
// MODELS[AUTO][key] = MODELS[AUTO][key] || MODELS[n][key];
|
|
254
258
|
// }
|
|
@@ -512,7 +516,7 @@ const packAi = (ais, options = {}) => {
|
|
|
512
516
|
|
|
513
517
|
const getAi = async (id, options = {}) => {
|
|
514
518
|
options?.select || (options.select = {});
|
|
515
|
-
options?.jsonMode && (options.select.
|
|
519
|
+
options?.jsonMode && (options.select.structured = true);
|
|
516
520
|
if (id) {
|
|
517
521
|
const ai = ais.find(x => x.id === id);
|
|
518
522
|
assert(ai, `AI not found: ${id}.`);
|
|
@@ -746,8 +750,8 @@ const packModelId = (model_reference, options = {}) => {
|
|
|
746
750
|
};
|
|
747
751
|
|
|
748
752
|
const buildPrompts = async (model, input, options = {}) => {
|
|
749
|
-
assert(!(options.jsonMode && !model?.
|
|
750
|
-
`This model does not support
|
|
753
|
+
assert(!(options.jsonMode && !model?.structured),
|
|
754
|
+
`This model does not support structured output: ${model.name}`);
|
|
751
755
|
assert(!(options.reasoning && !model?.reasoning),
|
|
752
756
|
`This model does not support reasoning: ${model.name}`);
|
|
753
757
|
options.attachments = (await Promise.all((
|
|
@@ -997,11 +1001,23 @@ const promptGoogle = async (aiId, prompt, options = {}) => {
|
|
|
997
1001
|
const target_model = options?.model || model.name;
|
|
998
1002
|
const M = MODELS[target_model];
|
|
999
1003
|
prompt = ensureString(prompt, { trim: true });
|
|
1004
|
+
// M.name === IMAGEN_4_ULTRA ||
|
|
1000
1005
|
assertPrompt(prompt);
|
|
1001
1006
|
M.tts && (prompt = `${options?.prompt || TTS_PROMPT}: ${prompt}`);
|
|
1002
1007
|
prompt = trimText(prompt, { limit: M.maxInputTokens });
|
|
1003
1008
|
if (M?.image) {
|
|
1004
|
-
var resp
|
|
1009
|
+
var resp;
|
|
1010
|
+
// if (M.name === IMAGEN_4_ULTRA) {
|
|
1011
|
+
// resp = await client.models.upscaleImage({
|
|
1012
|
+
// model: M.name, prompt, config: mergeAtoB(options?.config, {
|
|
1013
|
+
// numberOfImages: options?.n || 4, sampleImageSize: '2K',
|
|
1014
|
+
// includeRaiReason: true,
|
|
1015
|
+
// // "1:1" (default), "3:4", "4:3", "9:16", and "16:9"
|
|
1016
|
+
// aspectRatio: '16:9', personGeneration: 'allow_adult',
|
|
1017
|
+
// }),
|
|
1018
|
+
// });
|
|
1019
|
+
// } else {
|
|
1020
|
+
resp = await client.models.generateImages({
|
|
1005
1021
|
model: M.name, prompt, config: mergeAtoB(options?.config, {
|
|
1006
1022
|
numberOfImages: options?.n || 4, sampleImageSize: '2K',
|
|
1007
1023
|
includeRaiReason: true,
|
|
@@ -1009,6 +1025,7 @@ const promptGoogle = async (aiId, prompt, options = {}) => {
|
|
|
1009
1025
|
aspectRatio: '16:9', personGeneration: 'allow_adult',
|
|
1010
1026
|
}),
|
|
1011
1027
|
});
|
|
1028
|
+
// }
|
|
1012
1029
|
var generated = resp?.generatedImages;
|
|
1013
1030
|
assert(!resp?.error && generated?.filter(
|
|
1014
1031
|
x => !x.raiFilteredReason
|
|
@@ -1482,7 +1499,7 @@ const analyzeSessions = async (sessionIds, options) => {
|
|
|
1482
1499
|
if (sm.length) { sses[ids[i]] = sm; }
|
|
1483
1500
|
}
|
|
1484
1501
|
const ai = await getAi(options?.aiId, {
|
|
1485
|
-
jsonMode: true, simple: true, select: {
|
|
1502
|
+
jsonMode: true, simple: true, select: { structured: true, fast: true },
|
|
1486
1503
|
...options || {}
|
|
1487
1504
|
});
|
|
1488
1505
|
const pmt = options?.prompt || (
|
package/lib/manifest.mjs
CHANGED