Add single-line mode for Kobold

This commit is contained in:
SillyLossy
2023-03-20 00:31:12 +02:00
parent 6177985340
commit 15edcbb4ac
6 changed files with 43 additions and 7 deletions

View File

@ -558,6 +558,10 @@
<div class="drawer-icon down"></div>
</div>
<div class="drawer-content">
<label class="checkbox_label" for="single_line">
<input id="single_line" type="checkbox" />
<h4>Single-line mode</h4>
</label>
<div class="range-block">
<div class="range-block-title">
<h4>Top P Sampling</h4>

View File

@ -21,6 +21,11 @@
process. It is important to be careful when making changes to these settings without proper
consideration, as doing so may result in degraded quality of responses.
</p>
<h3>Single-line mode</h3>
<p>
In single-line mode the AI generates only one line per request. This allows for quicker generation of
shorter prompts, but it does not produce responses that consist of more than one line.
</p>
<h3>Top P Sampling</h3>
<p>
This setting controls how much of the text generated is based on the most likely options.

View File

@ -846,8 +846,8 @@ function addOneMessage(mes, type = "normal") {
var $textchat = $("#chat");
$('#chat .mes').last().addClass('last_mes');
$('#chat .mes').eq(-2).removeClass('last_mes');
$textchat.scrollTop(($textchat[0].scrollHeight));
//$textchat.scrollTop(($textchat[0].scrollHeight));
$('#chat .mes').last().get(0).scrollIntoView({ behavior: "smooth" });
//console.log(chat[chat.length - 1].["swipes"]);
@ -1397,7 +1397,14 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
var generate_data;
if (main_api == 'kobold') {
var generate_data = { prompt: finalPromt, gui_settings: true, max_length: amount_gen, temperature: kai_settings.temp, max_context_length: max_context };
var generate_data = {
prompt: finalPromt,
gui_settings: true,
max_length: amount_gen,
temperature: kai_settings.temp,
max_context_length: max_context,
singleline: kai_settings.single_line,
};
if (preset_settings != 'gui') {
generate_data = {
@ -1423,6 +1430,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
s6: this_settings.sampler_order[5],
s7: this_settings.sampler_order[6],
use_world_info: false,
singleline: kai_settings.single_line,
};
}
}

View File

@ -17,22 +17,29 @@ const kai_settings = {
typical: 1,
tfs: 1,
rep_pen_slope: 0.9,
single_line: false,
};
function loadKoboldSettings(preset) {
for (const name of Object.keys(kai_settings)) {
const value = preset[name];
const slider = sliders.find(x => x.name === name);
if (value === undefined) {
if (value === undefined || !slider) {
continue;
}
const slider = sliders.find(x => x.name === name);
const formattedValue = slider.format(value);
slider.setValue(preset[name]);
$(slider.sliderId).val(preset[name]);
$(slider.counterId).text(formattedValue);
}
// TODO: refactor checkboxes (if adding any more)
if (preset.hasOwnProperty('single_line')) {
kai_settings.single_line = preset.single_line;
$('#single_line').prop('checked', kai_settings.single_line);
}
}
const sliders = [
@ -111,4 +118,10 @@ $(document).ready(function () {
saveSettingsDebounced();
});
});
$('#single_line').on("input", function() {
const value = $(this).prop('checked');
kai_settings.single_line = value;
saveSettingsDebounced();
});
});

View File

@ -2822,6 +2822,10 @@ label[for="extensions_autoconnect"] {
display: none;
}
.drawer-content .checkbox_label {
margin: 1rem 0;
}
.extensions_info {
text-align: left;
margin: 0 1em;

View File

@ -238,7 +238,8 @@ app.post("/generate", jsonParser, async function (request, response_generate = r
use_memory: false,
use_authors_note: false,
use_world_info: false,
max_context_length: request.body.max_context_length
max_context_length: request.body.max_context_length,
singleline: !!request.body.singleline,
//temperature: request.body.temperature,
//max_length: request.body.max_length
};
@ -262,7 +263,8 @@ app.post("/generate", jsonParser, async function (request, response_generate = r
top_k: request.body.top_k,
top_p: request.body.top_p,
typical: request.body.typical,
sampler_order: sampler_order
sampler_order: sampler_order,
singleline: !!request.body.singleline,
};
}