utilitas 2000.3.49 → 2000.3.52
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 +2 -1
- package/lib/manifest.mjs +1 -1
- package/lib/storage.mjs +13 -11
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -1220,7 +1220,7 @@ const initChat = async (options = {}) => {
|
|
|
1220
1220
|
'Invalid session storage provider.'
|
|
1221
1221
|
);
|
|
1222
1222
|
chatConfig.sessions = options.sessions;
|
|
1223
|
-
}
|
|
1223
|
+
} else { log(`WARNING: Sessions persistence is not enabled.`); }
|
|
1224
1224
|
options.instructions && (chatConfig.systemPrompt = options.instructions);
|
|
1225
1225
|
// Use Gemini instead of ChatGPT because of the longer package.
|
|
1226
1226
|
const [spTokens, ais] = await Promise.all([countTokens([await buildMessage(
|
|
@@ -1446,6 +1446,7 @@ export {
|
|
|
1446
1446
|
prompt,
|
|
1447
1447
|
promptOpenRouter,
|
|
1448
1448
|
resetSession,
|
|
1449
|
+
setSession,
|
|
1449
1450
|
stt,
|
|
1450
1451
|
talk,
|
|
1451
1452
|
trimPrompt,
|
package/lib/manifest.mjs
CHANGED
package/lib/storage.mjs
CHANGED
|
@@ -119,18 +119,20 @@ const assertPath = async (path, type, mode, msg, code, options) => {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
const isTextFile = async (file, options) => {
|
|
122
|
-
const
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
)
|
|
122
|
+
const maxBytes = options?.length ?? 1000;
|
|
123
|
+
let buf;
|
|
124
|
+
if (Buffer.isBuffer(file)) {
|
|
125
|
+
buf = file.subarray(0, maxBytes);
|
|
126
|
+
} else {
|
|
127
|
+
const fd = await fs.promises.open(file, 'r');
|
|
128
|
+
buf = Buffer.alloc(maxBytes);
|
|
129
|
+
await fd.read(buf, 0, maxBytes, 0);
|
|
130
|
+
await fd.close();
|
|
131
|
+
}
|
|
132
|
+
for (let i = 0; i < buf.length; i++) {
|
|
133
|
+
if (buf[i] === 0) return false;
|
|
131
134
|
}
|
|
132
|
-
|
|
133
|
-
return res;
|
|
135
|
+
return true;
|
|
134
136
|
};
|
|
135
137
|
|
|
136
138
|
const getConfigFilename = async (options) => {
|