| 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, |