mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Continue CGRs ignoring missing image dereferences. #733
This is an emergency workaround where formal correctness yields to an unbroken chat experience.
This commit is contained in:
@@ -15,6 +15,7 @@ import type { AixAPIChatGenerate_Request, AixMessages_ModelMessage, AixMessages_
|
||||
// configuration
|
||||
const MODEL_IMAGE_RESCALE_MIMETYPE = !Is.Browser.Safari ? 'image/webp' : 'image/jpeg';
|
||||
const MODEL_IMAGE_RESCALE_QUALITY = 0.90;
|
||||
const IGNORE_CGR_NO_IMAGE_DEREFERENCE = true; // set to false to raise an exception, otherwise the CGR will continue skipping the part
|
||||
|
||||
|
||||
// AIX <> Simple Text API helpers
|
||||
@@ -138,7 +139,12 @@ export async function aixCGR_ChatSequence_FromDMessagesOrThrow(
|
||||
|
||||
case 'image_ref':
|
||||
// note, we don't resize, as the user image is resized following the user's preferences
|
||||
uMsg.parts.push(await aixConvertImageRefToInlineImageOrThrow(uFragment.part, false));
|
||||
try {
|
||||
uMsg.parts.push(await aixConvertImageRefToInlineImageOrThrow(uFragment.part, false));
|
||||
} catch (error: any) {
|
||||
if (IGNORE_CGR_NO_IMAGE_DEREFERENCE) console.warn(`Image from the user missing in the chat generation request because: ${error?.message || error?.toString() || 'Unknown error'} - continuing without`);
|
||||
else throw error;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'doc':
|
||||
@@ -223,7 +229,12 @@ export async function aixCGR_ChatSequence_FromDMessagesOrThrow(
|
||||
*/
|
||||
const isLastAssistantMessage = _index === lastAssistantMessageIndex;
|
||||
const resizeMode = isLastAssistantMessage ? false : 'openai-low-res';
|
||||
modelMessage.parts.push(await aixConvertImageRefToInlineImageOrThrow(aFragment.part, resizeMode));
|
||||
try {
|
||||
modelMessage.parts.push(await aixConvertImageRefToInlineImageOrThrow(aFragment.part, resizeMode));
|
||||
} catch (error: any) {
|
||||
if (IGNORE_CGR_NO_IMAGE_DEREFERENCE) console.warn(`Image from the assistant missing in the chat generation request because: ${error?.message || error?.toString() || 'Unknown error'} - continuing without`);
|
||||
else throw error;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'tool_response':
|
||||
|
||||
Reference in New Issue
Block a user