Skip to content

Commit 6987c67

Browse files
committed
AIX: Images: further resize the last generated image - can be very large, so >0.5M we resize
1 parent 65a59e5 commit 6987c67

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/modules/aix/client/aix.client.chatGenerateRequest.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,10 @@ export async function aixCGR_ChatSequence_FromDMessagesOrThrow(
447447

448448
case 'image':
449449
// dereference the Zync Image Asset, converting it to an inline image
450+
const legacyImageRefPart = refPart._legacyImageRefPart;
451+
const imageSize = legacyImageRefPart && legacyImageRefPart.dataRef.reftype === 'dblob' ? legacyImageRefPart?.dataRef?.bytesSize ?? 0 : 0;
450452
const isLastAssistantMessage = _index === lastAssistantMessageIndex;
451-
const resizeMode = isLastAssistantMessage ? false : 'openai-low-res';
453+
const resizeMode = !isLastAssistantMessage ? 'openai-low-res' : imageSize > 400_000 ? 'openai-high-res' : false;
452454
try {
453455
const aixPart = await aixConvertZyncImageAssetRefToInlineImageOrThrow(refPart, resizeMode);
454456
modelMessage.parts.push(_vnd ? { ...aixPart, _vnd } : aixPart);
@@ -491,8 +493,9 @@ export async function aixCGR_ChatSequence_FromDMessagesOrThrow(
491493
* FIXME for GEMINI IMAGE GENERATION
492494
* For now we upload ONLY THE LAST IMAGE as full quality, while all others are resized before transmission.
493495
*/
496+
const imageSize = aPart.dataRef.reftype === 'dblob' ? aPart.dataRef?.bytesSize ?? 0 : 0;
494497
const isLastAssistantMessage = _index === lastAssistantMessageIndex;
495-
const resizeMode = isLastAssistantMessage ? false : 'openai-low-res';
498+
const resizeMode = !isLastAssistantMessage ? 'openai-low-res' : imageSize > 400_000 ? 'openai-high-res' : false;
496499
try {
497500
const aixPart = await aixConvertImageRefToInlineImageOrThrow(aPart, resizeMode);
498501
modelMessage.parts.push(_vnd ? { ...aixPart, _vnd } : aixPart);

0 commit comments

Comments
 (0)