mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Separate horde adjust settings
This commit is contained in:
@@ -979,9 +979,14 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<label for="horde_auto_adjust" class="checkbox_label">
|
||||
<input id="horde_auto_adjust" type="checkbox" />
|
||||
Adjust generation to worker capabilities
|
||||
<label for="horde_auto_adjust_context_length" class="checkbox_label">
|
||||
<input id="horde_auto_adjust_context_length" type="checkbox" />
|
||||
Adjust context size to worker capabilities
|
||||
</label>
|
||||
|
||||
<label for="horde_auto_adjust_response_length" class="checkbox_label">
|
||||
<input id="horde_auto_adjust_response_length" type="checkbox" />
|
||||
Adjust response length to worker capabilities
|
||||
</label>
|
||||
<h4>API key</h4>
|
||||
<h5>Get it here: <a target="_blank" href="https://horde.koboldai.net/register">Register</a>
|
||||
|
@@ -1794,7 +1794,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
|
||||
// Adjust token limit for Horde
|
||||
let adjustedParams;
|
||||
if (main_api == 'kobold' && horde_settings.use_horde && horde_settings.auto_adjust) {
|
||||
if (main_api == 'kobold' && horde_settings.use_horde && (horde_settings.auto_adjust_context_length || horde_settings.auto_adjust_response_length)) {
|
||||
try {
|
||||
adjustedParams = await adjustHordeGenerationParams(max_context, amount_gen);
|
||||
}
|
||||
@@ -1802,7 +1802,9 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
activateSendButtons();
|
||||
return;
|
||||
}
|
||||
this_max_context = (adjustedParams.maxContextLength - adjustedParams.maxLength);
|
||||
if (horde_settings.auto_adjust_context_length) {
|
||||
this_max_context = (adjustedParams.maxContextLength - adjustedParams.maxLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Extension added strings
|
||||
@@ -2107,7 +2109,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
}
|
||||
}
|
||||
|
||||
if (main_api == 'kobold' && horde_settings.use_horde && adjustedParams) {
|
||||
if (main_api == 'kobold' && horde_settings.use_horde && horde_settings.auto_adjust_response_length) {
|
||||
this_amount_gen = Math.min(this_amount_gen, adjustedParams.maxLength);
|
||||
this_amount_gen = Math.max(this_amount_gen, MIN_AMOUNT_GEN); // prevent validation errors
|
||||
}
|
||||
@@ -2124,7 +2126,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
||||
};
|
||||
|
||||
if (preset_settings != 'gui' || horde_settings.use_horde) {
|
||||
const maxContext = horde_settings.use_horde && adjustedParams ? adjustedParams.maxContextLength : max_context;
|
||||
const maxContext = horde_settings.use_horde && horde_settings.auto_adjust_context_length ? adjustedParams.maxContextLength : max_context;
|
||||
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, maxContext, isImpersonate);
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,8 @@ let horde_settings = {
|
||||
api_key: '0000000000',
|
||||
models: [],
|
||||
use_horde: false,
|
||||
auto_adjust: true,
|
||||
auto_adjust_response_length: true,
|
||||
auto_adjust_context_length: false,
|
||||
};
|
||||
|
||||
const MAX_RETRIES = 100;
|
||||
@@ -76,8 +77,12 @@ async function adjustHordeGenerationParams(max_context_length, max_length) {
|
||||
|
||||
//get the minimum requires parameters, lowest common value for all selected
|
||||
for (const worker of availableWorkers) {
|
||||
maxContextLength = Math.min(worker.max_context_length, maxContextLength);
|
||||
maxLength = Math.min(worker.max_length, maxLength);
|
||||
if (horde_settings.auto_adjust_context_length) {
|
||||
maxContextLength = Math.min(worker.max_context_length, maxContextLength);
|
||||
}
|
||||
if (horde_settings.auto_adjust_response_length) {
|
||||
maxLength = Math.min(worker.max_length, maxLength);
|
||||
}
|
||||
}
|
||||
|
||||
return { maxContextLength, maxLength };
|
||||
@@ -186,7 +191,8 @@ function loadHordeSettings(settings) {
|
||||
|
||||
$('#use_horde').prop("checked", horde_settings.use_horde).trigger('input');
|
||||
$('#horde_api_key').val(horde_settings.api_key);
|
||||
$('#horde_auto_adjust').prop("checked", horde_settings.auto_adjust);
|
||||
$('#horde_auto_adjust_response_length').prop("checked", horde_settings.auto_adjust_response_length);
|
||||
$('#horde_auto_adjust_context_length').prop("checked", horde_settings.auto_adjust_context_length);
|
||||
}
|
||||
|
||||
jQuery(function () {
|
||||
@@ -218,8 +224,13 @@ jQuery(function () {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#horde_auto_adjust").on("input", function () {
|
||||
horde_settings.auto_adjust = !!$(this).prop("checked");
|
||||
$("#horde_auto_adjust_response_length").on("input", function () {
|
||||
horde_settings.auto_adjust_response_length = !!$(this).prop("checked");
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#horde_auto_adjust_context_length").on("input", function () {
|
||||
horde_settings.auto_adjust_context_length = !!$(this).prop("checked");
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user