@@ -57,9 +57,10 @@ let PLATFORM_DATA = {
5757 } ,
5858 google : {
5959 models : [
60- "gemini-2.5-pro-preview-05-06" ,
6160 "gemini-2.5-flash-preview-05-20" ,
62- "gemini-1.5-pro"
61+ "gemini-2.0-flash-preview-image-generation" ,
62+ "gemini-2.5-pro-preview-05-06"
63+
6364 ] ,
6465 name : "Google" ,
6566 endpoint : 'https://generativelanguage.googleapis.com/v1beta/models/{{model}}:{{gen_mode}}?key={{api_key}}'
@@ -157,14 +158,6 @@ let PLATFORM_DATA = {
157158 get_models_endpoint : "http://localhost:11434/v1/models" ,
158159 endpoint : "http://localhost:11434/v1/chat/completions"
159160 }
160- /* nvidia: {
161- models: [
162- "meta/llama-3.1-405b-instruct",
163- "nvidia/llama-3.1-nemotron-70b-instruct"
164- ],
165- name: "NVIDIA",
166- endpoint: "https://integrate.api.nvidia.com/v1/chat/completions"
167- }*/
168161}
169162
170163
@@ -1097,6 +1090,7 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
10971090 addFileToPrompt ( ) ;
10981091 conversations . messages . forEach ( part => {
10991092 let role = part . role === 'assistant' ? 'model' : part . role ;
1093+ part . content = part . content . replace ( / < i m g [ ^ > ] * > / g, ' ' ) ; // remove attached images
11001094 all_parts . push ( {
11011095 "role" : role ,
11021096 "parts" : [
@@ -1107,7 +1101,6 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
11071101 } ) ;
11081102 } )
11091103
1110-
11111104 if ( base64String ) {
11121105 geminiUploadImage ( ) . then ( response => {
11131106 console . log ( 'uploading' )
@@ -1185,6 +1178,11 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
11851178 // "maxOutputTokens": 8192,
11861179 } ;
11871180
1181+ if ( model . includes ( "image" ) ) {
1182+ with_stream = false ;
1183+ data . generationConfig . responseModalities = [ "IMAGE" , "TEXT" ] ;
1184+ }
1185+
11881186 let pog = whichTool ( last_user_input ) ;
11891187 if ( pog === 'dt' ) {
11901188 data . generationConfig . thinkingConfig = { thinkingBudget : 8000 } ;
@@ -1217,13 +1215,6 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
12171215 if ( last_user_input . match ( / ^ g : / i) ) {
12181216 // Grounding with Google Search
12191217 data . tools = [ { 'google_search' : { } } ] ;
1220- /*
1221- if(!model.match(/^gemini-1/)){
1222- data.tools = [{'google_search': {}}];
1223- }else {
1224- addWarning("Please use Gemini compatible models for grounding with Google Search!", false)
1225- }
1226- */
12271218
12281219 }
12291220
@@ -1252,9 +1243,18 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
12521243 } )
12531244 . then ( data => {
12541245 let text = '' ;
1246+ let inlineData = '' ;
12551247 if ( typeof data === "object" ) {
12561248 try {
12571249 text = data . candidates [ 0 ] . content . parts [ 0 ] ?. text ?? '' ;
1250+ inlineData = data . candidates [ 0 ] . content . parts [ 0 ] ?. inlineData ?? '' ;
1251+ if ( ! inlineData ) {
1252+ inlineData = data . candidates [ 0 ] . content . parts [ 1 ] ?. inlineData ?? '' ;
1253+ }
1254+ if ( inlineData ) {
1255+ inlineData = `<img class="img_output" src="data:${ inlineData . mimeType } ;base64,${ inlineData . data } " alt="">`
1256+ }
1257+ text += `${ inlineData } ` ;
12581258 let g_tool = data . candidates [ 0 ] . content . parts [ 0 ] ?. functionCall ?? '' ;
12591259 if ( g_tool === '' ) {
12601260 g_tool = data . candidates [ 0 ] . content . parts [ 1 ] ?. functionCall ?? '' ;
@@ -1276,6 +1276,7 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
12761276
12771277 } catch {
12781278 text += '<pre>' + JSON . stringify ( data ) + '</pre>' ;
1279+ console . log ( 'Error' )
12791280 try {
12801281 // Verify if it is an error with the api key being not valid
12811282 let tt = data . error . message ;
@@ -1429,7 +1430,7 @@ function setOptions() {
14291430 let add_new_models = `<button class="more_opt_btn" onclick="addModelsOptions()">Add Models</button>` ;
14301431 let more_option = `<button class="more_opt_btn" onclick="moreOptions()">More Options</button>` ;
14311432 let btn_youtube_api = `<button class="more_opt_btn" onclick="dialogSetYouTubeCaptionApiEndpoint()">YouTube Captions</button>` ;
1432- let bnt_nuggets = `<button class="more_opt_btn btn_new " onclick="goNuggets()">Nuggets</button>` ;
1433+ let bnt_nuggets = `<button class="more_opt_btn" onclick="goNuggets()">Nuggets</button>` ;
14331434
14341435 let cnt =
14351436 `<div>${ platform_options }
@@ -2735,8 +2736,6 @@ async function geminiStreamChat(fileUri, data, allow_tool_use = true) {
27352736 if ( done ) {
27362737 if ( story ) {
27372738 addConversation ( 'assistant' , story , false , false )
2738- //toggleAnimation(true)
2739- //toggleAiGenAnimation(false);
27402739 }
27412740 break ;
27422741 }
@@ -2766,8 +2765,6 @@ async function geminiStreamChat(fileUri, data, allow_tool_use = true) {
27662765 } ) ;
27672766 if ( first_response ) {
27682767 first_response = false ;
2769- //toggleAnimation(true);
2770- //toggleAiGenAnimation(false);
27712768 botMessageDiv . scrollIntoView ( ) ;
27722769 }
27732770 if ( story ) {
@@ -2826,9 +2823,6 @@ async function geminiStreamChat(fileUri, data, allow_tool_use = true) {
28262823 } catch ( error ) {
28272824 console . error ( "Error:" , error ) ;
28282825 addWarning ( 'Error: ' + error . message )
2829- //toggleAnimation(true);
2830- // toggleAiGenAnimation(false);
2831- //enableChat();
28322826 } finally {
28332827 if ( grounding_rendered_cnt ) {
28342828 const all_div_bots = document . querySelectorAll ( '.bot' ) ;
@@ -2840,7 +2834,6 @@ async function geminiStreamChat(fileUri, data, allow_tool_use = true) {
28402834 }
28412835 enableCopyForCode ( ) ;
28422836 enableChat ( ) ;
2843- //toggleAnimation(true)
28442837 toggleAiGenAnimation ( false ) ;
28452838 toggleAiGenAnimation ( false ) ;
28462839 }
0 commit comments