utilitas 1999.1.52 → 1999.1.53
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 +1 -1
- package/lib/image.mjs +15 -14
- package/lib/manifest.mjs +13 -13
- package/package.json +13 -13
package/lib/alan.mjs
CHANGED
|
@@ -78,7 +78,7 @@ const [
|
|
|
78
78
|
'Azure Openai', 'Anthropic', 'Vertex Anthropic', 7680 * 4320, [], 10,
|
|
79
79
|
{ log: true }, 'Alan', 'user', 'system', 'assistant', 'model',
|
|
80
80
|
'json_object', 'tool', true, 'gemini-embedding-exp-03-07',
|
|
81
|
-
'Invalid file data.', 1.1, 100, 'Content is required.',
|
|
81
|
+
'Invalid file data.', 1.1, 100, 'Content is required.', 2048 * 2048,
|
|
82
82
|
x => 1024 * x, x => 1000 * x, x => 1024 * 1024 * x, x => 60 * x,
|
|
83
83
|
x => 60 * 60 * x, x => 1024 * 1024 * 1024 * x,
|
|
84
84
|
x => x.replace(/[\.\s]*$/, ''), { embedding: true },
|
package/lib/image.mjs
CHANGED
|
@@ -3,10 +3,12 @@ import { MIME_PNG, convert } from './storage.mjs';
|
|
|
3
3
|
|
|
4
4
|
const _NEED = ['OpenAI'];
|
|
5
5
|
|
|
6
|
-
const [
|
|
7
|
-
|
|
6
|
+
const [
|
|
7
|
+
clients, OPENAI, GEMINI, BASE64, BUFFER, ERROR_GENERATING, IMAGEN_MODEL,
|
|
8
|
+
OPENAI_MODEL,
|
|
9
|
+
] = [
|
|
8
10
|
{}, 'OPENAI', 'GEMINI', 'BASE64', 'BUFFER', 'Error generating image.',
|
|
9
|
-
'imagen-3.0-generate-002',
|
|
11
|
+
'imagen-3.0-generate-002', 'gpt-image-1',
|
|
10
12
|
];
|
|
11
13
|
|
|
12
14
|
const init = async (options) => {
|
|
@@ -36,6 +38,7 @@ const generate = async (prompt, options) => {
|
|
|
36
38
|
if (!provider && clients?.[GEMINI]) { provider = GEMINI; }
|
|
37
39
|
if (!provider && clients?.[OPENAI]) { provider = OPENAI; }
|
|
38
40
|
const client = clients?.[provider];
|
|
41
|
+
const n = options?.n || 4;
|
|
39
42
|
assert(client, 'No available image generation provider.');
|
|
40
43
|
prompt = ensureString(prompt);
|
|
41
44
|
assert(prompt.length <= 4000,
|
|
@@ -46,20 +49,18 @@ const generate = async (prompt, options) => {
|
|
|
46
49
|
...options || {},
|
|
47
50
|
expected: ensureString(options?.expected || BUFFER, { case: 'LOW' }),
|
|
48
51
|
};
|
|
49
|
-
|
|
50
|
-
try {
|
|
52
|
+
try { // https://platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1
|
|
51
53
|
var resp = await client.generate({
|
|
52
|
-
prompt, model:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
// user: '',
|
|
54
|
+
prompt, model: OPENAI_MODEL, n, quality: 'high',
|
|
55
|
+
size: '1536x1024', moderation: 'low',
|
|
56
|
+
// 1024x1024 (square), 1536x1024 (landscape), 1024x1536 (portrait), auto (default)
|
|
57
|
+
// background: 'transparent',
|
|
57
58
|
...options?.params || {},
|
|
58
59
|
});
|
|
59
60
|
} catch (err) { throwError(err?.message || ERROR_GENERATING); }
|
|
60
|
-
if (!options?.raw
|
|
61
|
+
if (!options?.raw) {
|
|
61
62
|
resp.data = await Promise.all(resp.data.map(async x => ({
|
|
62
|
-
caption:
|
|
63
|
+
caption: `🎨 by ${OPENAI_MODEL}`,
|
|
63
64
|
data: await extractImage(x.b64_json, options),
|
|
64
65
|
mimeType: MIME_PNG,
|
|
65
66
|
})));
|
|
@@ -73,7 +74,7 @@ const generate = async (prompt, options) => {
|
|
|
73
74
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
74
75
|
body: JSON.stringify({
|
|
75
76
|
instances: [{ prompt }], parameters: {
|
|
76
|
-
sampleCount:
|
|
77
|
+
sampleCount: n, aspectRatio: '16:9',
|
|
77
78
|
...options?.params || {},
|
|
78
79
|
}, // "1:1" (default), "3:4", "4:3", "9:16", and "16:9"
|
|
79
80
|
})
|
|
@@ -82,7 +83,7 @@ const generate = async (prompt, options) => {
|
|
|
82
83
|
if (!options?.raw) {
|
|
83
84
|
resp = await Promise.all((resp?.predictions || []).map(
|
|
84
85
|
async x => ({
|
|
85
|
-
caption: `🎨 by ${IMAGEN_MODEL}`,
|
|
86
|
+
caption: `🎨 by ${IMAGEN_MODEL}`,
|
|
86
87
|
data: await extractImage(x.bytesBase64Encoded, options),
|
|
87
88
|
mimeType: x.mimeType,
|
|
88
89
|
})
|
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": "1999.1.
|
|
4
|
+
"version": "1999.1.53",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -19,12 +19,12 @@ const manifest = {
|
|
|
19
19
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"file-type": "^20.
|
|
22
|
+
"file-type": "^20.5.0",
|
|
23
23
|
"mathjs": "^14.4.0",
|
|
24
24
|
"uuid": "^11.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@anthropic-ai/sdk": "^0.
|
|
27
|
+
"@anthropic-ai/sdk": "^0.40.1",
|
|
28
28
|
"@anthropic-ai/vertex-sdk": "^0.7.0",
|
|
29
29
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
30
30
|
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
@@ -32,10 +32,10 @@ const manifest = {
|
|
|
32
32
|
"@google-cloud/storage": "^7.16.0",
|
|
33
33
|
"@google-cloud/text-to-speech": "^6.0.1",
|
|
34
34
|
"@google-cloud/vision": "^5.1.0",
|
|
35
|
-
"@google/genai": "^0.
|
|
35
|
+
"@google/genai": "^0.10.0",
|
|
36
36
|
"@mozilla/readability": "github:mozilla/readability",
|
|
37
|
-
"@sentry/node": "^9.
|
|
38
|
-
"@sentry/profiling-node": "^9.
|
|
37
|
+
"@sentry/node": "^9.15.0",
|
|
38
|
+
"@sentry/profiling-node": "^9.15.0",
|
|
39
39
|
"acme-client": "^5.4.0",
|
|
40
40
|
"browserify-fs": "^1.0.0",
|
|
41
41
|
"buffer": "^6.0.3",
|
|
@@ -43,23 +43,23 @@ const manifest = {
|
|
|
43
43
|
"fluent-ffmpeg": "^2.1.3",
|
|
44
44
|
"form-data": "^4.0.2",
|
|
45
45
|
"ioredis": "^5.6.1",
|
|
46
|
-
"js-tiktoken": "^1.0.
|
|
46
|
+
"js-tiktoken": "^1.0.20",
|
|
47
47
|
"jsdom": "^26.1.0",
|
|
48
48
|
"lorem-ipsum": "^2.0.8",
|
|
49
49
|
"mailgun.js": "^12.0.1",
|
|
50
50
|
"mailparser": "^3.7.2",
|
|
51
51
|
"mime": "^4.0.7",
|
|
52
|
-
"mysql2": "^3.14.
|
|
52
|
+
"mysql2": "^3.14.1",
|
|
53
53
|
"node-mailjet": "^6.0.8",
|
|
54
54
|
"node-polyfill-webpack-plugin": "^4.1.0",
|
|
55
55
|
"office-text-extractor": "^3.0.3",
|
|
56
|
-
"openai": "^4.
|
|
57
|
-
"pdfjs-dist": "^5.
|
|
58
|
-
"pg": "^8.
|
|
56
|
+
"openai": "^4.96.2",
|
|
57
|
+
"pdfjs-dist": "^5.2.133",
|
|
58
|
+
"pg": "^8.15.6",
|
|
59
59
|
"pgvector": "^0.2.0",
|
|
60
60
|
"ping": "^0.4.4",
|
|
61
61
|
"process": "^0.11.10",
|
|
62
|
-
"puppeteer": "^24.
|
|
62
|
+
"puppeteer": "^24.7.2",
|
|
63
63
|
"say": "^0.16.0",
|
|
64
64
|
"telegraf": "^4.16.3",
|
|
65
65
|
"telesignsdk": "^3.0.2",
|
|
@@ -68,7 +68,7 @@ const manifest = {
|
|
|
68
68
|
"url": "github:Leask/node-url",
|
|
69
69
|
"webpack-cli": "^6.0.1",
|
|
70
70
|
"whisper-node": "^1.1.1",
|
|
71
|
-
"wrangler": "^4.
|
|
71
|
+
"wrangler": "^4.14.0",
|
|
72
72
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz",
|
|
73
73
|
"youtube-transcript": "^1.2.1"
|
|
74
74
|
}
|
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": "1999.1.
|
|
4
|
+
"version": "1999.1.53",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"file-type": "^20.
|
|
33
|
+
"file-type": "^20.5.0",
|
|
34
34
|
"mathjs": "^14.4.0",
|
|
35
35
|
"uuid": "^11.1.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@anthropic-ai/sdk": "^0.
|
|
38
|
+
"@anthropic-ai/sdk": "^0.40.1",
|
|
39
39
|
"@anthropic-ai/vertex-sdk": "^0.7.0",
|
|
40
40
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
41
41
|
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"@google-cloud/storage": "^7.16.0",
|
|
44
44
|
"@google-cloud/text-to-speech": "^6.0.1",
|
|
45
45
|
"@google-cloud/vision": "^5.1.0",
|
|
46
|
-
"@google/genai": "^0.
|
|
46
|
+
"@google/genai": "^0.10.0",
|
|
47
47
|
"@mozilla/readability": "github:mozilla/readability",
|
|
48
|
-
"@sentry/node": "^9.
|
|
49
|
-
"@sentry/profiling-node": "^9.
|
|
48
|
+
"@sentry/node": "^9.15.0",
|
|
49
|
+
"@sentry/profiling-node": "^9.15.0",
|
|
50
50
|
"acme-client": "^5.4.0",
|
|
51
51
|
"browserify-fs": "^1.0.0",
|
|
52
52
|
"buffer": "^6.0.3",
|
|
@@ -54,23 +54,23 @@
|
|
|
54
54
|
"fluent-ffmpeg": "^2.1.3",
|
|
55
55
|
"form-data": "^4.0.2",
|
|
56
56
|
"ioredis": "^5.6.1",
|
|
57
|
-
"js-tiktoken": "^1.0.
|
|
57
|
+
"js-tiktoken": "^1.0.20",
|
|
58
58
|
"jsdom": "^26.1.0",
|
|
59
59
|
"lorem-ipsum": "^2.0.8",
|
|
60
60
|
"mailgun.js": "^12.0.1",
|
|
61
61
|
"mailparser": "^3.7.2",
|
|
62
62
|
"mime": "^4.0.7",
|
|
63
|
-
"mysql2": "^3.14.
|
|
63
|
+
"mysql2": "^3.14.1",
|
|
64
64
|
"node-mailjet": "^6.0.8",
|
|
65
65
|
"node-polyfill-webpack-plugin": "^4.1.0",
|
|
66
66
|
"office-text-extractor": "^3.0.3",
|
|
67
|
-
"openai": "^4.
|
|
68
|
-
"pdfjs-dist": "^5.
|
|
69
|
-
"pg": "^8.
|
|
67
|
+
"openai": "^4.96.2",
|
|
68
|
+
"pdfjs-dist": "^5.2.133",
|
|
69
|
+
"pg": "^8.15.6",
|
|
70
70
|
"pgvector": "^0.2.0",
|
|
71
71
|
"ping": "^0.4.4",
|
|
72
72
|
"process": "^0.11.10",
|
|
73
|
-
"puppeteer": "^24.
|
|
73
|
+
"puppeteer": "^24.7.2",
|
|
74
74
|
"say": "^0.16.0",
|
|
75
75
|
"telegraf": "^4.16.3",
|
|
76
76
|
"telesignsdk": "^3.0.2",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"url": "github:Leask/node-url",
|
|
80
80
|
"webpack-cli": "^6.0.1",
|
|
81
81
|
"whisper-node": "^1.1.1",
|
|
82
|
-
"wrangler": "^4.
|
|
82
|
+
"wrangler": "^4.14.0",
|
|
83
83
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.1/xlsx-0.20.1.tgz",
|
|
84
84
|
"youtube-transcript": "^1.2.1"
|
|
85
85
|
}
|