diff --git a/public/script.js b/public/script.js index 603cf7033..0266831a8 100644 --- a/public/script.js +++ b/public/script.js @@ -6,6 +6,7 @@ import { loadKoboldSettings, formatKoboldUrl, getKoboldGenerationData, + canUseKoboldStopSequence, } from "./scripts/kai-settings.js"; import { @@ -518,6 +519,11 @@ async function getStatus() { is_pygmalion = false; } + // determine if we can use stop sequence + if (main_api == "kobold") { + kai_settings.use_stop_sequence = canUseKoboldStopSequence(data.version); + } + // determine if streaming is enabled for ooba if (main_api == 'textgenerationwebui' && typeof data.gradio_config == 'string') { try { diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index 9330a3b66..36701fcfd 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -8,6 +8,7 @@ export { loadKoboldSettings, formatKoboldUrl, getKoboldGenerationData, + canUseKoboldStopSequence, }; const kai_settings = { @@ -21,8 +22,11 @@ const kai_settings = { tfs: 1, rep_pen_slope: 0.9, single_line: false, + use_stop_sequence: false, }; +const MIN_STOP_SEQUENCE_VERSION = '1.2.2'; + function formatKoboldUrl(value) { try { const url = new URL(value); @@ -81,7 +85,7 @@ function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, thi s7: this_settings.sampler_order[6], use_world_info: false, singleline: kai_settings.single_line, - stop_sequence: [getStoppingStrings(isImpersonate, false)], + stop_sequence: kai_settings.use_stop_sequence ? [getStoppingStrings(isImpersonate, false)] : undefined, }; return generate_data; } @@ -152,6 +156,10 @@ const sliders = [ }, ]; +function canUseKoboldStopSequence(version) { + return version.localeCompare(MIN_STOP_SEQUENCE_VERSION, undefined, { numeric: true, sensitivity: 'base' }) > -1; +} + $(document).ready(function () { sliders.forEach(slider => { $(document).on("input", slider.sliderId, function () { diff --git a/server.js b/server.js index d51b6bff9..8f4f784c5 100644 --- a/server.js +++ b/server.js @@ -270,8 +270,10 @@ app.post("/generate", jsonParser, async function (request, response_generate = r typical: request.body.typical, sampler_order: sampler_order, singleline: !!request.body.singleline, - stop_sequence: request.body.stop_sequence || [], }; + if (!!request.body.stop_sequence) { + this_settings['stop_sequence'] = request.body.stop_sequence; + } } console.log(this_settings); @@ -536,7 +538,7 @@ app.post("/getchat", jsonParser, function (request, response) { }); -app.post("/getstatus", jsonParser, function (request, response_getstatus = response) { +app.post("/getstatus", jsonParser, async function (request, response_getstatus = response) { if (!request.body) return response_getstatus.sendStatus(400); api_server = request.body.api_server; main_api = request.body.main_api; @@ -547,10 +549,19 @@ app.post("/getstatus", jsonParser, function (request, response_getstatus = respo headers: { "Content-Type": "application/json" } }; var url = api_server + "/v1/model"; + let version = ''; if (main_api == "textgenerationwebui") { url = api_server; args = {} } + if (main_api == "kobold") { + try { + version = (await getAsync(api_server + "/v1/info/version")).result; + } + catch { + version = '0.0.0'; + } + } client.get(url, args, function (data, response) { if (response.statusCode == 200) { if (main_api == "textgenerationwebui") { @@ -568,8 +579,8 @@ app.post("/getstatus", jsonParser, function (request, response_getstatus = respo data = { result: "no_connection" }; } } else { + data.version = version; if (data.result != "ReadOnly") { - //response_getstatus.send(data.result); } else { data.result = "no_connection"; }