utilitas 2001.1.102 → 2001.1.104
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 +5 -4
- package/lib/manifest.mjs +1 -1
- package/lib/utilitas.mjs +6 -4
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -1360,9 +1360,10 @@ const talk = async (request, options = {}) => {
|
|
|
1360
1360
|
// init
|
|
1361
1361
|
const [sessionId, msgs, stream]
|
|
1362
1362
|
= [options.sessionId || newSessionId(), {}, options.stream];
|
|
1363
|
+
let result;
|
|
1363
1364
|
await selectAi(options);
|
|
1364
1365
|
// init functions
|
|
1365
|
-
const packMsg = (opts) =>
|
|
1366
|
+
const packMsg = (opts) => result = {
|
|
1366
1367
|
text: Object.values(msgs).find(x => x.text) ? joinL2(options.aiId.map(n => {
|
|
1367
1368
|
if (msgs[n]?.ignored) { return null };
|
|
1368
1369
|
const ai = ais.find(x => x.id === n);
|
|
@@ -1379,7 +1380,7 @@ const talk = async (request, options = {}) => {
|
|
|
1379
1380
|
videos: Object.values(msgs).map(x => (x.videos || []).map(y => caption(y, FEATURE_ICONS.video, x.model))).flat(),
|
|
1380
1381
|
annotations: Object.values(msgs).map(x => x.annotations || []).flat(),
|
|
1381
1382
|
models: Object.values(msgs).map(x => x.model),
|
|
1382
|
-
}
|
|
1383
|
+
};
|
|
1383
1384
|
const multiStream = async (ai, r, opts) => {
|
|
1384
1385
|
ai && r && (msgs[ai] = r);
|
|
1385
1386
|
stream && await stream(packMsg(opts));
|
|
@@ -1414,12 +1415,12 @@ const talk = async (request, options = {}) => {
|
|
|
1414
1415
|
request && response && session.messages.push(chat);
|
|
1415
1416
|
await setSession(sessionId, session, options);
|
|
1416
1417
|
// tts
|
|
1417
|
-
if ((options?.tts || session?.config?.tts) &&
|
|
1418
|
+
if ((options?.tts || session?.config?.tts) && result?.spoken
|
|
1418
1419
|
&& Object.values(msgs).find(x => !x.audio?.length)) {
|
|
1419
1420
|
await ignoreErrFunc(async () => {
|
|
1420
1421
|
const ttsAi = await getAi(null, { select: { audio: true, fast: true } });
|
|
1421
1422
|
await multiStream(ttsAi.id, {
|
|
1422
|
-
...await tts(
|
|
1423
|
+
...await tts(result?.spoken, { aiId: ttsAi.id, raw: true }),
|
|
1423
1424
|
text: FEATURE_ICONS.audio, hidden: true,
|
|
1424
1425
|
}, { processing: true });
|
|
1425
1426
|
}, LOG);
|
package/lib/manifest.mjs
CHANGED
package/lib/utilitas.mjs
CHANGED
|
@@ -850,12 +850,14 @@ const getLockKey = key => {
|
|
|
850
850
|
};
|
|
851
851
|
|
|
852
852
|
const lock = async (key, options) => {
|
|
853
|
-
|
|
854
|
-
while (new Date().getTime()
|
|
855
|
-
< (options?.timeout || 1000)) {
|
|
853
|
+
const stdKey = getLockKey(key);
|
|
854
|
+
while (new Date().getTime() < parseInt(LOCKS?.[stdKey] || 0)) {
|
|
856
855
|
await timeout(options?.checkInterval || 1000);
|
|
857
856
|
}
|
|
858
|
-
return
|
|
857
|
+
return {
|
|
858
|
+
time: LOCKS[stdKey] = new Date().getTime() + (options?.timeout || 1000),
|
|
859
|
+
unlock: () => unlock(key),
|
|
860
|
+
};
|
|
859
861
|
};
|
|
860
862
|
|
|
861
863
|
export {
|