Merge pull request #3434 from sirius422/add-gemini-models Add new gemini models and update the safety settings
Signed| @@ -3075,8 +3075,11 @@ | ||
| 3075 | 3075 | <option value="gemini-1.0-ultra-latest">Gemini 1.0 Ultra</option> |
| 3076 | 3076 | </optgroup> |
| 3077 | 3077 | <optgroup label="Subversions"> |
| 3078 | 3078 | <option value="gemini-2.0-flash-lite-preview-02pro-05exp">Gemini 2.0 Flash Lite PreviewPro 2025-02-05Experimental</option> |
| 3079 | 3079 | <option value="gemini-2.0-pro-exp-02-05">Gemini 2.0 Pro Experimental 2025-02-05</option> |
| 3080 | + <option value="gemini-2.0-flash-lite-preview">Gemini 2.0 Flash-Lite Preview</option> | |
| 3081 | + <option value="gemini-2.0-flash-lite-preview-02-05">Gemini 2.0 Flash-Lite Preview 2025-02-05</option> | |
| 3082 | + <option value="gemini-2.0-flash-001">Gemini 2.0 Flash [001]</option> | |
| 3080 | 3083 | <option value="gemini-2.0-flash-thinking-exp">Gemini 2.0 Flash Thinking Experimental</option> |
| 3081 | 3084 | <option value="gemini-2.0-flash-thinking-exp-01-21">Gemini 2.0 Flash Thinking Experimental 2025-01-21</option> |
| 3082 | 3085 | <option value="gemini-2.0-flash-thinking-exp-1219">Gemini 2.0 Flash Thinking Experimental 2024-12-19</option> |
| @@ -53,6 +53,12 @@ | ||
| 53 | 53 | <option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option> |
| 54 | 54 | <option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> |
| 55 | 55 | <option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option> |
| 56 | + <option data-type="google" value="gemini-2.0-pro-exp">gemini-2.0-pro-exp</option> | |
| 57 | + <option data-type="google" value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05</option> | |
| 58 | + <option data-type="google" value="gemini-2.0-flash-lite-preview">gemini-2.0-flash-lite-preview</option> | |
| 59 | + <option data-type="google" value="gemini-2.0-flash-lite-preview-02-05">gemini-2.0-flash-lite-preview-02-05</option> | |
| 60 | + <option data-type="google" value="gemini-2.0-flash">gemini-2.0-flash</option> | |
| 61 | + <option data-type="google" value="gemini-2.0-flash-001">gemini-2.0-flash-001</option> | |
| 56 | 62 | <option data-type="google" value="gemini-2.0-flash-exp">gemini-2.0-flash-exp</option> |
| 57 | 63 | <option data-type="google" value="gemini-2.0-flash-thinking-exp">gemini-2.0-flash-thinking-exp</option> |
| 58 | 64 | <option data-type="google" value="gemini-2.0-flash-thinking-exp-01-21">gemini-2.0-flash-thinking-exp-01-21</option> |
| @@ -4239,9 +4239,9 @@ async function onModelChange() { | ||
| 4239 | 4239 | $('#openai_max_context').attr('max', max_2mil); |
| 4240 | 4240 | } else if (value.includes('gemini-exp-1114') || value.includes('gemini-exp-1121') || value.includes('gemini-2.0-flash-thinking-exp-1219')) { |
| 4241 | 4241 | $('#openai_max_context').attr('max', max_32k); |
| 4242 | 4242 | } else if (value.includes('gemini-1.5-pro') || value.includes('gemini-exp-1206') || value.includes('gemini-2.0-pro')) { |
| 4243 | 4243 | $('#openai_max_context').attr('max', max_2mil); |
| 4244 | 4244 | } else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash-exp') || value.includes('gemini-2.0-flash-thinking-exp')) { |
| 4245 | 4245 | $('#openai_max_context').attr('max', max_1mil); |
| 4246 | 4246 | } else if (value.includes('gemini-1.0-pro') || value === 'gemini-pro') { |
| 4247 | 4247 | $('#openai_max_context').attr('max', max_32k); |
| @@ -4934,6 +4934,12 @@ export function isImageInliningSupported() { | ||
| 4934 | 4934 | // gultra just isn't being offered as multimodal, thanks google. |
| 4935 | 4935 | const visionSupportedModels = [ |
| 4936 | 4936 | 'gpt-4-vision', |
| 4937 | + 'gemini-2.0-pro-exp', | |
| 4938 | + 'gemini-2.0-pro-exp-02-05', | |
| 4939 | + 'gemini-2.0-flash-lite-preview', | |
| 4940 | + 'gemini-2.0-flash-lite-preview-02-05', | |
| 4941 | + 'gemini-2.0-flash', | |
| 4942 | + 'gemini-2.0-flash-001', | |
| 4937 | 4943 | 'gemini-2.0-flash-thinking-exp-1219', |
| 4938 | 4944 | 'gemini-2.0-flash-thinking-exp-01-21', |
| 4939 | 4945 | 'gemini-2.0-flash-thinking-exp', |
| @@ -139,19 +139,19 @@ export const UNSAFE_EXTENSIONS = [ | ||
| 139 | 139 | export const GEMINI_SAFETY = [ |
| 140 | 140 | { |
| 141 | 141 | category: 'HARM_CATEGORY_HARASSMENT', |
| 142 | 142 | threshold: 'BLOCK_NONEOFF', |
| 143 | 143 | }, |
| 144 | 144 | { |
| 145 | 145 | category: 'HARM_CATEGORY_HATE_SPEECH', |
| 146 | 146 | threshold: 'BLOCK_NONEOFF', |
| 147 | 147 | }, |
| 148 | 148 | { |
| 149 | 149 | category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', |
| 150 | 150 | threshold: 'BLOCK_NONEOFF', |
| 151 | 151 | }, |
| 152 | 152 | { |
| 153 | 153 | category: 'HARM_CATEGORY_DANGEROUS_CONTENT', |
| 154 | 154 | threshold: 'BLOCK_NONEOFF', |
| 155 | 155 | }, |
| 156 | 156 | { |
| 157 | 157 | category: 'HARM_CATEGORY_CIVIC_INTEGRITY', |
| @@ -316,9 +316,15 @@ async function sendMakerSuiteRequest(request, response) { | ||
| 316 | 316 | const prompt = convertGooglePrompt(request.body.messages, model, should_use_system_prompt, getPromptNames(request)); |
| 317 | 317 | let safetySettings = GEMINI_SAFETY; |
| 318 | 318 | |
| 319 | - if (model.includes('gemini-2.0-flash-exp')) { | |
| 319 | + // These old models do not support setting the threshold to OFF at all. | |
| 320 | + if (['gemini-1.5-pro-001', 'gemini-1.5-flash-001', 'gemini-1.0-pro-001'].includes(model)) { | |
| 321 | + safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'BLOCK_NONE' })); | |
| 322 | + } | |
| 323 | + // Interestingly, Gemini 2.0 Flash does support setting the threshold for HARM_CATEGORY_CIVIC_INTEGRITY to OFF. | |
| 324 | + else if (['gemini-2.0-flash', 'gemini-2.0-flash-001', 'gemini-2.0-flash-exp'].includes(model)) { | |
| 320 | 325 | safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'OFF' })); |
| 321 | 326 | } |
| 327 | + // Most of the other models allow for setting the threshold of filters, except for HARM_CATEGORY_CIVIC_INTEGRITY, to OFF. | |
| 322 | 328 | |
| 323 | 329 | let body = { |
| 324 | 330 | contents: prompt.contents, |
| @@ -360,6 +360,12 @@ export function convertCohereMessages(messages, names) { | ||
| 360 | 360 | */ |
| 361 | 361 | export function convertGooglePrompt(messages, model, useSysPrompt, names) { |
| 362 | 362 | const visionSupportedModels = [ |
| 363 | + 'gemini-2.0-pro-exp', | |
| 364 | + 'gemini-2.0-pro-exp-02-05', | |
| 365 | + 'gemini-2.0-flash-lite-preview', | |
| 366 | + 'gemini-2.0-flash-lite-preview-02-05', | |
| 367 | + 'gemini-2.0-flash', | |
| 368 | + 'gemini-2.0-flash-001', | |
| 363 | 369 | 'gemini-2.0-flash-thinking-exp', |
| 364 | 370 | 'gemini-2.0-flash-thinking-exp-01-21', |
| 365 | 371 | 'gemini-2.0-flash-thinking-exp-1219', |