@@ -3,24 +3,23 @@ import TopBar from "./TopBar";
33import LeftSidebar from "./LeftSidebar" ;
44import RightSidebar from "./RightSidebar" ;
55import ChatView from "../../views/ChatView" ;
6- import ImagenView from "../../views/ImagenView " ;
6+ import NanoBananaView from "../../views/NanoBananaView " ;
77import LiveView from "../../views/LiveView" ;
88import { AppMode } from "../../App" ;
99import {
1010 UsageMetadata ,
1111 ModelParams ,
12- ImagenModelParams ,
1312 BackendType ,
1413 AI ,
1514 VertexAIBackend ,
1615 GoogleAIBackend ,
1716 getAI ,
17+ ResponseModality ,
1818} from "firebase/ai" ;
1919import {
2020 AVAILABLE_GENERATIVE_MODELS ,
21- AVAILABLE_IMAGEN_MODELS ,
21+ AVAILABLE_NANO_BANANA_MODELS ,
2222 defaultGenerativeParams ,
23- defaultImagenParams ,
2423} from "../../services/firebaseAIService" ;
2524import styles from "./MainLayout.module.css" ;
2625import { getApp } from "firebase/app" ;
@@ -46,10 +45,13 @@ const MainLayout: React.FC<MainLayoutProps> = ({
4645 model : AVAILABLE_GENERATIVE_MODELS [ 0 ] ,
4746 ...defaultGenerativeParams ,
4847 } ) ;
49- const [ imagenParams , setImagenParams ] = useState < ImagenModelParams > ( {
50- model : AVAILABLE_IMAGEN_MODELS [ 0 ] ,
51- ...defaultImagenParams ,
48+ const [ nanoBananaParams , setNanoBananaParams ] = useState < ModelParams > ( {
49+ model : AVAILABLE_NANO_BANANA_MODELS [ 0 ] ,
50+ generationConfig : {
51+ responseModalities : [ ResponseModality . TEXT , ResponseModality . IMAGE ] ,
52+ } ,
5253 } ) ;
54+ const [ selectedAspectRatio , setSelectedAspectRatio ] = useState < string | undefined > ( ) ;
5355
5456 const [ usageMetadata , setUsageMetadata ] = useState < UsageMetadata | null > (
5557 null ,
@@ -60,7 +62,9 @@ const MainLayout: React.FC<MainLayoutProps> = ({
6062 try {
6163 const backendInstance =
6264 activeBackendType === BackendType . VERTEX_AI
63- ? new VertexAIBackend ( )
65+ ? activeMode === "nanobanana"
66+ ? new VertexAIBackend ( "global" )
67+ : new VertexAIBackend ( )
6468 : new GoogleAIBackend ( ) ;
6569 const aiInstance = getAI ( getApp ( ) , { backend : backendInstance } ) ;
6670 setActiveAI ( aiInstance ) ;
@@ -75,14 +79,14 @@ const MainLayout: React.FC<MainLayoutProps> = ({
7579 ) ;
7680 setActiveAI ( null ) ;
7781 }
78- } , [ activeBackendType ] ) ;
82+ } , [ activeBackendType , activeMode ] ) ;
7983
8084 useEffect ( ( ) => {
8185 setUsageMetadata ( null ) ;
8286 } , [ activeMode ] ) ;
8387
8488 useEffect ( ( ) => {
85- const validModes : AppMode [ ] = [ "chat" , "imagenGen " , "live" ] ;
89+ const validModes : AppMode [ ] = [ "chat" , "nanobanana " , "live" ] ;
8690 if ( ! validModes . includes ( activeMode ) ) {
8791 console . warn ( `Invalid activeMode "${ activeMode } ". Resetting to "chat".` ) ;
8892 setActiveMode ( "chat" ) ;
@@ -109,9 +113,9 @@ const MainLayout: React.FC<MainLayoutProps> = ({
109113 activeMode = { activeMode }
110114 />
111115 ) ;
112- case "imagenGen " :
116+ case "nanobanana " :
113117 return (
114- < ImagenView aiInstance = { activeAI } currentParams = { imagenParams } />
118+ < NanoBananaView aiInstance = { activeAI } currentParams = { nanoBananaParams } selectedAspectRatio = { selectedAspectRatio } />
115119 ) ;
116120 case "live" :
117121 return (
@@ -152,8 +156,10 @@ const MainLayout: React.FC<MainLayoutProps> = ({
152156 activeMode = { activeMode }
153157 generativeParams = { generativeParams }
154158 setGenerativeParams = { setGenerativeParams }
155- imagenParams = { imagenParams }
156- setImagenParams = { setImagenParams }
159+ nanoBananaParams = { nanoBananaParams }
160+ setNanoBananaParams = { setNanoBananaParams }
161+ selectedAspectRatio = { selectedAspectRatio }
162+ setSelectedAspectRatio = { setSelectedAspectRatio }
157163 />
158164 </ div >
159165 </ div >
0 commit comments