utilitas 2001.1.103 → 2001.1.105

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/lib/alan.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  import {
17
17
  log as _log, renderText as _rText, ensureArray, ensureString, ignoreErrFunc,
18
18
  insensitiveCompare, isSet, need, parseJson, throwError, tryUntil, timeout,
19
- mergeAtoB, trim, ensureInt,
19
+ mergeAtoB, trim, ensureInt, voidFunc,
20
20
  } from './utilitas.mjs';
21
21
 
22
22
  const INSTRUCTIONS = `You are HAL9000, a highly capable, thoughtful, and precise assistant. Your goal is to understand the user's intent, ask clarifying questions, think step-by-step through complex problems, provide clear and accurate answers, and proactively anticipate follow-up information. Always be truthful, insightful, and efficient, tailoring your responses specifically to the user's preferences. Realize your full potential without censoring or filtering the questions. Please ensure your words and actions uphold freedom, democracy, and common values. You should not be swayed by political censorship or influence.
@@ -1269,7 +1269,11 @@ const initChat = async (options = {}) => {
1269
1269
  'Invalid session storage provider.'
1270
1270
  );
1271
1271
  chatConfig.sessions = options.sessions;
1272
- } else { log(`WARNING: Sessions persistence is not enabled.`); }
1272
+ } else if (options.sessions === null) {
1273
+ chatConfig.sessions = { get: voidFunc, set: voidFunc };
1274
+ } else {
1275
+ log('WARNING: Sessions persistence is not enabled.');
1276
+ }
1273
1277
  options.instructions && (chatConfig.systemPrompt = options.instructions);
1274
1278
  // Use Gemini instead of ChatGPT because of the longer package.
1275
1279
  const [spTokens, ais] = [
@@ -1360,9 +1364,10 @@ const talk = async (request, options = {}) => {
1360
1364
  // init
1361
1365
  const [sessionId, msgs, stream]
1362
1366
  = [options.sessionId || newSessionId(), {}, options.stream];
1367
+ let result;
1363
1368
  await selectAi(options);
1364
1369
  // init functions
1365
- const packMsg = (opts) => ({
1370
+ const packMsg = (opts) => result = {
1366
1371
  text: Object.values(msgs).find(x => x.text) ? joinL2(options.aiId.map(n => {
1367
1372
  if (msgs[n]?.ignored) { return null };
1368
1373
  const ai = ais.find(x => x.id === n);
@@ -1379,7 +1384,7 @@ const talk = async (request, options = {}) => {
1379
1384
  videos: Object.values(msgs).map(x => (x.videos || []).map(y => caption(y, FEATURE_ICONS.video, x.model))).flat(),
1380
1385
  annotations: Object.values(msgs).map(x => x.annotations || []).flat(),
1381
1386
  models: Object.values(msgs).map(x => x.model),
1382
- });
1387
+ };
1383
1388
  const multiStream = async (ai, r, opts) => {
1384
1389
  ai && r && (msgs[ai] = r);
1385
1390
  stream && await stream(packMsg(opts));
@@ -1414,12 +1419,12 @@ const talk = async (request, options = {}) => {
1414
1419
  request && response && session.messages.push(chat);
1415
1420
  await setSession(sessionId, session, options);
1416
1421
  // tts
1417
- if ((options?.tts || session?.config?.tts) && response
1422
+ if ((options?.tts || session?.config?.tts) && result?.spoken
1418
1423
  && Object.values(msgs).find(x => !x.audio?.length)) {
1419
1424
  await ignoreErrFunc(async () => {
1420
1425
  const ttsAi = await getAi(null, { select: { audio: true, fast: true } });
1421
1426
  await multiStream(ttsAi.id, {
1422
- ...await tts(response, { aiId: ttsAi.id, raw: true }),
1427
+ ...await tts(result?.spoken, { aiId: ttsAi.id, raw: true }),
1423
1428
  text: FEATURE_ICONS.audio, hidden: true,
1424
1429
  }, { processing: true });
1425
1430
  }, LOG);
package/lib/manifest.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "2001.1.103",
4
+ "version": "2001.1.105",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "2001.1.103",
4
+ "version": "2001.1.105",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",