fix: adjust safetySettings handling for legacy and experimental Gemini models

- gemini-1.5-flash-8b-exp-0827
- gemini-1.5-flash-8b-exp-0924
- gemini-pro
- gemini-1.0-pro
This commit is contained in:
sirius422 2025-02-07 16:35:44 +08:00
parent 1acee3d4c9
commit f32938981c

View File

@ -318,7 +318,7 @@ async function sendMakerSuiteRequest(request, response) {
let safetySettings = GEMINI_SAFETY;
// These old models do not support setting the threshold to OFF at all.
if (['gemini-1.5-pro-001', 'gemini-1.5-flash-001', 'gemini-1.0-pro-001'].includes(model)) {
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'].includes(model)) {
safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'BLOCK_NONE' }));
}
// Interestingly, Gemini 2.0 Flash does support setting the threshold for HARM_CATEGORY_CIVIC_INTEGRITY to OFF.