utilitas 2001.1.68 → 2001.1.70
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 -0
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +22 -12
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -54,7 +54,7 @@ const [
|
|
|
54
54
|
GEMINI_30_PRO, GEMINI_25_FLASH, IMAGEN_4_ULTRA, VEO_31, IMAGEN_4_UPSCALE,
|
|
55
55
|
ERROR_GENERATING, GEMINI_25_FLASH_TTS, GEMINI_25_PRO_TTS, wav,
|
|
56
56
|
GPT_4O_MIMI_TTS, GPT_4O_TRANSCRIBE, INVALID_AUDIO, OGG_EXT, ELLIPSIS,
|
|
57
|
-
TOP_LIMIT, ATTACHMENT, PROCESSING, CURSOR, LN
|
|
57
|
+
TOP_LIMIT, ATTACHMENT, PROCESSING, CURSOR, LN, TOP
|
|
58
58
|
] = [
|
|
59
59
|
'OpenAI', 'Google', 'Ollama', 'nova', 'deepseek-3.2-speciale', '```',
|
|
60
60
|
'claude-opus-4.5', 'audio', 'wav', 'OPENAI_VOICE', 'medium', 'think',
|
|
@@ -72,7 +72,7 @@ const [
|
|
|
72
72
|
'imagen-4.0-upscale-preview', 'Error generating content.',
|
|
73
73
|
'gemini-2.5-flash-preview-tts', 'gemini-2.5-pro-tts', 'wav',
|
|
74
74
|
'gpt-4o-mini-tts', 'gpt-4o-transcribe', 'Invalid audio data.', 'ogg',
|
|
75
|
-
'...', 3, 'ATTACHMENT', { processing: true }, ' █', '\n',
|
|
75
|
+
'...', 3, 'ATTACHMENT', { processing: true }, ' █', '\n', 'top',
|
|
76
76
|
];
|
|
77
77
|
|
|
78
78
|
const LN2 = `${LN}${LN}`;
|
|
@@ -1235,7 +1235,7 @@ const collectAttachments = async (options = {}) => {
|
|
|
1235
1235
|
const selectAi = async (options = {}) => {
|
|
1236
1236
|
options.aiId = ensureArray(options?.aiId).filter(x => x);
|
|
1237
1237
|
const ais = await getAi(null, { all: true });
|
|
1238
|
-
if (options.aiId.includes(
|
|
1238
|
+
if (options.aiId.includes(TOP)) { // Use top AIs
|
|
1239
1239
|
options.aiId = ais.slice(0, TOP_LIMIT).map(x => x.id);
|
|
1240
1240
|
} else if (options.collected?.length) { // Select by attachments
|
|
1241
1241
|
const supported = {};
|
|
@@ -1254,20 +1254,16 @@ const selectAi = async (options = {}) => {
|
|
|
1254
1254
|
} else { // Select by preference
|
|
1255
1255
|
options.aiId = options.aiId.filter(x => ais.find(y => y.id === x));
|
|
1256
1256
|
}
|
|
1257
|
-
options.aiId.length || (options.aiId = ais[0].id);
|
|
1257
|
+
options.aiId.length || (options.aiId = [ais[0].id]);
|
|
1258
1258
|
return options.aiId;
|
|
1259
1259
|
};
|
|
1260
1260
|
|
|
1261
1261
|
const talk = async (request, options = {}) => {
|
|
1262
|
-
|
|
1263
|
-
|
|
1262
|
+
// init
|
|
1263
|
+
const [sessionId, msgs, stream, SOUND_ICON]
|
|
1264
|
+
= [options.sessionId || newSessionId(), {}, options.stream, '🔊'];
|
|
1264
1265
|
await selectAi(options);
|
|
1265
|
-
|
|
1266
|
-
request = joinL2([ensureString(request), ...(options.collected || []).filter(
|
|
1267
|
-
x => x.type !== ATTACHMENT && String.isString(x.content)
|
|
1268
|
-
).map(x => x.content)]);
|
|
1269
|
-
const session = await getSession(sessionId, { ...options, prompt: request });
|
|
1270
|
-
const stream = options.stream;
|
|
1266
|
+
// init functions
|
|
1271
1267
|
const packMsg = (opts) => ({
|
|
1272
1268
|
text: Object.values(msgs).find(x => x.text) ? joinL2(options.aiId.map(n => {
|
|
1273
1269
|
if (msgs[n]?.ignored) { return null };
|
|
@@ -1290,7 +1286,16 @@ const talk = async (request, options = {}) => {
|
|
|
1290
1286
|
ai && r && (msgs[ai] = r);
|
|
1291
1287
|
stream && await stream(packMsg(opts));
|
|
1292
1288
|
};
|
|
1289
|
+
// first response
|
|
1293
1290
|
await multiStream(null, null, PROCESSING);
|
|
1291
|
+
// build prompt
|
|
1292
|
+
await collectAttachments(options);
|
|
1293
|
+
request = joinL2([ensureString(request), ...(options.collected || []).filter(
|
|
1294
|
+
x => x.type !== ATTACHMENT && String.isString(x.content)
|
|
1295
|
+
).map(x => x.content)]);
|
|
1296
|
+
// get session
|
|
1297
|
+
const session = await getSession(sessionId, { ...options, prompt: request });
|
|
1298
|
+
// prompt
|
|
1294
1299
|
await Promise.all(options.aiId.map(async ai => {
|
|
1295
1300
|
try {
|
|
1296
1301
|
return await prompt(request, {
|
|
@@ -1304,10 +1309,13 @@ const talk = async (request, options = {}) => {
|
|
|
1304
1309
|
log(e);
|
|
1305
1310
|
}
|
|
1306
1311
|
}));
|
|
1312
|
+
// pack response
|
|
1307
1313
|
const response = joinL2(Object.values(msgs).map(x => x.text));
|
|
1314
|
+
// save session
|
|
1308
1315
|
const chat = { request, response };
|
|
1309
1316
|
request && response && session.messages.push(chat);
|
|
1310
1317
|
await setSession(sessionId, session, options);
|
|
1318
|
+
// tts
|
|
1311
1319
|
if ((options?.tts || session?.config?.tts)
|
|
1312
1320
|
&& Object.values(msgs).find(x => !x.audio?.length)) {
|
|
1313
1321
|
await ignoreErrFunc(async () => {
|
|
@@ -1318,6 +1326,7 @@ const talk = async (request, options = {}) => {
|
|
|
1318
1326
|
}, { processing: true });
|
|
1319
1327
|
}, LOG);
|
|
1320
1328
|
}
|
|
1329
|
+
// return
|
|
1321
1330
|
return { sessionId, ...chat, ...packMsg({ processing: false }) };
|
|
1322
1331
|
};
|
|
1323
1332
|
|
|
@@ -1504,6 +1513,7 @@ export {
|
|
|
1504
1513
|
MODELS,
|
|
1505
1514
|
OPENAI_VOICE,
|
|
1506
1515
|
RETRIEVAL,
|
|
1516
|
+
TOP,
|
|
1507
1517
|
VEO_31,
|
|
1508
1518
|
analyzeSessions,
|
|
1509
1519
|
countTokens,
|
package/lib/manifest.mjs
CHANGED