Skip to content

feat(AI): Replace Imagen with Nano Banana usage#985

Open
DellaBitta wants to merge 3 commits intomasterfrom
ddb-imagen-banana
Open

feat(AI): Replace Imagen with Nano Banana usage#985
DellaBitta wants to merge 3 commits intomasterfrom
ddb-imagen-banana

Conversation

@DellaBitta
Copy link
Copy Markdown
Contributor

Update the ai-react-app to:

  • Replace Imagen view with Nana Banana view.
  • Remove usage of Imagen generative model calls. Replace with standard regenerative models.
  • Update the supported models to the list of Nano Banana models.
  • Add an Aspect Ratio pull down for the supported Nano Banana aspect ratios. Selecting an Aspect Ratio appends the prompt with text with Use aspect ratio 21:9 for instance.
  • Add the ability to set the response modalities for image generation request.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the 'Imagen Generation' feature with a new 'Nano Banana' mode, transitioning from a dedicated image generation model to a generative model capable of interleaved text and image output. Key changes include updating the application state to support the nanobanana mode, adding aspect ratio selection and response modality controls in the sidebar, and implementing the NanoBananaView component. Feedback highlights a missing dependency in a useCallback hook within NanoBananaView.tsx which could lead to stale state usage, and a redundant state assignment in RightSidebar.tsx.

setIsLoading(false);
setCurrentPrompt("");
}
}, [currentPrompt, isLoading, currentParams, aiInstance]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The handleImageGenerationSubmit callback uses selectedAspectRatio (line 84) but does not include it in the dependency array. This will cause the function to use the initial or stale value of the aspect ratio when submitted.

Suggested change
}, [currentPrompt, isLoading, currentParams, aiInstance]);
}, [currentPrompt, isLoading, currentParams, aiInstance, selectedAspectRatio]);

Comment on lines 167 to +168
nextState.tools = [defaultGoogleSearchTool];
nextState.generationConfig.responseMimeType = undefined;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This assignment is redundant as responseMimeType is set to undefined again on line 171 within the same block.

Suggested change
nextState.tools = [defaultGoogleSearchTool];
nextState.generationConfig.responseMimeType = undefined;
nextState.tools = [defaultGoogleSearchTool];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the bot is correct.

Comment on lines 167 to +168
nextState.tools = [defaultGoogleSearchTool];
nextState.generationConfig.responseMimeType = undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the bot is correct.

<option key={level} value={level}>
{level.replace(/_/g, " ")}
<option value="">None</option>
{["1:1", "3:2", "2:3", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"].map((ar) => (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were only going to put a sample of aspect ratio text in the placeholder and not provide a UI select element? Is this because there are a limited number of aspect ratios that the model can handle?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it turns out that there's only a select set of supported aspect ratios. Seems easier to toy with if there's a pulldown, but I can remove the pull down and bake the aspect ratio into the sample prompts instead, if that's what you'd rather after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants