mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Added stop sequences for Kobold.cpp
This commit is contained in:
@@ -128,6 +128,7 @@ export {
|
|||||||
getTokenCount,
|
getTokenCount,
|
||||||
isStreamingEnabled,
|
isStreamingEnabled,
|
||||||
getThumbnailUrl,
|
getThumbnailUrl,
|
||||||
|
getStoppingStrings,
|
||||||
chat,
|
chat,
|
||||||
this_chid,
|
this_chid,
|
||||||
settings,
|
settings,
|
||||||
@@ -1013,10 +1014,11 @@ function substituteParams(content, _name1, _name2) {
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStoppingStrings(isImpersonate) {
|
function getStoppingStrings(isImpersonate, wrapInQuotes) {
|
||||||
const charString = `"\n${name2}: "`;
|
const charString = `\n${name2}: `;
|
||||||
const userString = is_pygmalion ? `"\nYou: "` : `"\n${name1}: "`;
|
const userString = is_pygmalion ? `\nYou: ` : `\n${name1}: `;
|
||||||
return isImpersonate ? charString : userString;
|
const result = isImpersonate ? charString : userString;
|
||||||
|
return wrapInQuotes ? `"${result}"` : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSlashCommand(message, type) {
|
function getSlashCommand(message, type) {
|
||||||
@@ -1862,7 +1864,7 @@ async function Generate(type, automatic_trigger, force_name2) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (preset_settings != 'gui' || horde_settings.use_horde) {
|
if (preset_settings != 'gui' || horde_settings.use_horde) {
|
||||||
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context);
|
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context, isImpersonate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1886,7 +1888,7 @@ async function Generate(type, automatic_trigger, force_name2) {
|
|||||||
'early_stopping': textgenerationwebui_settings.early_stopping,
|
'early_stopping': textgenerationwebui_settings.early_stopping,
|
||||||
'seed': textgenerationwebui_settings.seed,
|
'seed': textgenerationwebui_settings.seed,
|
||||||
'add_bos_token': textgenerationwebui_settings.add_bos_token,
|
'add_bos_token': textgenerationwebui_settings.add_bos_token,
|
||||||
'custom_stopping_strings': JSON.stringify(getStoppingStrings(isImpersonate)),
|
'custom_stopping_strings': JSON.stringify(getStoppingStrings(isImpersonate, false)),
|
||||||
'truncation_length': max_context,
|
'truncation_length': max_context,
|
||||||
'ban_eos_token': textgenerationwebui_settings.ban_eos_token,
|
'ban_eos_token': textgenerationwebui_settings.ban_eos_token,
|
||||||
'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens,
|
'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens,
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
saveSettingsDebounced,
|
saveSettingsDebounced,
|
||||||
|
getStoppingStrings,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -55,7 +56,7 @@ function loadKoboldSettings(preset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context) {
|
function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context, isImpersonate) {
|
||||||
let generate_data = {
|
let generate_data = {
|
||||||
prompt: finalPromt,
|
prompt: finalPromt,
|
||||||
gui_settings: false,
|
gui_settings: false,
|
||||||
@@ -80,6 +81,7 @@ function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, thi
|
|||||||
s7: this_settings.sampler_order[6],
|
s7: this_settings.sampler_order[6],
|
||||||
use_world_info: false,
|
use_world_info: false,
|
||||||
singleline: kai_settings.single_line,
|
singleline: kai_settings.single_line,
|
||||||
|
stop_sequence: [getStoppingStrings(isImpersonate, false)],
|
||||||
};
|
};
|
||||||
return generate_data;
|
return generate_data;
|
||||||
}
|
}
|
||||||
|
@@ -270,6 +270,7 @@ app.post("/generate", jsonParser, async function (request, response_generate = r
|
|||||||
typical: request.body.typical,
|
typical: request.body.typical,
|
||||||
sampler_order: sampler_order,
|
sampler_order: sampler_order,
|
||||||
singleline: !!request.body.singleline,
|
singleline: !!request.body.singleline,
|
||||||
|
stop_sequence: request.body.stop_sequence || [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user