Google Imagen: Add personGeneration setting to config.yaml
| @@ -287,6 +287,10 @@ claude: | |||
| 287 | gemini: | 287 | gemini: |
| 288 | # API endpoint version ("v1beta" or "v1alpha") | 288 | # API endpoint version ("v1beta" or "v1alpha") |
| 289 | apiVersion: 'v1beta' | 289 | apiVersion: 'v1beta' |
| 290 | # https://ai.google.dev/gemini-api/docs/imagen#imagen-configuration | ||
| 291 | image: | ||
| 292 | # Leave empty to use the API-default value. | ||
| 293 | personGeneration: 'allow_adult' | ||
| 290 | # -- SERVER PLUGIN CONFIGURATION -- | 294 | # -- SERVER PLUGIN CONFIGURATION -- |
| 291 | enableServerPlugins: false | 295 | enableServerPlugins: false |
| 292 | # Attempt to automatically update server plugins on startup | 296 | # Attempt to automatically update server plugins on startup |
| @@ -438,6 +438,8 @@ router.post('/generate-image', async (request, response) => { | |||
| 438 | const isVertex = request.body.api === 'vertexai'; | 438 | const isVertex = request.body.api === 'vertexai'; |
| 439 | // Is it even worth it? | 439 | // Is it even worth it? |
| 440 | const isDeprecated = model.startsWith('imagegeneration'); | 440 | const isDeprecated = model.startsWith('imagegeneration'); |
| 441 | // Get person generation setting from config | ||
| 442 | const personGeneration = getConfigValue('gemini.image.personGeneration', 'allow_adult'); | ||
| 441 | 443 | ||
| 442 | const requestBody = { | 444 | const requestBody = { |
| 443 | instances: [{ | 445 | instances: [{ |
| @@ -449,7 +451,7 @@ router.post('/generate-image', async (request, response) => { | |||
| 449 | enhancePrompt: isVertex ? Boolean(request.body.enhance ?? false) : undefined, | 451 | enhancePrompt: isVertex ? Boolean(request.body.enhance ?? false) : undefined, |
| 450 | negativePrompt: isVertex ? (request.body.negative_prompt || undefined) : undefined, | 452 | negativePrompt: isVertex ? (request.body.negative_prompt || undefined) : undefined, |
| 451 | aspectRatio: String(request.body.aspect_ratio || '1:1'), | 453 | aspectRatio: String(request.body.aspect_ratio || '1:1'), |
| 452 | personGeneration: !isDeprecated ? 'allow_adult' : undefined, | 454 | personGeneration: !isDeprecated && personGeneration ? personGeneration : undefined, |
| 453 | language: isVertex ? 'auto' : undefined, | 455 | language: isVertex ? 'auto' : undefined, |
| 454 | safetySetting: !isDeprecated ? (isVertex ? 'block_only_high' : 'block_low_and_above') : undefined, | 456 | safetySetting: !isDeprecated ? (isVertex ? 'block_only_high' : 'block_low_and_above') : undefined, |
| 455 | addWatermark: isVertex ? false : undefined, | 457 | addWatermark: isVertex ? false : undefined, |