mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Gemma 3 (#3686)
* 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:
@ -3134,6 +3134,9 @@
|
|||||||
<option value="gemini-ultra">Gemini Ultra (1.0)</option>
|
<option value="gemini-ultra">Gemini Ultra (1.0)</option>
|
||||||
<option value="gemini-1.0-ultra-latest">Gemini 1.0 Ultra</option>
|
<option value="gemini-1.0-ultra-latest">Gemini 1.0 Ultra</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
<optgroup label="Gemma">
|
||||||
|
<option value="gemma-3-27b-it">Gemma 3 27B</option>
|
||||||
|
</optgroup>
|
||||||
<optgroup label="Subversions">
|
<optgroup label="Subversions">
|
||||||
<option value="gemini-2.0-pro-exp">Gemini 2.0 Pro Experimental</option>
|
<option value="gemini-2.0-pro-exp">Gemini 2.0 Pro Experimental</option>
|
||||||
<option value="gemini-2.0-pro-exp-02-05">Gemini 2.0 Pro Experimental 2025-02-05</option>
|
<option value="gemini-2.0-pro-exp-02-05">Gemini 2.0 Pro Experimental 2025-02-05</option>
|
||||||
|
@ -4341,10 +4341,12 @@ async function onModelChange() {
|
|||||||
$('#openai_max_context').attr('max', max_32k);
|
$('#openai_max_context').attr('max', max_32k);
|
||||||
} else if (value.includes('gemini-1.0-ultra') || value === 'gemini-ultra') {
|
} else if (value.includes('gemini-1.0-ultra') || value === 'gemini-ultra') {
|
||||||
$('#openai_max_context').attr('max', max_32k);
|
$('#openai_max_context').attr('max', max_32k);
|
||||||
|
} else if (value.includes('gemma-3')) {
|
||||||
|
$('#openai_max_context').attr('max', max_128k);
|
||||||
} else {
|
} else {
|
||||||
$('#openai_max_context').attr('max', max_4k);
|
$('#openai_max_context').attr('max', max_4k);
|
||||||
}
|
}
|
||||||
let makersuite_max_temp = (value.includes('vision') || value.includes('ultra')) ? 1.0 : 2.0;
|
let makersuite_max_temp = (value.includes('vision') || value.includes('ultra') || value.includes('gemma')) ? 1.0 : 2.0;
|
||||||
oai_settings.temp_openai = Math.min(makersuite_max_temp, oai_settings.temp_openai);
|
oai_settings.temp_openai = Math.min(makersuite_max_temp, oai_settings.temp_openai);
|
||||||
$('#temp_openai').attr('max', makersuite_max_temp).val(oai_settings.temp_openai).trigger('input');
|
$('#temp_openai').attr('max', makersuite_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||||
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
|
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
|
||||||
|
@ -340,6 +340,7 @@ async function sendMakerSuiteRequest(request, response) {
|
|||||||
const enableWebSearch = Boolean(request.body.enable_web_search);
|
const enableWebSearch = Boolean(request.body.enable_web_search);
|
||||||
const requestImages = Boolean(request.body.request_images);
|
const requestImages = Boolean(request.body.request_images);
|
||||||
const isThinking = model.includes('thinking');
|
const isThinking = model.includes('thinking');
|
||||||
|
const isGemma = model.includes('gemma');
|
||||||
|
|
||||||
const generationConfig = {
|
const generationConfig = {
|
||||||
stopSequences: request.body.stop,
|
stopSequences: request.body.stop,
|
||||||
@ -375,8 +376,8 @@ async function sendMakerSuiteRequest(request, response) {
|
|||||||
const prompt = convertGooglePrompt(request.body.messages, model, useSystemPrompt, getPromptNames(request));
|
const prompt = convertGooglePrompt(request.body.messages, model, useSystemPrompt, getPromptNames(request));
|
||||||
let safetySettings = GEMINI_SAFETY;
|
let safetySettings = GEMINI_SAFETY;
|
||||||
|
|
||||||
// These old models do not support setting the threshold to OFF at all.
|
// 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'].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', 'gemma-3-27b-it'].includes(model)) {
|
||||||
safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'BLOCK_NONE' }));
|
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.
|
// 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.
|
// 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')
|
const searchTool = model.includes('1.5') || model.includes('1.0')
|
||||||
? ({ google_search_retrieval: {} })
|
? ({ google_search_retrieval: {} })
|
||||||
: ({ google_search: {} });
|
: ({ google_search: {} });
|
||||||
tools.push(searchTool);
|
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 = [];
|
const functionDeclarations = [];
|
||||||
for (const tool of request.body.tools) {
|
for (const tool of request.body.tools) {
|
||||||
if (tool.type === 'function') {
|
if (tool.type === 'function') {
|
||||||
|
Reference in New Issue
Block a user