Enable image inlining for Gemini flash

This commit is contained in:
Cohee 2024-05-21 16:14:21 +03:00
parent bac00659ef
commit 0b06f9686b
1 changed files with 8 additions and 2 deletions

View File

@ -263,8 +263,14 @@ function convertGooglePrompt(messages, model, useSysPrompt = false, charName = '
const PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; const PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
const visionSupportedModels = [ const visionSupportedModels = [
'gemini-1.0-pro-vision-latest', 'gemini-1.5-flash-latest',
'gemini-1.5-pro-latest', 'gemini-1.5-pro-latest',
'gemini-1.0-pro-vision-latest',
'gemini-pro-vision',
];
const dummyRequiredModels = [
'gemini-1.0-pro-vision-latest',
'gemini-pro-vision', 'gemini-pro-vision',
]; ];
@ -343,7 +349,7 @@ function convertGooglePrompt(messages, model, useSysPrompt = false, charName = '
}); });
// pro 1.5 doesn't require a dummy image to be attached, other vision models do // pro 1.5 doesn't require a dummy image to be attached, other vision models do
if (isMultimodal && model !== 'gemini-1.5-pro-latest' && !hasImage) { if (isMultimodal && dummyRequiredModels.includes(model) && !hasImage) {
contents[0].parts.push({ contents[0].parts.push({
inlineData: { inlineData: {
mimeType: 'image/png', mimeType: 'image/png',