Ensure format supported before captioning

This commit is contained in:
Cohee 2024-06-22 00:36:29 +03:00
parent e3714e9b6a
commit a00560d2b3
1 changed files with 2 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { getBase64Async, isTrueBoolean, saveBase64AsFile } from '../../utils.js'; import { ensureImageFormatSupported, getBase64Async, isTrueBoolean, saveBase64AsFile } from '../../utils.js';
import { getContext, getApiUrl, doExtrasFetch, extension_settings, modules, renderExtensionTemplateAsync } from '../../extensions.js'; import { getContext, getApiUrl, doExtrasFetch, extension_settings, modules, renderExtensionTemplateAsync } from '../../extensions.js';
import { callPopup, getRequestHeaders, saveSettingsDebounced, substituteParamsExtended } from '../../../script.js'; import { callPopup, getRequestHeaders, saveSettingsDebounced, substituteParamsExtended } from '../../../script.js';
import { getMessageTimeStamp } from '../../RossAscends-mods.js'; import { getMessageTimeStamp } from '../../RossAscends-mods.js';
@ -272,7 +272,7 @@ async function getCaptionForFile(file, prompt, quiet) {
try { try {
setSpinnerIcon(); setSpinnerIcon();
const context = getContext(); const context = getContext();
const fileData = await getBase64Async(file); const fileData = await getBase64Async(await ensureImageFormatSupported(file));
const base64Format = fileData.split(',')[0].split(';')[0].split('/')[1]; const base64Format = fileData.split(',')[0].split(';')[0].split('/')[1];
const base64Data = fileData.split(',')[1]; const base64Data = fileData.split(',')[1];
const { caption } = await doCaptionRequest(base64Data, fileData, prompt); const { caption } = await doCaptionRequest(base64Data, fileData, prompt);