@threaded/ai 1.0.13 → 1.0.14
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/index.cjs +104 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +101 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
IMAGE_MODEL_SCHEMA: () => IMAGE_MODEL_SCHEMA,
|
|
33
34
|
Inherit: () => Inherit,
|
|
34
35
|
appendToLastRequest: () => appendToLastRequest,
|
|
35
36
|
compose: () => compose,
|
|
@@ -42,7 +43,9 @@ __export(index_exports, {
|
|
|
42
43
|
everyNTokens: () => everyNTokens,
|
|
43
44
|
generateApprovalToken: () => generateApprovalToken,
|
|
44
45
|
generateImage: () => generateImage,
|
|
46
|
+
getDefaultConfig: () => getDefaultConfig,
|
|
45
47
|
getKey: () => getKey,
|
|
48
|
+
getModelConfig: () => getModelConfig,
|
|
46
49
|
getOrCreateThread: () => getOrCreateThread,
|
|
47
50
|
isStandardSchema: () => isStandardSchema,
|
|
48
51
|
maxCalls: () => maxCalls,
|
|
@@ -301,6 +304,7 @@ var generateOpenAICompatible = async (endpoint, modelName, prompt, apiKey, confi
|
|
|
301
304
|
if (config?.outputFormat) body.output_format = config.outputFormat;
|
|
302
305
|
if (config?.outputCompression != null) body.output_compression = config.outputCompression;
|
|
303
306
|
if (config?.background) body.background = config.background;
|
|
307
|
+
if (config?.moderation) body.moderation = config.moderation;
|
|
304
308
|
}
|
|
305
309
|
const response = await fetch(endpoint, {
|
|
306
310
|
method: "POST",
|
|
@@ -332,6 +336,9 @@ var generateGoogle = async (modelName, prompt, apiKey, config) => {
|
|
|
332
336
|
if (config?.aspectRatio) {
|
|
333
337
|
body.generationConfig.aspectRatio = config.aspectRatio;
|
|
334
338
|
}
|
|
339
|
+
if (config?.imageSize) {
|
|
340
|
+
body.generationConfig.imageSize = config.imageSize;
|
|
341
|
+
}
|
|
335
342
|
const response = await fetch(endpoint, {
|
|
336
343
|
method: "POST",
|
|
337
344
|
headers: {
|
|
@@ -384,6 +391,100 @@ var generateImage = async (model2, prompt, config) => {
|
|
|
384
391
|
}
|
|
385
392
|
};
|
|
386
393
|
|
|
394
|
+
// src/image-model-schema.ts
|
|
395
|
+
var IMAGE_MODEL_SCHEMA = {
|
|
396
|
+
openai: {
|
|
397
|
+
"dall-e-3": {
|
|
398
|
+
size: {
|
|
399
|
+
values: ["1024x1024", "1024x1792", "1792x1024"],
|
|
400
|
+
default: "1024x1024",
|
|
401
|
+
description: "Image dimensions"
|
|
402
|
+
},
|
|
403
|
+
quality: {
|
|
404
|
+
values: ["standard", "hd"],
|
|
405
|
+
default: "standard",
|
|
406
|
+
description: "Image quality level"
|
|
407
|
+
},
|
|
408
|
+
style: {
|
|
409
|
+
values: ["vivid", "natural"],
|
|
410
|
+
default: "vivid",
|
|
411
|
+
description: "Image style"
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
"gpt-image-1.5": {
|
|
415
|
+
size: {
|
|
416
|
+
values: ["1024x1024", "1536x1024", "1024x1536", "auto"],
|
|
417
|
+
default: "auto",
|
|
418
|
+
description: "Image dimensions"
|
|
419
|
+
},
|
|
420
|
+
quality: {
|
|
421
|
+
values: ["low", "medium", "high", "auto"],
|
|
422
|
+
default: "auto",
|
|
423
|
+
description: "Image quality level"
|
|
424
|
+
},
|
|
425
|
+
background: {
|
|
426
|
+
values: ["transparent", "opaque", "auto"],
|
|
427
|
+
default: "auto",
|
|
428
|
+
description: "Background type"
|
|
429
|
+
},
|
|
430
|
+
moderation: {
|
|
431
|
+
values: ["auto", "low"],
|
|
432
|
+
default: "auto",
|
|
433
|
+
description: "Content moderation level"
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
google: {
|
|
438
|
+
"gemini-2.5-flash-image": {
|
|
439
|
+
aspectRatio: {
|
|
440
|
+
values: ["1:1", "3:4", "4:3", "9:16", "16:9"],
|
|
441
|
+
default: "1:1",
|
|
442
|
+
description: "Image aspect ratio"
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
"gemini-3-pro-image-preview": {
|
|
446
|
+
aspectRatio: {
|
|
447
|
+
values: ["1:1", "3:4", "4:3", "9:16", "16:9"],
|
|
448
|
+
default: "1:1",
|
|
449
|
+
description: "Image aspect ratio"
|
|
450
|
+
},
|
|
451
|
+
imageSize: {
|
|
452
|
+
values: ["1K", "2K"],
|
|
453
|
+
default: "1K",
|
|
454
|
+
description: "Output image size"
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
"nano-banana-pro-preview": {
|
|
458
|
+
aspectRatio: {
|
|
459
|
+
values: ["1:1", "3:4", "4:3", "9:16", "16:9"],
|
|
460
|
+
default: "1:1",
|
|
461
|
+
description: "Image aspect ratio"
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
xai: {
|
|
466
|
+
"grok-2-image-1212": {
|
|
467
|
+
size: {
|
|
468
|
+
values: ["1024x1024"],
|
|
469
|
+
default: "1024x1024",
|
|
470
|
+
description: "Image dimensions"
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
function getModelConfig(provider, model2) {
|
|
476
|
+
return IMAGE_MODEL_SCHEMA[provider]?.[model2] || null;
|
|
477
|
+
}
|
|
478
|
+
function getDefaultConfig(provider, model2) {
|
|
479
|
+
const schema = getModelConfig(provider, model2);
|
|
480
|
+
if (!schema) return {};
|
|
481
|
+
const defaults = {};
|
|
482
|
+
for (const [key, option] of Object.entries(schema)) {
|
|
483
|
+
defaults[key] = option.default;
|
|
484
|
+
}
|
|
485
|
+
return defaults;
|
|
486
|
+
}
|
|
487
|
+
|
|
387
488
|
// src/providers/openai.ts
|
|
388
489
|
var getApiKey2 = (configApiKey) => {
|
|
389
490
|
if (configApiKey) return configApiKey;
|
|
@@ -1712,6 +1813,7 @@ var rateLimited = (config) => (fn) => {
|
|
|
1712
1813
|
};
|
|
1713
1814
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1714
1815
|
0 && (module.exports = {
|
|
1816
|
+
IMAGE_MODEL_SCHEMA,
|
|
1715
1817
|
Inherit,
|
|
1716
1818
|
appendToLastRequest,
|
|
1717
1819
|
compose,
|
|
@@ -1724,7 +1826,9 @@ var rateLimited = (config) => (fn) => {
|
|
|
1724
1826
|
everyNTokens,
|
|
1725
1827
|
generateApprovalToken,
|
|
1726
1828
|
generateImage,
|
|
1829
|
+
getDefaultConfig,
|
|
1727
1830
|
getKey,
|
|
1831
|
+
getModelConfig,
|
|
1728
1832
|
getOrCreateThread,
|
|
1729
1833
|
isStandardSchema,
|
|
1730
1834
|
maxCalls,
|