@just-every/ensemble 0.2.257 → 0.2.258
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 +2 -2
- package/dist/cjs/data/model_data.cjs +40 -11
- package/dist/cjs/data/model_data.d.ts.map +1 -1
- package/dist/cjs/data/model_data.js.map +1 -1
- package/dist/cjs/model_providers/gemini.cjs +93 -34
- package/dist/cjs/model_providers/gemini.d.ts.map +1 -1
- package/dist/cjs/model_providers/gemini.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/data/model_data.d.ts.map +1 -1
- package/dist/data/model_data.js +40 -11
- package/dist/data/model_data.js.map +1 -1
- package/dist/model_providers/gemini.d.ts.map +1 -1
- package/dist/model_providers/gemini.js +93 -34
- package/dist/model_providers/gemini.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -582,6 +582,24 @@ function isGemmaModel(model) {
|
|
|
582
582
|
const modelId = model.startsWith('models/') ? model.slice('models/'.length) : model;
|
|
583
583
|
return modelId.startsWith('gemma-4-');
|
|
584
584
|
}
|
|
585
|
+
function isGemini25FlashImageModel(model) {
|
|
586
|
+
return model.includes('gemini-2.5-flash-image');
|
|
587
|
+
}
|
|
588
|
+
function isGemini31FlashImageModel(model) {
|
|
589
|
+
return model.includes('gemini-3.1-flash-image');
|
|
590
|
+
}
|
|
591
|
+
function isGemini31FlashLiteImageModel(model) {
|
|
592
|
+
return model.includes('gemini-3.1-flash-lite-image');
|
|
593
|
+
}
|
|
594
|
+
function isGemini3ProImageModel(model) {
|
|
595
|
+
return model.includes('gemini-3-pro-image');
|
|
596
|
+
}
|
|
597
|
+
function isGeminiStreamingImageModel(model) {
|
|
598
|
+
return (isGemini25FlashImageModel(model) ||
|
|
599
|
+
isGemini31FlashImageModel(model) ||
|
|
600
|
+
isGemini31FlashLiteImageModel(model) ||
|
|
601
|
+
isGemini3ProImageModel(model));
|
|
602
|
+
}
|
|
585
603
|
function getSupportedThinkingLevels(model) {
|
|
586
604
|
if (isGemmaModel(model)) {
|
|
587
605
|
return new Set(['HIGH']);
|
|
@@ -589,17 +607,17 @@ function getSupportedThinkingLevels(model) {
|
|
|
589
607
|
if (model.includes('gemini-3.1-pro-preview') || model.includes('gemini-3-pro-preview')) {
|
|
590
608
|
return new Set(['LOW', 'MEDIUM', 'HIGH']);
|
|
591
609
|
}
|
|
610
|
+
if (isGemini31FlashImageModel(model) || isGemini31FlashLiteImageModel(model)) {
|
|
611
|
+
return new Set(['MINIMAL', 'HIGH']);
|
|
612
|
+
}
|
|
613
|
+
if (isGemini3ProImageModel(model)) {
|
|
614
|
+
return new Set(['HIGH']);
|
|
615
|
+
}
|
|
592
616
|
if (model.includes('gemini-3.5-flash') ||
|
|
593
617
|
model.includes('gemini-3.1-flash-lite') ||
|
|
594
618
|
model.includes('gemini-3-flash-preview')) {
|
|
595
619
|
return new Set(['MINIMAL', 'LOW', 'MEDIUM', 'HIGH']);
|
|
596
620
|
}
|
|
597
|
-
if (model.includes('gemini-3.1-flash-image-preview')) {
|
|
598
|
-
return new Set(['MINIMAL', 'HIGH']);
|
|
599
|
-
}
|
|
600
|
-
if (model.includes('gemini-3-pro-image-preview')) {
|
|
601
|
-
return new Set(['HIGH']);
|
|
602
|
-
}
|
|
603
621
|
return null;
|
|
604
622
|
}
|
|
605
623
|
const GEMINI_3_PRO_IMAGE_DIMENSION_PRESETS = {
|
|
@@ -1230,7 +1248,7 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1230
1248
|
const requestId = `req_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
1231
1249
|
let finalRequestId = requestId;
|
|
1232
1250
|
try {
|
|
1233
|
-
model = model || 'gemini-
|
|
1251
|
+
model = model || 'gemini-3.1-flash-image';
|
|
1234
1252
|
const numberOfImages = opts?.n ?? 1;
|
|
1235
1253
|
if (!Number.isInteger(numberOfImages) || numberOfImages < 1) {
|
|
1236
1254
|
throw new Error('[Gemini] ImageGenerationOpts.n must be a positive integer.');
|
|
@@ -1244,11 +1262,17 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1244
1262
|
}
|
|
1245
1263
|
const explicitWebGrounding = opts?.grounding?.web_search;
|
|
1246
1264
|
const explicitImageGrounding = opts?.grounding?.image_search;
|
|
1247
|
-
const
|
|
1248
|
-
const
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1265
|
+
const isGemini31FlashImage = isGemini31FlashImageModel(model);
|
|
1266
|
+
const isGemini31FlashLiteImage = isGemini31FlashLiteImageModel(model);
|
|
1267
|
+
const isGemini3ProImage = isGemini3ProImageModel(model);
|
|
1268
|
+
const supportsWebGrounding = isGemini31FlashImage || isGemini3ProImage;
|
|
1269
|
+
const enableWebGrounding = supportsWebGrounding && (explicitWebGrounding ?? hasGoogleWebSearch ?? false);
|
|
1270
|
+
const enableImageGrounding = explicitImageGrounding === true && isGemini31FlashImage;
|
|
1271
|
+
if ((explicitWebGrounding || hasGoogleWebSearch) && !supportsWebGrounding) {
|
|
1272
|
+
console.warn('[Gemini] Google Search grounding is only available for gemini-3.1-flash-image and gemini-3-pro-image. Ignoring web_search=true.');
|
|
1273
|
+
}
|
|
1274
|
+
if (explicitImageGrounding && !isGemini31FlashImage) {
|
|
1275
|
+
console.warn('[Gemini] Image Search grounding is only available for gemini-3.1-flash-image. Ignoring image_search=true.');
|
|
1252
1276
|
}
|
|
1253
1277
|
const thinkingOptions = opts?.thinking;
|
|
1254
1278
|
const hasThinkingOptionsObject = thinkingOptions !== null && typeof thinkingOptions === 'object' && !Array.isArray(thinkingOptions);
|
|
@@ -1258,11 +1282,12 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1258
1282
|
? thinkingOptions.level
|
|
1259
1283
|
: undefined;
|
|
1260
1284
|
const thinkingLevel = requestedThinkingLevel === 'high' ? 'High' : requestedThinkingLevel ? 'Minimal' : undefined;
|
|
1261
|
-
|
|
1262
|
-
|
|
1285
|
+
const supportsImageThinkingControls = isGemini31FlashImage || isGemini31FlashLiteImage;
|
|
1286
|
+
if (requestedThinkingLevel && !supportsImageThinkingControls) {
|
|
1287
|
+
console.warn('[Gemini] thinking.level is currently supported for gemini-3.1-flash-image and gemini-3.1-flash-lite-image only. Ignoring thinking level.');
|
|
1263
1288
|
}
|
|
1264
|
-
if (hasThinkingOptionsObject && 'include_thoughts' in thinkingOptions && !
|
|
1265
|
-
console.warn('[Gemini] thinking.include_thoughts is currently supported for gemini-3.1-flash-image-
|
|
1289
|
+
if (hasThinkingOptionsObject && 'include_thoughts' in thinkingOptions && !supportsImageThinkingControls) {
|
|
1290
|
+
console.warn('[Gemini] thinking.include_thoughts is currently supported for gemini-3.1-flash-image and gemini-3.1-flash-lite-image only. Ignoring include_thoughts.');
|
|
1266
1291
|
}
|
|
1267
1292
|
let aspectRatio = '1:1';
|
|
1268
1293
|
if (opts?.size === 'landscape')
|
|
@@ -1270,9 +1295,7 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1270
1295
|
else if (opts?.size === 'portrait')
|
|
1271
1296
|
aspectRatio = '2:3';
|
|
1272
1297
|
console.log(`[Gemini] Generating ${numberOfImages} image(s) with model ${model}, prompt: "${prompt.substring(0, 100)}${prompt.length > 100 ? '...' : ''}"`);
|
|
1273
|
-
if (model
|
|
1274
|
-
model.includes('gemini-3.1-flash-image-preview') ||
|
|
1275
|
-
model.includes('gemini-3-pro-image-preview')) {
|
|
1298
|
+
if (isGeminiStreamingImageModel(model)) {
|
|
1276
1299
|
let aggregateMetadata = { model };
|
|
1277
1300
|
const sizeMap = {
|
|
1278
1301
|
'1:1': { ar: '1:1' },
|
|
@@ -1303,7 +1326,7 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1303
1326
|
'1024x1792': { ar: '9:16' },
|
|
1304
1327
|
};
|
|
1305
1328
|
const sm = opts?.size ? sizeMap[String(opts.size)] : undefined;
|
|
1306
|
-
const gemini3ProDimensionPreset =
|
|
1329
|
+
const gemini3ProDimensionPreset = isGemini3ProImage
|
|
1307
1330
|
? GEMINI_3_PRO_IMAGE_DIMENSION_PRESETS[String(opts?.size)]
|
|
1308
1331
|
: undefined;
|
|
1309
1332
|
const imageConfig = {};
|
|
@@ -1312,7 +1335,24 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1312
1335
|
if (gemini3ProDimensionPreset?.ar)
|
|
1313
1336
|
imageConfig.aspectRatio = gemini3ProDimensionPreset.ar;
|
|
1314
1337
|
const qualityKey = typeof opts?.quality === 'string' ? opts.quality.toLowerCase() : '';
|
|
1315
|
-
|
|
1338
|
+
if (isGemini31FlashLiteImage && imageConfig.aspectRatio) {
|
|
1339
|
+
const liteAspectRatios = new Set([
|
|
1340
|
+
'1:1',
|
|
1341
|
+
'2:3',
|
|
1342
|
+
'3:2',
|
|
1343
|
+
'3:4',
|
|
1344
|
+
'4:3',
|
|
1345
|
+
'4:5',
|
|
1346
|
+
'5:4',
|
|
1347
|
+
'9:16',
|
|
1348
|
+
'16:9',
|
|
1349
|
+
'21:9',
|
|
1350
|
+
]);
|
|
1351
|
+
if (!liteAspectRatios.has(imageConfig.aspectRatio)) {
|
|
1352
|
+
throw new Error(`[Gemini] gemini-3.1-flash-lite-image does not support aspect ratio ${imageConfig.aspectRatio}.`);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
const imageSizeMap = isGemini31FlashImage
|
|
1316
1356
|
? {
|
|
1317
1357
|
low: '0.5K',
|
|
1318
1358
|
standard: '1K',
|
|
@@ -1320,28 +1360,44 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1320
1360
|
hd: '4K',
|
|
1321
1361
|
high: '4K',
|
|
1322
1362
|
}
|
|
1323
|
-
:
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1363
|
+
: isGemini31FlashLiteImage
|
|
1364
|
+
? {
|
|
1365
|
+
low: '1K',
|
|
1366
|
+
standard: '1K',
|
|
1367
|
+
medium: '1K',
|
|
1368
|
+
hd: '1K',
|
|
1369
|
+
high: '1K',
|
|
1370
|
+
}
|
|
1371
|
+
: {
|
|
1372
|
+
low: '1K',
|
|
1373
|
+
standard: '2K',
|
|
1374
|
+
medium: '2K',
|
|
1375
|
+
hd: '4K',
|
|
1376
|
+
high: '4K',
|
|
1377
|
+
};
|
|
1330
1378
|
let imageSize = imageSizeMap[qualityKey];
|
|
1331
1379
|
if (gemini3ProDimensionPreset?.imageSize) {
|
|
1332
1380
|
imageSize = gemini3ProDimensionPreset.imageSize;
|
|
1333
1381
|
}
|
|
1334
|
-
if (
|
|
1382
|
+
if (isGemini31FlashImage && opts?.size === '512x512') {
|
|
1335
1383
|
imageSize = '0.5K';
|
|
1336
1384
|
}
|
|
1385
|
+
if (isGemini31FlashLiteImage) {
|
|
1386
|
+
imageSize = '1K';
|
|
1387
|
+
if (opts?.size === '512x512') {
|
|
1388
|
+
throw new Error('[Gemini] gemini-3.1-flash-lite-image only supports 1K image output.');
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1337
1391
|
const requestImageSize = imageSize === '0.5K' ? '512' : imageSize;
|
|
1338
1392
|
if (requestImageSize)
|
|
1339
1393
|
imageConfig.imageSize = requestImageSize;
|
|
1340
1394
|
const thinkingConfig = {};
|
|
1341
|
-
if (hasThinkingOptionsObject &&
|
|
1395
|
+
if (hasThinkingOptionsObject &&
|
|
1396
|
+
'include_thoughts' in thinkingOptions &&
|
|
1397
|
+
supportsImageThinkingControls) {
|
|
1342
1398
|
thinkingConfig.includeThoughts = includeThoughts;
|
|
1343
1399
|
}
|
|
1344
|
-
if (thinkingLevel &&
|
|
1400
|
+
if (thinkingLevel && supportsImageThinkingControls) {
|
|
1345
1401
|
thinkingConfig.thinkingLevel = thinkingLevel;
|
|
1346
1402
|
}
|
|
1347
1403
|
const searchTypes = {};
|
|
@@ -1657,7 +1713,7 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1657
1713
|
}
|
|
1658
1714
|
}
|
|
1659
1715
|
getImageCost(model, imageSize) {
|
|
1660
|
-
if (model
|
|
1716
|
+
if (isGemini31FlashImageModel(model)) {
|
|
1661
1717
|
if (imageSize === '4K')
|
|
1662
1718
|
return 0.151;
|
|
1663
1719
|
if (imageSize === '2K')
|
|
@@ -1666,10 +1722,13 @@ export class GeminiProvider extends BaseModelProvider {
|
|
|
1666
1722
|
return 0.045;
|
|
1667
1723
|
return 0.067;
|
|
1668
1724
|
}
|
|
1669
|
-
else if (model
|
|
1725
|
+
else if (isGemini31FlashLiteImageModel(model)) {
|
|
1726
|
+
return 0.0336;
|
|
1727
|
+
}
|
|
1728
|
+
else if (isGemini25FlashImageModel(model)) {
|
|
1670
1729
|
return 0.039;
|
|
1671
1730
|
}
|
|
1672
|
-
else if (model
|
|
1731
|
+
else if (isGemini3ProImageModel(model)) {
|
|
1673
1732
|
if (imageSize === '4K')
|
|
1674
1733
|
return 0.24;
|
|
1675
1734
|
return 0.134;
|