* Gemma 3

* Adjust safetySettings

* Disable sysprompt

* Add isGemma check to tool processing logic

* Disable a google search tool for gemma
This commit is contained in:
Cohee
2025-03-14 21:41:28 +02:00
committed by GitHub
parent 0017358f8b
commit f607c3bc0d
3 changed files with 11 additions and 5 deletions

View File

@@ -340,6 +340,7 @@ async function sendMakerSuiteRequest(request, response) {
const enableWebSearch = Boolean(request.body.enable_web_search);
const requestImages = Boolean(request.body.request_images);
const isThinking = model.includes('thinking');
const isGemma = model.includes('gemma');
const generationConfig = {
stopSequences: request.body.stop,
@@ -375,8 +376,8 @@ async function sendMakerSuiteRequest(request, response) {
const prompt = convertGooglePrompt(request.body.messages, model, useSystemPrompt, getPromptNames(request));
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.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)) {
// These models do not support setting the threshold to OFF at all.
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)) {
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.
@@ -385,14 +386,14 @@ async function sendMakerSuiteRequest(request, response) {
}
// Most of the other models allow for setting the threshold of filters, except for HARM_CATEGORY_CIVIC_INTEGRITY, to OFF.
if (enableWebSearch && !useMultiModal) {
if (enableWebSearch && !useMultiModal && !isGemma) {
const searchTool = model.includes('1.5') || model.includes('1.0')
? ({ google_search_retrieval: {} })
: ({ google_search: {} });
tools.push(searchTool);
}
if (Array.isArray(request.body.tools) && request.body.tools.length > 0 && !useMultiModal) {
if (Array.isArray(request.body.tools) && request.body.tools.length > 0 && !useMultiModal && !isGemma) {
const functionDeclarations = [];
for (const tool of request.body.tools) {
if (tool.type === 'function') {