@@ -1086,6 +1086,7 @@ function createDialog(text, duration_seconds = 0, add_class_name = '', can_delet
10861086}
10871087
10881088function geminiChat ( fileUri = '' , with_stream = true , the_data = '' ) {
1089+ let gemini_model = model ;
10891090 let all_parts = [ ] ;
10901091 let system_prompt = getSystemPrompt ( ) ;
10911092 addFileToPrompt ( ) ;
@@ -1179,18 +1180,23 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
11791180 // "maxOutputTokens": 8192,
11801181 } ;
11811182
1182- if ( model . includes ( "image" ) ) {
1183- with_stream = false ;
1184- if ( data . systemInstruction ) {
1185- delete data . systemInstruction ;
1186- }
1187- data . generationConfig . responseModalities = [ "IMAGE" , "TEXT" ] ;
1188- }
11891183
11901184 let pog = whichTool ( last_user_input ) ;
11911185 if ( pog === 'dt' ) {
11921186 data . generationConfig . thinkingConfig = { thinkingBudget : 8000 } ;
11931187 }
1188+ if ( pog === 'pic' || pog === 'imagine' ) {
1189+ console . log ( 'image generation command activated' ) ;
1190+ gemini_model = "gemini-2.0-flash-preview-image-generation" ;
1191+ }
1192+
1193+ if ( gemini_model . includes ( "image" ) ) {
1194+ with_stream = false ;
1195+ if ( data . systemInstruction ) {
1196+ delete data . systemInstruction ;
1197+ }
1198+ data . generationConfig . responseModalities = [ "IMAGE" , "TEXT" ] ;
1199+ }
11941200
11951201 if ( the_data ) {
11961202 data = the_data ;
@@ -1230,7 +1236,7 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
12301236 return geminiStreamChat ( fileUri , data , allow_tool_use ) ;
12311237 }
12321238
1233- let gemini_endpoint = endpoint . replaceAll ( "{{model}}" , model ) ;
1239+ let gemini_endpoint = endpoint . replaceAll ( "{{model}}" , gemini_model ) ;
12341240 gemini_endpoint = gemini_endpoint . replaceAll ( "{{api_key}}" , api_key ) ;
12351241 gemini_endpoint = gemini_endpoint . replaceAll ( "{{gen_mode}}" , "generateContent" ) ;
12361242
@@ -2009,7 +2015,8 @@ function needToolUse(last_user_input) {
20092015 'search:' , 's:' ,
20102016 'javascript:' , 'js:' ,
20112017 'youtube:' , 'yt:' ,
2012- 'dt:'
2018+ 'dt:' ,
2019+ 'pic:' , 'imagine:'
20132020 ]
20142021 if ( cmd_list . includes ( cmd ) ) {
20152022 return true ;
@@ -2038,6 +2045,8 @@ function whichTool(last_user_input) {
20382045 } else if ( cmd === 'dt:' ) {
20392046 // Activate extend thinking for Claude
20402047 return 'dt' ;
2048+ } else if ( cmd . trim ( ) !== '' ) {
2049+ return cmd . replaceAll ( ":" , "" ) ;
20412050 }
20422051 return '' ;
20432052}
0 commit comments