Google: Fix image generation on deprecated models

560526586258522188e9eec8eb0d13463dd80aaa

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -2Showing whitespace changes
src/endpoints/google.js+4 -2
@@ -426,6 +426,8 @@ router.post('/generate-image', async (request, response) => {
426426
427 // AI Studio is stricter than Vertex AI.427 // AI Studio is stricter than Vertex AI.
428 const isVertex = request.body.api === 'vertexai';428 const isVertex = request.body.api === 'vertexai';
429 // Is it even worth it?
430 const isDeprecated = model.startsWith('imagegeneration');
429431
430 const requestBody = {432 const requestBody = {
431 instances: [{433 instances: [{
@@ -437,9 +439,9 @@ router.post('/generate-image', async (request, response) => {
437 enhancePrompt: isVertex ? Boolean(request.body.enhance ?? false) : undefined,439 enhancePrompt: isVertex ? Boolean(request.body.enhance ?? false) : undefined,
438 negativePrompt: isVertex ? (request.body.negative_prompt || undefined) : undefined,440 negativePrompt: isVertex ? (request.body.negative_prompt || undefined) : undefined,
439 aspectRatio: String(request.body.aspect_ratio || '1:1'),441 aspectRatio: String(request.body.aspect_ratio || '1:1'),
440 personGeneration: 'allow_all',442 personGeneration: !isDeprecated ? 'allow_all' : undefined,
441 language: isVertex ? 'auto' : undefined,443 language: isVertex ? 'auto' : undefined,
442 safetySetting: isVertex ? 'block_only_high' : 'block_low_and_above',444 safetySetting: !isDeprecated ? (isVertex ? 'block_only_high' : 'block_low_and_above') : undefined,
443 addWatermark: isVertex ? false : undefined,445 addWatermark: isVertex ? false : undefined,
444 outputOptions: {446 outputOptions: {
445 mimeType: 'image/jpeg',447 mimeType: 'image/jpeg',