update: script
This commit is contained in:
parent
2fc7bd7698
commit
8aaa22ab99
|
|
@ -33,12 +33,12 @@ async function main() {
|
|||
apiKey: process.env.GEMINI_API_KEY,
|
||||
});
|
||||
|
||||
// Note: Using gemini-2.0-flash-preview-image-generation with both IMAGE and TEXT response modalities
|
||||
// Note: Using gemini-2.5-flash-image-preview (Nano Banana) as primary model
|
||||
|
||||
const config = {
|
||||
responseModalities: ['IMAGE', 'TEXT'],
|
||||
};
|
||||
const model = 'gemini-2.0-flash-preview-image-generation';
|
||||
const model = 'gemini-2.5-flash-image-preview';
|
||||
const contents = [
|
||||
{
|
||||
role: 'user',
|
||||
|
|
@ -65,7 +65,7 @@ async function main() {
|
|||
|
||||
content.parts?.forEach((part, index) => {
|
||||
if (part.inlineData) {
|
||||
const fileName = `fantasy_warrior_${index}`;
|
||||
const fileName = `fantasy_warrior_primary_${index}`;
|
||||
const inlineData = part.inlineData;
|
||||
const fileExtension = mime.getExtension(inlineData.mimeType || '');
|
||||
console.log(`Saving image: ${fileName}.${fileExtension}`);
|
||||
|
|
@ -80,13 +80,13 @@ async function main() {
|
|||
} catch (error) {
|
||||
console.error('Primary model failed:', error.message || error);
|
||||
|
||||
// Try fallback model
|
||||
console.log('Trying fallback model (Nano Banana)...');
|
||||
// Try fallback model (Imagen 4)
|
||||
console.log('Trying fallback model (Imagen 4)...');
|
||||
try {
|
||||
const altResponse = await ai.models.generateContent({
|
||||
model: 'gemini-2.5-flash-image-preview',
|
||||
model: 'imagen-4.0-generate-001',
|
||||
config: {
|
||||
responseModalities: ['IMAGE', 'TEXT']
|
||||
responseModalities: ['IMAGE']
|
||||
},
|
||||
contents,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue