Merge pull request #3919 from cloak1505/gemini-patch Prune Google models
Signed| @@ -234,6 +234,10 @@ claude: | |||
| 234 | # should be ideal for most use cases. | 234 | # should be ideal for most use cases. |
| 235 | # Any value other than a non-negative integer will be ignored and caching at depth will not be enabled. | 235 | # Any value other than a non-negative integer will be ignored and caching at depth will not be enabled. |
| 236 | cachingAtDepth: -1 | 236 | cachingAtDepth: -1 |
| 237 | # -- GOOGLE GEMINI API CONFIGURATION -- | ||
| 238 | gemini: | ||
| 239 | # API endpoint version ("v1beta" or "v1alpha") | ||
| 240 | apiVersion: 'v1beta' | ||
| 237 | # -- SERVER PLUGIN CONFIGURATION -- | 241 | # -- SERVER PLUGIN CONFIGURATION -- |
| 238 | enableServerPlugins: false | 242 | enableServerPlugins: false |
| 239 | # Attempt to automatically update server plugins on startup | 243 | # Attempt to automatically update server plugins on startup |
| @@ -2025,7 +2025,7 @@ | |||
| 2025 | <input id="use_makersuite_sysprompt" type="checkbox" /> | 2025 | <input id="use_makersuite_sysprompt" type="checkbox" /> |
| 2026 | <span> | 2026 | <span> |
| 2027 | <span data-i18n="Use system prompt">Use system prompt</span> | 2027 | <span data-i18n="Use system prompt">Use system prompt</span> |
| 2028 | <i class="opacity50p fa-solid fa-circle-info" title="Gemini 1.5/2.0 Pro/Flash"></i> | 2028 | <i class="opacity50p fa-solid fa-circle-info" title="Gemini 1.5+, LearnLM"></i> |
| 2029 | </span> | 2029 | </span> |
| 2030 | </label> | 2030 | </label> |
| 2031 | <div class="toggle-description justifyLeft marginBot5"> | 2031 | <div class="toggle-description justifyLeft marginBot5"> |
| @@ -3146,49 +3146,49 @@ | |||
| 3146 | <div> | 3146 | <div> |
| 3147 | <h4 data-i18n="Google Model">Google Model</h4> | 3147 | <h4 data-i18n="Google Model">Google Model</h4> |
| 3148 | <select id="model_google_select"> | 3148 | <select id="model_google_select"> |
| 3149 | <optgroup label="Primary"> | 3149 | <optgroup label="Gemini 2.5"> |
| 3150 | <option value="gemini-2.0-flash">Gemini 2.0 Flash</option> | 3150 | <option value="gemini-2.5-pro-preview-03-25">gemini-2.5-pro-preview-03-25</option> |
| 3151 | <option value="gemini-1.5-pro">Gemini 1.5 Pro</option> | 3151 | <option value="gemini-2.5-pro-exp-03-25">gemini-2.5-pro-exp-03-25</option> |
| 3152 | <option value="gemini-1.5-flash">Gemini 1.5 Flash</option> | 3152 | <option value="gemini-2.5-flash-preview-04-17">gemini-2.5-flash-preview-04-17</option> |
| 3153 | <option value="gemini-1.0-pro">Gemini 1.0 Pro (Deprecated)</option> | 3153 | </optgroup> |
| 3154 | <option value="gemini-pro">Gemini Pro (1.0) (Deprecated)</option> | 3154 | <optgroup label="Gemini 2.0"> |
| 3155 | <option value="gemini-ultra">Gemini Ultra (1.0)</option> | 3155 | <option value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05 → 2.5-pro-exp-03-25</option> |
| 3156 | <option value="gemini-1.0-ultra-latest">Gemini 1.0 Ultra</option> | 3156 | <option value="gemini-2.0-pro-exp">gemini-2.0-pro-exp → 2.5-pro-exp-03-25</option> |
| 3157 | <option value="gemini-exp-1206">gemini-exp-1206 → 2.5-pro-exp-03-25</option> | ||
| 3158 | <option value="gemini-2.0-flash-001">gemini-2.0-flash-001</option> | ||
| 3159 | <option value="gemini-2.0-flash-exp-image-generation">gemini-2.0-flash-exp-image-generation</option> | ||
| 3160 | <option value="gemini-2.0-flash-exp">gemini-2.0-flash-exp</option> | ||
| 3161 | <option value="gemini-2.0-flash">gemini-2.0-flash</option> | ||
| 3162 | <option value="gemini-2.0-flash-thinking-exp-01-21">gemini-2.0-flash-thinking-exp-01-21 → 2.5-flash-preview-04-17</option> | ||
| 3163 | <option value="gemini-2.0-flash-thinking-exp-1219">gemini-2.0-flash-thinking-exp-1219 → 2.5-flash-preview-04-17</option> | ||
| 3164 | <option value="gemini-2.0-flash-thinking-exp">gemini-2.0-flash-thinking-exp → 2.5-flash-preview-04-17</option> | ||
| 3165 | <option value="gemini-2.0-flash-lite-001">gemini-2.0-flash-lite-001</option> | ||
| 3166 | <option value="gemini-2.0-flash-lite-preview-02-05">gemini-2.0-flash-lite-preview-02-05</option> | ||
| 3167 | <option value="gemini-2.0-flash-lite-preview">gemini-2.0-flash-lite-preview</option> | ||
| 3168 | </optgroup> | ||
| 3169 | <optgroup label="Gemini 1.5"> | ||
| 3170 | <option value="gemini-1.5-pro-latest">gemini-1.5-pro-latest</option> | ||
| 3171 | <option value="gemini-1.5-pro-002">gemini-1.5-pro-002</option> | ||
| 3172 | <option value="gemini-1.5-pro-001">gemini-1.5-pro-001</option> | ||
| 3173 | <option value="gemini-1.5-pro">gemini-1.5-pro</option> | ||
| 3174 | <option value="gemini-1.5-flash-latest">gemini-1.5-flash-latest</option> | ||
| 3175 | <option value="gemini-1.5-flash-002">gemini-1.5-flash-002</option> | ||
| 3176 | <option value="gemini-1.5-flash-001">gemini-1.5-flash-001</option> | ||
| 3177 | <option value="gemini-1.5-flash">gemini-1.5-flash</option> | ||
| 3178 | <option value="gemini-1.5-flash-8b-001">gemini-1.5-flash-8b-001</option> | ||
| 3179 | <option value="gemini-1.5-flash-8b-exp-0924">gemini-1.5-flash-8b-exp-0924</option> | ||
| 3180 | <option value="gemini-1.5-flash-8b-exp-0827">gemini-1.5-flash-8b-exp-0827</option> | ||
| 3181 | <option value="gemini-1.5-flash-8b">gemini-1.5-flash-8b</option> | ||
| 3157 | </optgroup> | 3182 | </optgroup> |
| 3158 | <optgroup label="Gemma"> | 3183 | <optgroup label="Gemma"> |
| 3159 | <option value="gemma-3-27b-it">Gemma 3 27B</option> | 3184 | <option value="gemma-3-27b-it">gemma-3-27b-it</option> |
| 3185 | <option value="gemma-3-12b-it">gemma-3-12b-it</option> | ||
| 3186 | <option value="gemma-3-4b-it">gemma-3-4b-it</option> | ||
| 3187 | <option value="gemma-3-1b-it">gemma-3-1b-it</option> | ||
| 3160 | </optgroup> | 3188 | </optgroup> |
| 3161 | <optgroup label="Subversions"> | 3189 | <optgroup label="LearnLM"> |
| 3162 | <option value="gemini-2.5-pro-preview-03-25">Gemini 2.5 Pro Preview 2025-03-25</option> | 3190 | <option value="learnlm-2.0-flash-experimental">learnlm-2.0-flash-experimental</option> |
| 3163 | <option value="gemini-2.5-pro-exp-03-25">Gemini 2.5 Pro Experimental 2025-03-25</option> | 3191 | <option value="learnlm-1.5-pro-experimental">learnlm-1.5-pro-experimental</option> |
| 3164 | <option value="gemini-2.0-pro-exp">Gemini 2.0 Pro Experimental</option> | ||
| 3165 | <option value="gemini-2.0-pro-exp-02-05">Gemini 2.0 Pro Experimental 2025-02-05</option> | ||
| 3166 | <option value="gemini-2.5-flash-preview-04-17">Gemini 2.5 Flash Preview 2025-04-17</option> | ||
| 3167 | <option value="gemini-2.0-flash-lite-preview">Gemini 2.0 Flash-Lite Preview</option> | ||
| 3168 | <option value="gemini-2.0-flash-lite-preview-02-05">Gemini 2.0 Flash-Lite Preview 2025-02-05</option> | ||
| 3169 | <option value="gemini-2.0-flash-001">Gemini 2.0 Flash [001]</option> | ||
| 3170 | <option value="gemini-2.0-flash-thinking-exp">Gemini 2.0 Flash Thinking Experimental</option> | ||
| 3171 | <option value="gemini-2.0-flash-thinking-exp-01-21">Gemini 2.0 Flash Thinking Experimental 2025-01-21</option> | ||
| 3172 | <option value="gemini-2.0-flash-thinking-exp-1219">Gemini 2.0 Flash Thinking Experimental 2024-12-19</option> | ||
| 3173 | <option value="gemini-2.0-flash-exp">Gemini 2.0 Flash Experimental</option> | ||
| 3174 | <option value="gemini-2.0-flash-exp-image-generation">Gemini 2.0 Flash (Image Generation) Experimental</option> | ||
| 3175 | <option value="gemini-exp-1114">Gemini Experimental 2024-11-14</option> | ||
| 3176 | <option value="gemini-exp-1121">Gemini Experimental 2024-11-21</option> | ||
| 3177 | <option value="gemini-exp-1206">Gemini Experimental 2024-12-06</option> | ||
| 3178 | <option value="gemini-1.5-pro-exp-0801">Gemini 1.5 Pro Experimental 2024-08-01</option> | ||
| 3179 | <option value="gemini-1.5-pro-exp-0827">Gemini 1.5 Pro Experimental 2024-08-27</option> | ||
| 3180 | <option value="gemini-1.5-pro-latest">Gemini 1.5 Pro [latest]</option> | ||
| 3181 | <option value="gemini-1.5-pro-001">Gemini 1.5 Pro [001]</option> | ||
| 3182 | <option value="gemini-1.5-pro-002">Gemini 1.5 Pro [002]</option> | ||
| 3183 | <option value="gemini-1.5-flash-8b">Gemini 1.5 Flash 8B</option> | ||
| 3184 | <option value="gemini-1.5-flash-exp-0827">Gemini 1.5 Flash Experimental 2024-08-27</option> | ||
| 3185 | <option value="gemini-1.5-flash-8b-exp-0827">Gemini 1.5 Flash 8B Experimental 2024-08-27</option> | ||
| 3186 | <option value="gemini-1.5-flash-8b-exp-0924">Gemini 1.5 Flash 8B Experimental 2024-09-24</option> | ||
| 3187 | <option value="gemini-1.5-flash-latest">Gemini 1.5 Flash [latest]</option> | ||
| 3188 | <option value="gemini-1.5-flash-001">Gemini 1.5 Flash [001]</option> | ||
| 3189 | <option value="gemini-1.5-flash-002">Gemini 1.5 Flash [002]</option> | ||
| 3190 | <option value="gemini-1.0-pro-latest">Gemini 1.0 Pro [latest] (Deprecated)</option> | ||
| 3191 | <option value="gemini-1.0-pro-001">Gemini 1.0 Pro (Tuning) [001] (Deprecated)</option> | ||
| 3192 | </optgroup> | 3192 | </optgroup> |
| 3193 | </select> | 3193 | </select> |
| 3194 | </div> | 3194 | </div> |
| @@ -79,34 +79,33 @@ | |||
| 79 | <option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option> | 79 | <option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option> |
| 80 | <option data-type="google" value="gemini-2.5-pro-preview-03-25">gemini-2.5-pro-preview-03-25</option> | 80 | <option data-type="google" value="gemini-2.5-pro-preview-03-25">gemini-2.5-pro-preview-03-25</option> |
| 81 | <option data-type="google" value="gemini-2.5-pro-exp-03-25">gemini-2.5-pro-exp-03-25</option> | 81 | <option data-type="google" value="gemini-2.5-pro-exp-03-25">gemini-2.5-pro-exp-03-25</option> |
| 82 | <option data-type="google" value="gemini-2.0-pro-exp">gemini-2.0-pro-exp</option> | ||
| 83 | <option data-type="google" value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05</option> | ||
| 84 | <option data-type="google" value="gemini-2.5-flash-preview-04-17">gemini-2.5-flash-preview-04-17</option> | 82 | <option data-type="google" value="gemini-2.5-flash-preview-04-17">gemini-2.5-flash-preview-04-17</option> |
| 85 | <option data-type="google" value="gemini-2.0-flash-lite-preview">gemini-2.0-flash-lite-preview</option> | 83 | <option data-type="google" value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05 → 2.5-pro-exp-03-25</option> |
| 86 | <option data-type="google" value="gemini-2.0-flash-lite-preview-02-05">gemini-2.0-flash-lite-preview-02-05</option> | 84 | <option data-type="google" value="gemini-2.0-pro-exp">gemini-2.0-pro-exp → 2.5-pro-exp-03-25</option> |
| 87 | <option data-type="google" value="gemini-2.0-flash">gemini-2.0-flash</option> | 85 | <option data-type="google" value="gemini-exp-1206">gemini-exp-1206 → 2.5-pro-exp-03-25</option> |
| 88 | <option data-type="google" value="gemini-2.0-flash-001">gemini-2.0-flash-001</option> | 86 | <option data-type="google" value="gemini-2.0-flash-001">gemini-2.0-flash-001</option> |
| 89 | <option data-type="google" value="gemini-2.0-flash-exp">gemini-2.0-flash-exp</option> | ||
| 90 | <option data-type="google" value="gemini-2.0-flash-exp-image-generation">gemini-2.0-flash-exp-image-generation</option> | 87 | <option data-type="google" value="gemini-2.0-flash-exp-image-generation">gemini-2.0-flash-exp-image-generation</option> |
| 91 | <option data-type="google" value="gemini-2.0-flash-thinking-exp">gemini-2.0-flash-thinking-exp</option> | 88 | <option data-type="google" value="gemini-2.0-flash-exp">gemini-2.0-flash-exp</option> |
| 92 | <option data-type="google" value="gemini-2.0-flash-thinking-exp-01-21">gemini-2.0-flash-thinking-exp-01-21</option> | 89 | <option data-type="google" value="gemini-2.0-flash">gemini-2.0-flash</option> |
| 93 | <option data-type="google" value="gemini-2.0-flash-thinking-exp-1219">gemini-2.0-flash-thinking-exp-1219</option> | 90 | <option data-type="google" value="gemini-2.0-flash-thinking-exp-01-21">gemini-2.0-flash-thinking-exp-01-21 → 2.5-flash-preview-04-17</option> |
| 94 | <option data-type="google" value="gemini-1.5-flash">gemini-1.5-flash</option> | 91 | <option data-type="google" value="gemini-2.0-flash-thinking-exp-1219">gemini-2.0-flash-thinking-exp-1219 → 2.5-flash-preview-04-17</option> |
| 92 | <option data-type="google" value="gemini-2.0-flash-thinking-exp">gemini-2.0-flash-thinking-exp → 2.5-flash-preview-04-17</option> | ||
| 93 | <option data-type="google" value="gemini-2.0-flash-lite-001">gemini-2.0-flash-lite-001</option> | ||
| 94 | <option data-type="google" value="gemini-2.0-flash-lite-preview-02-05">gemini-2.0-flash-lite-preview-02-05</option> | ||
| 95 | <option data-type="google" value="gemini-2.0-flash-lite-preview">gemini-2.0-flash-lite-preview</option> | ||
| 96 | <option data-type="google" value="gemini-1.5-pro-latest">gemini-1.5-pro-latest</option> | ||
| 97 | <option data-type="google" value="gemini-1.5-pro-002">gemini-1.5-pro-002</option> | ||
| 98 | <option data-type="google" value="gemini-1.5-pro-001">gemini-1.5-pro-001</option> | ||
| 99 | <option data-type="google" value="gemini-1.5-pro">gemini-1.5-pro</option> | ||
| 95 | <option data-type="google" value="gemini-1.5-flash-latest">gemini-1.5-flash-latest</option> | 100 | <option data-type="google" value="gemini-1.5-flash-latest">gemini-1.5-flash-latest</option> |
| 96 | <option data-type="google" value="gemini-1.5-flash-001">gemini-1.5-flash-001</option> | ||
| 97 | <option data-type="google" value="gemini-1.5-flash-002">gemini-1.5-flash-002</option> | 101 | <option data-type="google" value="gemini-1.5-flash-002">gemini-1.5-flash-002</option> |
| 98 | <option data-type="google" value="gemini-1.5-flash-exp-0827">gemini-1.5-flash-exp-0827</option> | 102 | <option data-type="google" value="gemini-1.5-flash-001">gemini-1.5-flash-001</option> |
| 99 | <option data-type="google" value="gemini-1.5-flash-8b-exp-0827">gemini-1.5-flash-8b-exp-0827</option> | 103 | <option data-type="google" value="gemini-1.5-flash">gemini-1.5-flash</option> |
| 104 | <option data-type="google" value="gemini-1.5-flash-8b-001">gemini-1.5-flash-8b-001</option> | ||
| 100 | <option data-type="google" value="gemini-1.5-flash-8b-exp-0924">gemini-1.5-flash-8b-exp-0924</option> | 105 | <option data-type="google" value="gemini-1.5-flash-8b-exp-0924">gemini-1.5-flash-8b-exp-0924</option> |
| 101 | <option data-type="google" value="gemini-exp-1114">gemini-exp-1114</option> | 106 | <option data-type="google" value="gemini-1.5-flash-8b-exp-0827">gemini-1.5-flash-8b-exp-0827</option> |
| 102 | <option data-type="google" value="gemini-exp-1121">gemini-exp-1121</option> | 107 | <option data-type="google" value="learnlm-2.0-flash-experimental">learnlm-2.0-flash-experimental</option> |
| 103 | <option data-type="google" value="gemini-exp-1206">gemini-exp-1206</option> | 108 | <option data-type="google" value="learnlm-1.5-pro-experimental">learnlm-1.5-pro-experimental</option> |
| 104 | <option data-type="google" value="gemini-1.5-pro">gemini-1.5-pro</option> | ||
| 105 | <option data-type="google" value="gemini-1.5-pro-latest">gemini-1.5-pro-latest</option> | ||
| 106 | <option data-type="google" value="gemini-1.5-pro-001">gemini-1.5-pro-001</option> | ||
| 107 | <option data-type="google" value="gemini-1.5-pro-002">gemini-1.5-pro-002</option> | ||
| 108 | <option data-type="google" value="gemini-1.5-pro-exp-0801">gemini-1.5-pro-exp-0801</option> | ||
| 109 | <option data-type="google" value="gemini-1.5-pro-exp-0827">gemini-1.5-pro-exp-0827</option> | ||
| 110 | <option data-type="groq" value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview</option> | 109 | <option data-type="groq" value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview</option> |
| 111 | <option data-type="groq" value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview</option> | 110 | <option data-type="groq" value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview</option> |
| 112 | <option data-type="groq" value="llava-v1.5-7b-4096-preview">llava-v1.5-7b-4096-preview</option> | 111 | <option data-type="groq" value="llava-v1.5-7b-4096-preview">llava-v1.5-7b-4096-preview</option> |
| @@ -4481,20 +4481,16 @@ async function onModelChange() { | |||
| 4481 | if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) { | 4481 | if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) { |
| 4482 | if (oai_settings.max_context_unlocked) { | 4482 | if (oai_settings.max_context_unlocked) { |
| 4483 | $('#openai_max_context').attr('max', max_2mil); | 4483 | $('#openai_max_context').attr('max', max_2mil); |
| 4484 | } else if (value.includes('gemini-exp-1114') || value.includes('gemini-exp-1121') || value.includes('gemini-2.0-flash-thinking-exp-1219')) { | 4484 | } else if (value.includes('gemini-1.5-pro')) { |
| 4485 | $('#openai_max_context').attr('max', max_32k); | ||
| 4486 | } else if (value.includes('gemini-1.5-pro') || value.includes('gemini-exp-1206') || value.includes('gemini-2.0-pro')) { | ||
| 4487 | $('#openai_max_context').attr('max', max_2mil); | 4485 | $('#openai_max_context').attr('max', max_2mil); |
| 4488 | } else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash') || value.includes('gemini-2.5-flash-preview-04-17') || value.includes('gemini-2.5-pro-exp-03-25') || value.includes('gemini-2.5-pro-preview-03-25')) { | 4486 | } else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash') || value.includes('gemini-2.0-pro') || value.includes('gemini-exp') || value.includes('gemini-2.5-flash') || value.includes('gemini-2.5-pro') || value.includes('learnlm-2.0-flash')) { |
| 4489 | $('#openai_max_context').attr('max', max_1mil); | 4487 | $('#openai_max_context').attr('max', max_1mil); |
| 4490 | } else if (value.includes('gemini-1.0-pro') || value === 'gemini-pro') { | 4488 | } else if (value.includes('gemma-3-27b-it')) { |
| 4491 | $('#openai_max_context').attr('max', max_32k); | ||
| 4492 | } else if (value.includes('gemini-1.0-ultra') || value === 'gemini-ultra') { | ||
| 4493 | $('#openai_max_context').attr('max', max_32k); | ||
| 4494 | } else if (value.includes('gemma-3')) { | ||
| 4495 | $('#openai_max_context').attr('max', max_128k); | 4489 | $('#openai_max_context').attr('max', max_128k); |
| 4490 | } else if (value.includes('gemma-3') || value.includes('learnlm-1.5-pro-experimental')) { | ||
| 4491 | $('#openai_max_context').attr('max', max_32k); | ||
| 4496 | } else { | 4492 | } else { |
| 4497 | $('#openai_max_context').attr('max', max_4k); | 4493 | $('#openai_max_context').attr('max', max_32k); |
| 4498 | } | 4494 | } |
| 4499 | let makersuite_max_temp = (value.includes('vision') || value.includes('ultra') || value.includes('gemma')) ? 1.0 : 2.0; | 4495 | let makersuite_max_temp = (value.includes('vision') || value.includes('ultra') || value.includes('gemma')) ? 1.0 : 2.0; |
| 4500 | oai_settings.temp_openai = Math.min(makersuite_max_temp, oai_settings.temp_openai); | 4496 | oai_settings.temp_openai = Math.min(makersuite_max_temp, oai_settings.temp_openai); |
| @@ -5152,9 +5148,8 @@ export function isImageInliningSupported() { | |||
| 5152 | 'gemini-1.5', | 5148 | 'gemini-1.5', |
| 5153 | 'gemini-2.0', | 5149 | 'gemini-2.0', |
| 5154 | 'gemini-2.5', | 5150 | 'gemini-2.5', |
| 5155 | 'gemini-exp-1114', | ||
| 5156 | 'gemini-exp-1121', | ||
| 5157 | 'gemini-exp-1206', | 5151 | 'gemini-exp-1206', |
| 5152 | 'learnlm', | ||
| 5158 | // MistralAI | 5153 | // MistralAI |
| 5159 | 'mistral-small-2503', | 5154 | 'mistral-small-2503', |
| 5160 | 'mistral-small-latest', | 5155 | 'mistral-small-latest', |
| @@ -5168,7 +5163,7 @@ export function isImageInliningSupported() { | |||
| 5168 | case chat_completion_sources.OPENAI: | 5163 | case chat_completion_sources.OPENAI: |
| 5169 | return visionSupportedModels.some(model => | 5164 | return visionSupportedModels.some(model => |
| 5170 | oai_settings.openai_model.includes(model) | 5165 | oai_settings.openai_model.includes(model) |
| 5171 | && ['gpt-4-turbo-preview', 'o1-mini', 'o3-mini'].some(x => !oai_settings.openai_model.includes(x)) | 5166 | && ['gpt-4-turbo-preview', 'o1-mini', 'o3-mini'].some(x => !oai_settings.openai_model.includes(x)), |
| 5172 | ); | 5167 | ); |
| 5173 | case chat_completion_sources.MAKERSUITE: | 5168 | case chat_completion_sources.MAKERSUITE: |
| 5174 | return visionSupportedModels.some(model => oai_settings.google_model.includes(model)); | 5169 | return visionSupportedModels.some(model => oai_settings.google_model.includes(model)); |
| @@ -156,7 +156,7 @@ export const GEMINI_SAFETY = [ | |||
| 156 | }, | 156 | }, |
| 157 | { | 157 | { |
| 158 | category: 'HARM_CATEGORY_CIVIC_INTEGRITY', | 158 | category: 'HARM_CATEGORY_CIVIC_INTEGRITY', |
| 159 | threshold: 'BLOCK_NONE', | 159 | threshold: 'OFF', |
| 160 | }, | 160 | }, |
| 161 | ]; | 161 | ]; |
| 162 | 162 | ||
| @@ -343,8 +343,8 @@ async function sendMakerSuiteRequest(request, response) { | |||
| 343 | const enableWebSearch = Boolean(request.body.enable_web_search); | 343 | const enableWebSearch = Boolean(request.body.enable_web_search); |
| 344 | const requestImages = Boolean(request.body.request_images); | 344 | const requestImages = Boolean(request.body.request_images); |
| 345 | const reasoningEffort = String(request.body.reasoning_effort); | 345 | const reasoningEffort = String(request.body.reasoning_effort); |
| 346 | const isThinking = model.includes('thinking'); | ||
| 347 | const isGemma = model.includes('gemma'); | 346 | const isGemma = model.includes('gemma'); |
| 347 | const isLearnLM = model.includes('learnlm'); | ||
| 348 | 348 | ||
| 349 | const generationConfig = { | 349 | const generationConfig = { |
| 350 | stopSequences: request.body.stop, | 350 | stopSequences: request.body.stop, |
| @@ -358,48 +358,60 @@ async function sendMakerSuiteRequest(request, response) { | |||
| 358 | }; | 358 | }; |
| 359 | 359 | ||
| 360 | function getGeminiBody() { | 360 | function getGeminiBody() { |
| 361 | // #region UGLY MODEL LISTS AREA | ||
| 362 | const imageGenerationModels = [ | ||
| 363 | 'gemini-2.0-flash-exp', | ||
| 364 | 'gemini-2.0-flash-exp-image-generation', | ||
| 365 | ]; | ||
| 366 | |||
| 367 | // These models do not support setting the threshold to OFF at all. | ||
| 368 | const blockNoneModels = [ | ||
| 369 | 'gemini-1.5-pro-001', | ||
| 370 | 'gemini-1.5-flash-001', | ||
| 371 | 'gemini-1.5-flash-8b-exp-0827', | ||
| 372 | 'gemini-1.5-flash-8b-exp-0924', | ||
| 373 | ]; | ||
| 374 | |||
| 375 | const thinkingBudgetModels = [ | ||
| 376 | 'gemini-2.5-flash-preview-04-17', | ||
| 377 | ]; | ||
| 378 | |||
| 379 | const noSearchModels = [ | ||
| 380 | 'gemini-2.0-flash-lite', | ||
| 381 | 'gemini-2.0-flash-lite-001', | ||
| 382 | 'gemini-2.0-flash-lite-preview-02-05', | ||
| 383 | 'gemini-1.5-flash-8b-exp-0924', | ||
| 384 | 'gemini-1.5-flash-8b-exp-0827', | ||
| 385 | ]; | ||
| 386 | // #endregion | ||
| 387 | |||
| 361 | if (!Array.isArray(generationConfig.stopSequences) || !generationConfig.stopSequences.length) { | 388 | if (!Array.isArray(generationConfig.stopSequences) || !generationConfig.stopSequences.length) { |
| 362 | delete generationConfig.stopSequences; | 389 | delete generationConfig.stopSequences; |
| 363 | } | 390 | } |
| 364 | 391 | ||
| 365 | const useMultiModal = requestImages && ['gemini-2.0-flash-exp', 'gemini-2.0-flash-exp-image-generation'].includes(model); | 392 | const enableImageModality = requestImages && imageGenerationModels.includes(model); |
| 366 | if (useMultiModal) { | 393 | if (enableImageModality) { |
| 367 | generationConfig.responseModalities = ['text', 'image']; | 394 | generationConfig.responseModalities = ['text', 'image']; |
| 368 | } | 395 | } |
| 369 | 396 | ||
| 370 | const useSystemPrompt = !useMultiModal && ( | 397 | const useSystemPrompt = !enableImageModality && !isGemma && request.body.use_makersuite_sysprompt; |
| 371 | model.includes('gemini-2.5-pro') || | ||
| 372 | model.includes('gemini-2.5-flash') || | ||
| 373 | model.includes('gemini-2.0-pro') || | ||
| 374 | model.includes('gemini-2.0-flash') || | ||
| 375 | model.includes('gemini-2.0-flash-thinking-exp') || | ||
| 376 | model.includes('gemini-1.5-flash') || | ||
| 377 | model.includes('gemini-1.5-pro') || | ||
| 378 | model.startsWith('gemini-exp') | ||
| 379 | ) && request.body.use_makersuite_sysprompt; | ||
| 380 | 398 | ||
| 381 | const tools = []; | 399 | const tools = []; |
| 382 | const prompt = convertGooglePrompt(request.body.messages, model, useSystemPrompt, getPromptNames(request)); | 400 | const prompt = convertGooglePrompt(request.body.messages, model, useSystemPrompt, getPromptNames(request)); |
| 383 | let safetySettings = GEMINI_SAFETY; | 401 | let safetySettings = GEMINI_SAFETY; |
| 384 | 402 | ||
| 385 | // These models do not support setting the threshold to OFF at all. | 403 | if (blockNoneModels.includes(model)) { |
| 386 | if (['gemini-1.5-pro-001', 'gemini-1.5-flash-001', 'gemini-1.5-flash-8b-exp-0827', 'gemini-1.5-flash-8b-exp-0924', 'gemini-pro', 'gemini-1.0-pro', 'gemini-1.0-pro-001', 'gemma-3-27b-it'].includes(model)) { | ||
| 387 | safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'BLOCK_NONE' })); | 404 | safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'BLOCK_NONE' })); |
| 388 | } | 405 | } |
| 389 | // Interestingly, Gemini 2.0 Flash does support setting the threshold for HARM_CATEGORY_CIVIC_INTEGRITY to OFF. | ||
| 390 | else if (['gemini-2.0-flash', 'gemini-2.0-flash-001', 'gemini-2.0-flash-exp', 'gemini-2.0-flash-exp-image-generation'].includes(model)) { | ||
| 391 | safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'OFF' })); | ||
| 392 | } | ||
| 393 | // Most of the other models allow for setting the threshold of filters, except for HARM_CATEGORY_CIVIC_INTEGRITY, to OFF. | ||
| 394 | 406 | ||
| 395 | if (enableWebSearch && !useMultiModal && !isGemma) { | 407 | if (enableWebSearch && !enableImageModality && !isGemma && !isLearnLM && !noSearchModels.includes(model)) { |
| 396 | const searchTool = model.includes('1.5') || model.includes('1.0') | 408 | const searchTool = model.includes('1.5') |
| 397 | ? ({ google_search_retrieval: {} }) | 409 | ? ({ google_search_retrieval: {} }) |
| 398 | : ({ google_search: {} }); | 410 | : ({ google_search: {} }); |
| 399 | tools.push(searchTool); | 411 | tools.push(searchTool); |
| 400 | } | 412 | } |
| 401 | 413 | ||
| 402 | if (Array.isArray(request.body.tools) && request.body.tools.length > 0 && !useMultiModal && !isGemma) { | 414 | if (Array.isArray(request.body.tools) && request.body.tools.length > 0 && !enableImageModality && !isGemma) { |
| 403 | const functionDeclarations = []; | 415 | const functionDeclarations = []; |
| 404 | for (const tool of request.body.tools) { | 416 | for (const tool of request.body.tools) { |
| 405 | if (tool.type === 'function') { | 417 | if (tool.type === 'function') { |
| @@ -415,11 +427,6 @@ async function sendMakerSuiteRequest(request, response) { | |||
| 415 | tools.push({ function_declarations: functionDeclarations }); | 427 | tools.push({ function_declarations: functionDeclarations }); |
| 416 | } | 428 | } |
| 417 | 429 | ||
| 418 | // One more models list to maintain, yay | ||
| 419 | const thinkingBudgetModels = [ | ||
| 420 | 'gemini-2.5-flash-preview-04-17', | ||
| 421 | ]; | ||
| 422 | |||
| 423 | if (thinkingBudgetModels.includes(model)) { | 430 | if (thinkingBudgetModels.includes(model)) { |
| 424 | const thinkingBudget = calculateGoogleBudgetTokens(generationConfig.maxOutputTokens, reasoningEffort); | 431 | const thinkingBudget = calculateGoogleBudgetTokens(generationConfig.maxOutputTokens, reasoningEffort); |
| 425 | 432 | ||
| @@ -455,7 +462,7 @@ async function sendMakerSuiteRequest(request, response) { | |||
| 455 | controller.abort(); | 462 | controller.abort(); |
| 456 | }); | 463 | }); |
| 457 | 464 | ||
| 458 | const apiVersion = isThinking ? 'v1alpha' : 'v1beta'; | 465 | const apiVersion = getConfigValue('gemini.apiVersion', 'v1beta'); |
| 459 | const responseType = (stream ? 'streamGenerateContent' : 'generateContent'); | 466 | const responseType = (stream ? 'streamGenerateContent' : 'generateContent'); |
| 460 | 467 | ||
| 461 | const generateResponse = await fetch(`${apiUrl.toString().replace(/\/$/, '')}/${apiVersion}/models/${model}:${responseType}?key=${apiKey}${stream ? '&alt=sse' : ''}`, { | 468 | const generateResponse = await fetch(`${apiUrl.toString().replace(/\/$/, '')}/${apiVersion}/models/${model}:${responseType}?key=${apiKey}${stream ? '&alt=sse' : ''}`, { |
| @@ -466,7 +473,7 @@ async function sendMakerSuiteRequest(request, response) { | |||
| 466 | }, | 473 | }, |
| 467 | signal: controller.signal, | 474 | signal: controller.signal, |
| 468 | }); | 475 | }); |
| 469 | // have to do this because of their busted ass streaming endpoint | 476 | |
| 470 | if (stream) { | 477 | if (stream) { |
| 471 | try { | 478 | try { |
| 472 | // Pipe remote SSE stream to Express response | 479 | // Pipe remote SSE stream to Express response |