utilitas 1995.2.72 → 1995.2.73
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 -1
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +18 -26
- package/lib/manifest.mjs +9 -8
- package/package.json +9 -8
package/lib/alan.mjs
CHANGED
|
@@ -4,12 +4,12 @@ import { loop, end } from './event.mjs';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
ensureString, ignoreErrFunc, log as _log, need, renderText as _renderText,
|
|
7
|
-
throwError,
|
|
7
|
+
throwError,
|
|
8
8
|
} from './utilitas.mjs';
|
|
9
9
|
|
|
10
10
|
const _NEED = [
|
|
11
11
|
'@google-cloud/aiplatform', '@google-cloud/vertexai',
|
|
12
|
-
'@google/generative-ai', 'js-tiktoken', 'OpenAI',
|
|
12
|
+
'@google/generative-ai', 'js-tiktoken', 'ollama', 'OpenAI',
|
|
13
13
|
];
|
|
14
14
|
|
|
15
15
|
const [
|
|
@@ -260,8 +260,11 @@ const init = async (options) => {
|
|
|
260
260
|
}
|
|
261
261
|
break;
|
|
262
262
|
case OLLAMA:
|
|
263
|
+
const Ollama = await need('ollama');
|
|
263
264
|
clients[provider] = {
|
|
264
|
-
|
|
265
|
+
// @todo: this feature does not work yet.
|
|
266
|
+
// client: new Ollama({ host: options?.endpoint })
|
|
267
|
+
client: Ollama,
|
|
265
268
|
};
|
|
266
269
|
break;
|
|
267
270
|
default:
|
|
@@ -363,32 +366,21 @@ const promptChatGPT = async (content, options) => {
|
|
|
363
366
|
};
|
|
364
367
|
|
|
365
368
|
const promptOllama = async (content, options) => {
|
|
366
|
-
|
|
369
|
+
const { client } = await getOllamaClient(options);
|
|
367
370
|
// https://github.com/ollama/ollama-js
|
|
368
|
-
const { endpoint } = await getOllamaClient(options);
|
|
369
371
|
// https://github.com/jmorganca/ollama/blob/main/examples/typescript-simplechat/client.ts
|
|
370
|
-
const resp = await
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}),
|
|
375
|
-
});
|
|
376
|
-
const reader = resp.body?.getReader();
|
|
377
|
-
reader || throwError('Failed to request Ollama API.');
|
|
372
|
+
const resp = await client.chat({
|
|
373
|
+
model: options?.model || DEFAULT_MODELS[OLLAMA], stream: true,
|
|
374
|
+
...messages([...options?.messages || [], buildGptMessage(content)]),
|
|
375
|
+
})
|
|
378
376
|
let [chunk, result] = [null, ''];
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
chunk.done || await ignoreErrFunc(async () =>
|
|
387
|
-
await options?.stream?.(
|
|
388
|
-
options?.raw ? chunk : packResp(result)
|
|
389
|
-
), LOG
|
|
390
|
-
);
|
|
391
|
-
}
|
|
377
|
+
for await (chunk of resp) {
|
|
378
|
+
result += chunk.message?.content || '';
|
|
379
|
+
chunk.done || await ignoreErrFunc(async () =>
|
|
380
|
+
await options?.stream?.(
|
|
381
|
+
options?.raw ? chunk : packResp(result)
|
|
382
|
+
), LOG
|
|
383
|
+
);
|
|
392
384
|
}
|
|
393
385
|
return { response: options?.raw ? chunk : packResp(result) };
|
|
394
386
|
};
|
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": "1995.2.
|
|
4
|
+
"version": "1995.2.73",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -26,16 +26,16 @@ const manifest = {
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
28
28
|
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
29
|
-
"@google-cloud/aiplatform": "^3.10.
|
|
30
|
-
"@google-cloud/speech": "^6.1.
|
|
29
|
+
"@google-cloud/aiplatform": "^3.10.1",
|
|
30
|
+
"@google-cloud/speech": "^6.1.1",
|
|
31
31
|
"@google-cloud/storage": "^7.7.0",
|
|
32
32
|
"@google-cloud/text-to-speech": "^5.0.2",
|
|
33
33
|
"@google-cloud/vertexai": "^0.2.1",
|
|
34
|
-
"@google-cloud/vision": "^4.0.
|
|
34
|
+
"@google-cloud/vision": "^4.0.3",
|
|
35
35
|
"@google/generative-ai": "^0.1.3",
|
|
36
36
|
"@mozilla/readability": "^0.5.0",
|
|
37
37
|
"@ngrok/ngrok": "^0.9.1",
|
|
38
|
-
"@sentry/node": "^7.
|
|
38
|
+
"@sentry/node": "^7.98.0",
|
|
39
39
|
"acme-client": "^5.2.0",
|
|
40
40
|
"browserify-fs": "^1.0.0",
|
|
41
41
|
"buffer": "^6.0.3",
|
|
@@ -49,11 +49,12 @@ const manifest = {
|
|
|
49
49
|
"mailgun.js": "^10.0.0",
|
|
50
50
|
"mailparser": "^3.6.6",
|
|
51
51
|
"mime-types": "^2.1.35",
|
|
52
|
-
"mysql2": "^3.
|
|
52
|
+
"mysql2": "^3.9.0",
|
|
53
53
|
"node-mailjet": "^6.0.5",
|
|
54
54
|
"node-polyfill-webpack-plugin": "^3.0.0",
|
|
55
55
|
"office-text-extractor": "^3.0.2",
|
|
56
|
-
"
|
|
56
|
+
"ollama": "^0.4.3",
|
|
57
|
+
"openai": "^4.26.0",
|
|
57
58
|
"pdfjs-dist": "^4.0.379",
|
|
58
59
|
"pg": "^8.11.3",
|
|
59
60
|
"pgvector": "^0.1.7",
|
|
@@ -62,7 +63,7 @@ const manifest = {
|
|
|
62
63
|
"telegraf": "^4.15.3",
|
|
63
64
|
"telesignsdk": "^2.2.3",
|
|
64
65
|
"tesseract.js": "^5.0.4",
|
|
65
|
-
"twilio": "^4.
|
|
66
|
+
"twilio": "^4.21.0",
|
|
66
67
|
"url": "github:Leask/node-url",
|
|
67
68
|
"webpack-cli": "^5.1.4",
|
|
68
69
|
"whisper-node": "^1.1.1",
|
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": "1995.2.
|
|
4
|
+
"version": "1995.2.73",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
39
39
|
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
40
|
-
"@google-cloud/aiplatform": "^3.10.
|
|
41
|
-
"@google-cloud/speech": "^6.1.
|
|
40
|
+
"@google-cloud/aiplatform": "^3.10.1",
|
|
41
|
+
"@google-cloud/speech": "^6.1.1",
|
|
42
42
|
"@google-cloud/storage": "^7.7.0",
|
|
43
43
|
"@google-cloud/text-to-speech": "^5.0.2",
|
|
44
44
|
"@google-cloud/vertexai": "^0.2.1",
|
|
45
|
-
"@google-cloud/vision": "^4.0.
|
|
45
|
+
"@google-cloud/vision": "^4.0.3",
|
|
46
46
|
"@google/generative-ai": "^0.1.3",
|
|
47
47
|
"@mozilla/readability": "^0.5.0",
|
|
48
48
|
"@ngrok/ngrok": "^0.9.1",
|
|
49
|
-
"@sentry/node": "^7.
|
|
49
|
+
"@sentry/node": "^7.98.0",
|
|
50
50
|
"acme-client": "^5.2.0",
|
|
51
51
|
"browserify-fs": "^1.0.0",
|
|
52
52
|
"buffer": "^6.0.3",
|
|
@@ -60,11 +60,12 @@
|
|
|
60
60
|
"mailgun.js": "^10.0.0",
|
|
61
61
|
"mailparser": "^3.6.6",
|
|
62
62
|
"mime-types": "^2.1.35",
|
|
63
|
-
"mysql2": "^3.
|
|
63
|
+
"mysql2": "^3.9.0",
|
|
64
64
|
"node-mailjet": "^6.0.5",
|
|
65
65
|
"node-polyfill-webpack-plugin": "^3.0.0",
|
|
66
66
|
"office-text-extractor": "^3.0.2",
|
|
67
|
-
"
|
|
67
|
+
"ollama": "^0.4.3",
|
|
68
|
+
"openai": "^4.26.0",
|
|
68
69
|
"pdfjs-dist": "^4.0.379",
|
|
69
70
|
"pg": "^8.11.3",
|
|
70
71
|
"pgvector": "^0.1.7",
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
"telegraf": "^4.15.3",
|
|
74
75
|
"telesignsdk": "^2.2.3",
|
|
75
76
|
"tesseract.js": "^5.0.4",
|
|
76
|
-
"twilio": "^4.
|
|
77
|
+
"twilio": "^4.21.0",
|
|
77
78
|
"url": "github:Leask/node-url",
|
|
78
79
|
"webpack-cli": "^5.1.4",
|
|
79
80
|
"whisper-node": "^1.1.1",
|