utilitas 1998.2.44 → 1998.2.46
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 +18 -14
- package/lib/manifest.mjs +12 -12
- package/package.json +12 -12
package/lib/alan.mjs
CHANGED
|
@@ -645,8 +645,9 @@ const buildClaudeMessage = (text, options) => {
|
|
|
645
645
|
});
|
|
646
646
|
return String.isString(text) ? {
|
|
647
647
|
role: options?.role || user, content: [...attachments, {
|
|
648
|
-
type: TEXT, text,
|
|
649
|
-
|
|
648
|
+
type: TEXT, text, ...options.cache_control ? {
|
|
649
|
+
cache_control: { type: 'ephemeral' },
|
|
650
|
+
} : {},
|
|
650
651
|
}],
|
|
651
652
|
} : text;
|
|
652
653
|
};
|
|
@@ -771,8 +772,8 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
771
772
|
options.reasoning && !model?.reasoning
|
|
772
773
|
), `This model does not support reasoning: ${options.model}`);
|
|
773
774
|
let [systemPrompt, history, content, prompt, _system, _user, _assistant] = [
|
|
774
|
-
null, null, input || ATTACHMENTS, null,
|
|
775
|
-
{ role: system }, { role: user }, { role: assistant }
|
|
775
|
+
null, null, input || ATTACHMENTS, null, // length hack: ATTACHMENTS
|
|
776
|
+
{ role: system }, { role: user }, { role: assistant },
|
|
776
777
|
];
|
|
777
778
|
options.systemPrompt = options.systemPrompt || INSTRUCTIONS;
|
|
778
779
|
options.attachments = (
|
|
@@ -786,8 +787,8 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
786
787
|
prompt = buildGptMessage(content, options);
|
|
787
788
|
break;
|
|
788
789
|
case CLAUDE:
|
|
789
|
-
systemPrompt =
|
|
790
|
-
prompt = buildClaudeMessage(content, options)
|
|
790
|
+
systemPrompt = options.systemPrompt;
|
|
791
|
+
prompt = buildClaudeMessage(content, { ...options, cache_control: true });
|
|
791
792
|
break;
|
|
792
793
|
case OLLAMA:
|
|
793
794
|
systemPrompt = buildOllamaMessage(options.systemPrompt, _system);
|
|
@@ -801,7 +802,7 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
801
802
|
}
|
|
802
803
|
const msgBuilder = () => {
|
|
803
804
|
history = [];
|
|
804
|
-
(options.messages?.length ? options.messages : []).map(x => {
|
|
805
|
+
(options.messages?.length ? options.messages : []).map((x, i) => {
|
|
805
806
|
switch (options.flavor) {
|
|
806
807
|
case CHATGPT:
|
|
807
808
|
history.push(buildGptMessage(x.request, _user));
|
|
@@ -812,8 +813,8 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
812
813
|
history.push(buildClaudeMessage(x.response, _assistant));
|
|
813
814
|
break;
|
|
814
815
|
case OLLAMA:
|
|
815
|
-
history.push(
|
|
816
|
-
history.push(
|
|
816
|
+
history.push(buildOllamaMessage(x.request, _user));
|
|
817
|
+
history.push(buildOllamaMessage(x.response, _assistant));
|
|
817
818
|
break;
|
|
818
819
|
case GEMINI:
|
|
819
820
|
if (options.attachments?.length) { return; }
|
|
@@ -824,9 +825,11 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
824
825
|
});
|
|
825
826
|
switch (options.flavor) {
|
|
826
827
|
case CHATGPT: case CLAUDE: case OLLAMA:
|
|
827
|
-
history
|
|
828
|
-
|
|
829
|
-
|
|
828
|
+
history = messages([
|
|
829
|
+
...options.flavor === CLAUDE ? [] : [systemPrompt],
|
|
830
|
+
...history, prompt,
|
|
831
|
+
...options.toolsResult?.length ? options.toolsResult : []
|
|
832
|
+
]);
|
|
830
833
|
break;
|
|
831
834
|
case GEMINI:
|
|
832
835
|
history.push(
|
|
@@ -847,6 +850,7 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
847
850
|
content = trimTailing(trimTailing(content).slice(0, -1)) + '...';
|
|
848
851
|
}
|
|
849
852
|
}, model.maxInputTokens - options.attachments?.length * ATTACHMENT_TOKEN_COST);
|
|
853
|
+
print(JSON.stringify(history));
|
|
850
854
|
return { systemPrompt, history, prompt };
|
|
851
855
|
};
|
|
852
856
|
|
|
@@ -1045,11 +1049,11 @@ const promptClaude = async (content, options = {}) => {
|
|
|
1045
1049
|
[], false
|
|
1046
1050
|
];
|
|
1047
1051
|
const { client } = await getClaudeClient(options);
|
|
1048
|
-
const { history }
|
|
1052
|
+
const { systemPrompt: system, history }
|
|
1049
1053
|
= await buildPrompts(_MODEL, content, { ...options, flavor: CLAUDE });
|
|
1050
1054
|
const resp = await client.beta.messages.create({
|
|
1051
1055
|
model: options.model, max_tokens: _MODEL.maxOutputTokens, ...history,
|
|
1052
|
-
stream: true, ...options.reasoning ?? _MODEL?.reasoning ? {
|
|
1056
|
+
system, stream: true, ...options.reasoning ?? _MODEL?.reasoning ? {
|
|
1053
1057
|
thinking: options.thinking || { type: 'enabled', budget_tokens: 1024 },
|
|
1054
1058
|
} : {}, ..._MODEL?.tools ? { // https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
|
|
1055
1059
|
tools: options.tools ?? toolsClaude.map(x => x.def),
|
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": "1998.2.
|
|
4
|
+
"version": "1998.2.46",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -20,7 +20,7 @@ const manifest = {
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"file-type": "^20.4.0",
|
|
23
|
-
"mathjs": "^14.3.
|
|
23
|
+
"mathjs": "^14.3.1",
|
|
24
24
|
"uuid": "^11.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -32,36 +32,36 @@ const manifest = {
|
|
|
32
32
|
"@google-cloud/storage": "^7.15.2",
|
|
33
33
|
"@google-cloud/text-to-speech": "^5.8.1",
|
|
34
34
|
"@google-cloud/vision": "^4.3.3",
|
|
35
|
-
"@google/generative-ai": "^0.
|
|
35
|
+
"@google/generative-ai": "^0.24.0",
|
|
36
36
|
"@mozilla/readability": "github:mozilla/readability",
|
|
37
37
|
"@ngrok/ngrok": "^1.4.1",
|
|
38
|
-
"@sentry/node": "^9.
|
|
39
|
-
"@sentry/profiling-node": "^9.
|
|
38
|
+
"@sentry/node": "^9.5.0",
|
|
39
|
+
"@sentry/profiling-node": "^9.5.0",
|
|
40
40
|
"acme-client": "^5.4.0",
|
|
41
41
|
"browserify-fs": "^1.0.0",
|
|
42
42
|
"buffer": "^6.0.3",
|
|
43
43
|
"fast-geoip": "^1.1.88",
|
|
44
44
|
"fluent-ffmpeg": "^2.1.3",
|
|
45
45
|
"form-data": "^4.0.2",
|
|
46
|
-
"ioredis": "^5.
|
|
46
|
+
"ioredis": "^5.6.0",
|
|
47
47
|
"js-tiktoken": "^1.0.19",
|
|
48
48
|
"jsdom": "^26.0.0",
|
|
49
49
|
"lorem-ipsum": "^2.0.8",
|
|
50
|
-
"mailgun.js": "^12.0.
|
|
50
|
+
"mailgun.js": "^12.0.1",
|
|
51
51
|
"mailparser": "^3.7.2",
|
|
52
52
|
"mime": "^4.0.6",
|
|
53
|
-
"mysql2": "^3.
|
|
54
|
-
"node-mailjet": "^6.0.
|
|
53
|
+
"mysql2": "^3.13.0",
|
|
54
|
+
"node-mailjet": "^6.0.7",
|
|
55
55
|
"node-polyfill-webpack-plugin": "^4.1.0",
|
|
56
56
|
"office-text-extractor": "^3.0.3",
|
|
57
57
|
"ollama": "^0.5.14",
|
|
58
|
-
"openai": "^4.86.
|
|
58
|
+
"openai": "^4.86.2",
|
|
59
59
|
"pdfjs-dist": "^4.10.38",
|
|
60
60
|
"pg": "^8.13.3",
|
|
61
61
|
"pgvector": "^0.2.0",
|
|
62
62
|
"ping": "^0.4.4",
|
|
63
63
|
"process": "^0.11.10",
|
|
64
|
-
"puppeteer": "^24.
|
|
64
|
+
"puppeteer": "^24.4.0",
|
|
65
65
|
"say": "^0.16.0",
|
|
66
66
|
"telegraf": "^4.16.3",
|
|
67
67
|
"telesignsdk": "^3.0.2",
|
|
@@ -70,7 +70,7 @@ const manifest = {
|
|
|
70
70
|
"url": "github:Leask/node-url",
|
|
71
71
|
"webpack-cli": "^6.0.1",
|
|
72
72
|
"whisper-node": "^1.1.1",
|
|
73
|
-
"wrangler": "^3.
|
|
73
|
+
"wrangler": "^3.114.0",
|
|
74
74
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz",
|
|
75
75
|
"youtube-transcript": "^1.2.1"
|
|
76
76
|
}
|
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": "1998.2.
|
|
4
|
+
"version": "1998.2.46",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"file-type": "^20.4.0",
|
|
34
|
-
"mathjs": "^14.3.
|
|
34
|
+
"mathjs": "^14.3.1",
|
|
35
35
|
"uuid": "^11.1.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -43,36 +43,36 @@
|
|
|
43
43
|
"@google-cloud/storage": "^7.15.2",
|
|
44
44
|
"@google-cloud/text-to-speech": "^5.8.1",
|
|
45
45
|
"@google-cloud/vision": "^4.3.3",
|
|
46
|
-
"@google/generative-ai": "^0.
|
|
46
|
+
"@google/generative-ai": "^0.24.0",
|
|
47
47
|
"@mozilla/readability": "github:mozilla/readability",
|
|
48
48
|
"@ngrok/ngrok": "^1.4.1",
|
|
49
|
-
"@sentry/node": "^9.
|
|
50
|
-
"@sentry/profiling-node": "^9.
|
|
49
|
+
"@sentry/node": "^9.5.0",
|
|
50
|
+
"@sentry/profiling-node": "^9.5.0",
|
|
51
51
|
"acme-client": "^5.4.0",
|
|
52
52
|
"browserify-fs": "^1.0.0",
|
|
53
53
|
"buffer": "^6.0.3",
|
|
54
54
|
"fast-geoip": "^1.1.88",
|
|
55
55
|
"fluent-ffmpeg": "^2.1.3",
|
|
56
56
|
"form-data": "^4.0.2",
|
|
57
|
-
"ioredis": "^5.
|
|
57
|
+
"ioredis": "^5.6.0",
|
|
58
58
|
"js-tiktoken": "^1.0.19",
|
|
59
59
|
"jsdom": "^26.0.0",
|
|
60
60
|
"lorem-ipsum": "^2.0.8",
|
|
61
|
-
"mailgun.js": "^12.0.
|
|
61
|
+
"mailgun.js": "^12.0.1",
|
|
62
62
|
"mailparser": "^3.7.2",
|
|
63
63
|
"mime": "^4.0.6",
|
|
64
|
-
"mysql2": "^3.
|
|
65
|
-
"node-mailjet": "^6.0.
|
|
64
|
+
"mysql2": "^3.13.0",
|
|
65
|
+
"node-mailjet": "^6.0.7",
|
|
66
66
|
"node-polyfill-webpack-plugin": "^4.1.0",
|
|
67
67
|
"office-text-extractor": "^3.0.3",
|
|
68
68
|
"ollama": "^0.5.14",
|
|
69
|
-
"openai": "^4.86.
|
|
69
|
+
"openai": "^4.86.2",
|
|
70
70
|
"pdfjs-dist": "^4.10.38",
|
|
71
71
|
"pg": "^8.13.3",
|
|
72
72
|
"pgvector": "^0.2.0",
|
|
73
73
|
"ping": "^0.4.4",
|
|
74
74
|
"process": "^0.11.10",
|
|
75
|
-
"puppeteer": "^24.
|
|
75
|
+
"puppeteer": "^24.4.0",
|
|
76
76
|
"say": "^0.16.0",
|
|
77
77
|
"telegraf": "^4.16.3",
|
|
78
78
|
"telesignsdk": "^3.0.2",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"url": "github:Leask/node-url",
|
|
82
82
|
"webpack-cli": "^6.0.1",
|
|
83
83
|
"whisper-node": "^1.1.1",
|
|
84
|
-
"wrangler": "^3.
|
|
84
|
+
"wrangler": "^3.114.0",
|
|
85
85
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz",
|
|
86
86
|
"youtube-transcript": "^1.2.1"
|
|
87
87
|
}
|