utilitas 2001.1.104 → 2001.1.106
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 +6 -2
- package/lib/dbio.mjs +2 -2
- package/lib/manifest.mjs +1 -1
- package/lib/memory.mjs +12 -3
- package/package.json +1 -1
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
|
|
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] = [
|
package/lib/dbio.mjs
CHANGED
|
@@ -15,7 +15,7 @@ const RETURNING_ALL = ` RETURNING *`;
|
|
|
15
15
|
const [fieldId, fieldAny] = ['id', '*'];
|
|
16
16
|
const fieldCount = `COUNT(${fieldAny})`;
|
|
17
17
|
const direct = { direct: true };
|
|
18
|
-
const comparison = ['=', '>', '<', '<>', '!='];
|
|
18
|
+
const comparison = ['=', '>', '<', '<>', '!=', 'LIKE', 'NOT LIKE'];
|
|
19
19
|
const fieldNoQuote = [fieldAny, fieldCount];
|
|
20
20
|
const log = content => _log(content, import.meta.url);
|
|
21
21
|
const defaultKey = options => options && options.key ? options.key : fieldId;
|
|
@@ -356,7 +356,7 @@ const queryByKeyValue = async (table, key, value, options) => {
|
|
|
356
356
|
|
|
357
357
|
const queryById = async (table, id, options) => await queryByKeyValue(
|
|
358
358
|
table, defaultKey(options), id,
|
|
359
|
-
{ ...options || {}, unique: !Array.isArray(id) }
|
|
359
|
+
{ ...options || {}, unique: !Array.isArray(id) && !Object.isObject(id) }
|
|
360
360
|
);
|
|
361
361
|
|
|
362
362
|
const insert = async (table, fields, options) => {
|
package/lib/manifest.mjs
CHANGED
package/lib/memory.mjs
CHANGED
|
@@ -56,7 +56,9 @@ const handleResult = (resp, options) => {
|
|
|
56
56
|
ensureArray(resp).map(x => { x.value = unpack(x.value); });
|
|
57
57
|
let result = {};
|
|
58
58
|
if (Array.isArray(resp)) {
|
|
59
|
-
for (let i in resp) {
|
|
59
|
+
for (let i in resp) {
|
|
60
|
+
result[resp[i].key.split('/').pop()] = resp[i].value;
|
|
61
|
+
}
|
|
60
62
|
} else { result = resp?.value; }
|
|
61
63
|
resp = result;
|
|
62
64
|
}
|
|
@@ -72,8 +74,15 @@ const set = async (key, value, options) => {
|
|
|
72
74
|
|
|
73
75
|
const get = async (key, options) => {
|
|
74
76
|
options = { ...options || {}, ...defaultKey };
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
let result;
|
|
78
|
+
if ((key = assertKey(key, { ignoreError: true })) && !options?.asPrefix) {
|
|
79
|
+
result = queryById(table, key, options);
|
|
80
|
+
} else if (key && options?.asPrefix) {
|
|
81
|
+
result = queryById(table, { 'LIKE': `${key}/%` }, options);
|
|
82
|
+
} else {
|
|
83
|
+
result = queryAll(table, options);
|
|
84
|
+
}
|
|
85
|
+
return handleResult(await result, options);
|
|
77
86
|
};
|
|
78
87
|
|
|
79
88
|
const del = async (key, options) => {
|