utilitas 2001.1.142 → 2001.1.144
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 +8 -105
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -52,9 +52,9 @@ const [
|
|
|
52
52
|
JSON_OBJECT, PROMPT_IS_REQUIRED, k, trimTailing, trimBeginning,
|
|
53
53
|
GEMINI_30_PRO_IMAGE, IMAGE, OPENROUTER_API, OPENROUTER, AUTO, TOOL, ONLINE,
|
|
54
54
|
GEMINI_31_PRO, GEMINI_30_FLASH, VEO_31, IMAGEN_4_UPSCALE, ERROR_GENERATING,
|
|
55
|
-
GEMINI_25_PRO_TTS,
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
GEMINI_25_PRO_TTS, GPT_AUDIO, ELLIPSIS, TOP_LIMIT, ATTACHMENT, PROCESSING,
|
|
56
|
+
CURSOR, LN1, LN2, TOP, DEEP_RESEARCH_MAX, MD_CODE_ESCAPED, VERTEX, LYRIA_3,
|
|
57
|
+
GPT_54_MINI,
|
|
58
58
|
] = [
|
|
59
59
|
'OpenAI', 'Google', 'Ollama', 'nova', '```', 'claude-opus-4.7', 'audio',
|
|
60
60
|
'wav', 'OPENAI_VOICE', 'medium', 'think', '<think>', '</think>',
|
|
@@ -67,10 +67,10 @@ const [
|
|
|
67
67
|
'OpenRouter', 'openrouter/auto', 'tool', ':online',
|
|
68
68
|
'gemini-3.1-pro-preview', 'gemini-3-flash-preview',
|
|
69
69
|
'veo-3.1-generate-preview', 'imagen-4.0-upscale-preview',
|
|
70
|
-
'Error generating content.', 'gemini-2.5-pro-preview-tts', '
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
70
|
+
'Error generating content.', 'gemini-2.5-pro-preview-tts', 'gpt-audio',
|
|
71
|
+
'...', 3, 'ATTACHMENT', { processing: true }, ' █', '\n\n', '\n\n\n',
|
|
72
|
+
'top', 'deep-research-max-preview-04-2026', '\`\`\`', 'Vertex',
|
|
73
|
+
'lyria-3-pro-preview', 'gpt-5.4-mini',
|
|
74
74
|
];
|
|
75
75
|
|
|
76
76
|
const [joinL1, joinL2]
|
|
@@ -150,42 +150,6 @@ for (const n in MODELS) {
|
|
|
150
150
|
MODELS[n].attachmentTokenCost = MODELS[n].attachmentTokenCost
|
|
151
151
|
?? ATTACHMENT_TOKEN_COST;
|
|
152
152
|
}
|
|
153
|
-
// Auto model have some issues with tools and reasoning, so we disable them here
|
|
154
|
-
// MODELS[AUTO] = { name: AUTO, defaultProvider: OPENROUTER, };
|
|
155
|
-
// for (const n of [GPT_55, GEMINI_31_PRO, GEMINI_30_FLASH]) {
|
|
156
|
-
// // get the most restrictive limits
|
|
157
|
-
// for (const key of [
|
|
158
|
-
// 'contextWindow', 'maxInputTokens', 'maxOutputTokens',
|
|
159
|
-
// ]) {
|
|
160
|
-
// MODELS[AUTO][key] = Math.min(
|
|
161
|
-
// MODELS[AUTO][key] || Infinity, MODELS[n][key] || Infinity,
|
|
162
|
-
// );
|
|
163
|
-
// }
|
|
164
|
-
// // get the most permissive costs
|
|
165
|
-
// for (const key of [
|
|
166
|
-
// 'documentCostTokens', 'imageCostTokens', 'audioCostTokens',
|
|
167
|
-
// ]) {
|
|
168
|
-
// MODELS[AUTO][key] = Math.max(
|
|
169
|
-
// MODELS[AUTO][key] || 0, MODELS[n][key] || 0,
|
|
170
|
-
// );
|
|
171
|
-
// }
|
|
172
|
-
// // combine supported types
|
|
173
|
-
// for (const key of ['supportedMimeTypes']) {
|
|
174
|
-
// MODELS[AUTO][key] = [...new Set(
|
|
175
|
-
// [...MODELS[AUTO][key] || [], ...MODELS[n][key] || []]
|
|
176
|
-
// )];
|
|
177
|
-
// }
|
|
178
|
-
// // for other features, if any model supports it, then AUTO supports it
|
|
179
|
-
// for (const key of [
|
|
180
|
-
// 'structured', 'reasoning', 'tools', 'vision', 'fast', 'deep-research', 'image',
|
|
181
|
-
// ]) {
|
|
182
|
-
// MODELS[AUTO][key] = MODELS[AUTO][key] || MODELS[n][key];
|
|
183
|
-
// }
|
|
184
|
-
// // catch first possible support
|
|
185
|
-
// for (const key of ['audio']) {
|
|
186
|
-
// MODELS[AUTO][key] = MODELS[AUTO][key] || MODELS[n][key];
|
|
187
|
-
// }
|
|
188
|
-
// };
|
|
189
153
|
|
|
190
154
|
// Default models for each provider
|
|
191
155
|
const DEFAULT_MODELS = {
|
|
@@ -266,7 +230,7 @@ const adaptOpenRouterModels = async () => {
|
|
|
266
230
|
&& ![GEMINI_30_FLASH].includes(model.name));
|
|
267
231
|
model.tools = !!(model.supported_parameters?.includes('tools')
|
|
268
232
|
|| model.supported_parameters?.includes('tool_choice'));
|
|
269
|
-
if (
|
|
233
|
+
if (/\-(flash|lite|mini|nano|tiny|small)/i.test(model.name)) {
|
|
270
234
|
model.fast = true;
|
|
271
235
|
}
|
|
272
236
|
model.supportedMimeTypes = [];
|
|
@@ -1185,67 +1149,6 @@ const promptGoogle = async (aiId, prompt, options = {}) => {
|
|
|
1185
1149
|
})), model: packModelId([provider, M.source, M.name]),
|
|
1186
1150
|
};
|
|
1187
1151
|
}
|
|
1188
|
-
} else if (M?.audio) { // https://ai.google.dev/gemini-api/docs/speech-generation#voices
|
|
1189
|
-
if (M.name === LYRIA_3) {
|
|
1190
|
-
var resp = await client.interactions.create({
|
|
1191
|
-
model: M.name,
|
|
1192
|
-
input: [{ type: TEXT, text: prompt }],
|
|
1193
|
-
...(options?.config ? { generation_config: options.config } : {}),
|
|
1194
|
-
});
|
|
1195
|
-
assert(!resp?.error, resp?.error?.message || ERROR_GENERATING);
|
|
1196
|
-
if (options?.generateRaw) { return resp; }
|
|
1197
|
-
await tryUntil(async () => {
|
|
1198
|
-
if (resp?.status === 'completed') { return; }
|
|
1199
|
-
assert(
|
|
1200
|
-
!['failed', 'cancelled', 'incomplete'].includes(resp?.status),
|
|
1201
|
-
`Google music generation failed: ${resp?.status}`,
|
|
1202
|
-
);
|
|
1203
|
-
resp = await client.interactions.get(resp.id);
|
|
1204
|
-
assert(
|
|
1205
|
-
resp?.status === 'completed',
|
|
1206
|
-
`Waiting for Google music generation: ${resp.id}`,
|
|
1207
|
-
);
|
|
1208
|
-
}, { maxTry: 60 * 10, log });
|
|
1209
|
-
const outputs = resp?.outputs || [];
|
|
1210
|
-
const rawAudio = outputs.find(x => x?.type === AUDIO && x?.data);
|
|
1211
|
-
const mimeType = rawAudio?.mime_type || rawAudio?.mimeType || MIME_MPEGA;
|
|
1212
|
-
const suffix = mimeType === MIME_MPEGA ? 'mp3' : mimeType.split('/').pop();
|
|
1213
|
-
assert(rawAudio?.data, ERROR_GENERATING);
|
|
1214
|
-
resp = {
|
|
1215
|
-
text: outputs.filter(x => x?.type === TEXT && x?.text)
|
|
1216
|
-
.map(x => x.text).join(LN1),
|
|
1217
|
-
audio: {
|
|
1218
|
-
data: await convert(rawAudio.data, {
|
|
1219
|
-
input: BASE64, suffix, ...options || {},
|
|
1220
|
-
}), mimeType,
|
|
1221
|
-
}, model: packModelId([provider, M.source, M.name]),
|
|
1222
|
-
};
|
|
1223
|
-
} else {
|
|
1224
|
-
var resp = await client.models.generateContent({
|
|
1225
|
-
model: M.name, contents: prompt,
|
|
1226
|
-
config: mergeAtoB(options?.config, {
|
|
1227
|
-
responseModalities: ['AUDIO'],
|
|
1228
|
-
speechConfig: {
|
|
1229
|
-
voiceConfig: {
|
|
1230
|
-
prebuiltVoiceConfig: {
|
|
1231
|
-
voiceName: options?.voice || 'Zephyr',
|
|
1232
|
-
},
|
|
1233
|
-
},
|
|
1234
|
-
},
|
|
1235
|
-
}),
|
|
1236
|
-
});
|
|
1237
|
-
var rawAudio = resp?.candidates?.[0]?.content?.parts?.[0]?.inlineData;
|
|
1238
|
-
assert(rawAudio, ERROR_GENERATING, 500);
|
|
1239
|
-
if (!options?.raw) {
|
|
1240
|
-
resp = {
|
|
1241
|
-
text: '', audio: {
|
|
1242
|
-
data: await packPcmToWav(rawAudio?.data, {
|
|
1243
|
-
input: BASE64, suffix: wav, ...options || {},
|
|
1244
|
-
}), mimeType: MIME_WAV,
|
|
1245
|
-
}, model: packModelId([provider, M.source, M.name]),
|
|
1246
|
-
};
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
1152
|
} else if (M?.['deep-research']) {
|
|
1250
1153
|
// TODO: previous_interaction_id support
|
|
1251
1154
|
const pkgOptions = { ...options || {}, provider, model: M.name };
|
package/lib/manifest.mjs
CHANGED