utilitas 1999.1.52 → 1999.1.54

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/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.', 2000 * 768,
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 [clients, OPENAI, GEMINI, BASE64, BUFFER, ERROR_GENERATING, IMAGEN_MODEL]
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,44 +38,42 @@ 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,
42
45
  'Prompt must be less than 4000 characters.', 400);
46
+ options = {
47
+ ...options || {},
48
+ expected: ensureString(options?.expected || BUFFER, { case: 'LOW' }),
49
+ };
43
50
  switch (provider) {
44
51
  case OPENAI:
45
- options = {
46
- ...options || {},
47
- expected: ensureString(options?.expected || BUFFER, { case: 'LOW' }),
48
- };
49
- const asUrl = options.expected === 'url';
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: 'dall-e-3', n: 1, quality: 'hd',
53
- response_format: asUrl ? 'url' : 'b64_json',
54
- size: '1792x1024', // 1024x1024, 1792x1024, or 1024x1792
55
- // style: 'vivid', // or 'natural'
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 && !asUrl) {
61
+ if (!options?.raw) {
61
62
  resp.data = await Promise.all(resp.data.map(async x => ({
62
- caption: x.revised_prompt, tts: x.revised_prompt,
63
+ caption: `🎨 by [${OPENAI_MODEL}](https://deepmind.google/technologies/imagen-3/)`,
63
64
  data: await extractImage(x.b64_json, options),
64
65
  mimeType: MIME_PNG,
65
66
  })));
66
67
  }
67
68
  return resp?.data;
68
69
  case GEMINI:
69
- options.expected === 'URL' && (options.expected = 'FILE');
70
70
  var resp = await (await fetch(
71
71
  'https://generativelanguage.googleapis.com/v1beta/models/'
72
72
  + `${IMAGEN_MODEL}:predict?key=${client.apiKey}`, {
73
73
  method: 'POST', headers: { 'Content-Type': 'application/json' },
74
74
  body: JSON.stringify({
75
75
  instances: [{ prompt }], parameters: {
76
- sampleCount: 4, aspectRatio: '16:9',
76
+ sampleCount: n, aspectRatio: '16:9',
77
77
  ...options?.params || {},
78
78
  }, // "1:1" (default), "3:4", "4:3", "9:16", and "16:9"
79
79
  })
@@ -82,7 +82,7 @@ const generate = async (prompt, options) => {
82
82
  if (!options?.raw) {
83
83
  resp = await Promise.all((resp?.predictions || []).map(
84
84
  async x => ({
85
- caption: `🎨 by ${IMAGEN_MODEL}`, tts: null,
85
+ caption: `🎨 by [${IMAGEN_MODEL}](https://openai.com/index/image-generation-api/)`,
86
86
  data: await extractImage(x.bytesBase64Encoded, options),
87
87
  mimeType: x.mimeType,
88
88
  })
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.52",
4
+ "version": "1999.1.54",
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.4.1",
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.39.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.9.0",
35
+ "@google/genai": "^0.10.0",
36
36
  "@mozilla/readability": "github:mozilla/readability",
37
- "@sentry/node": "^9.13.0",
38
- "@sentry/profiling-node": "^9.13.0",
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.19",
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.0",
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.95.0",
57
- "pdfjs-dist": "^5.1.91",
58
- "pg": "^8.14.1",
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.6.1",
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.12.0",
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.52",
4
+ "version": "1999.1.54",
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.4.1",
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.39.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.9.0",
46
+ "@google/genai": "^0.10.0",
47
47
  "@mozilla/readability": "github:mozilla/readability",
48
- "@sentry/node": "^9.13.0",
49
- "@sentry/profiling-node": "^9.13.0",
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.19",
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.0",
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.95.0",
68
- "pdfjs-dist": "^5.1.91",
69
- "pg": "^8.14.1",
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.6.1",
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.12.0",
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
  }