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>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<label for="horde_auto_adjust" class="checkbox_label">
|
<label for="horde_auto_adjust_context_length" class="checkbox_label">
|
||||||
<input id="horde_auto_adjust" type="checkbox" />
|
<input id="horde_auto_adjust_context_length" type="checkbox" />
|
||||||
Adjust generation to worker capabilities
|
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>
|
</label>
|
||||||
<h4>API key</h4>
|
<h4>API key</h4>
|
||||||
<h5>Get it here: <a target="_blank" href="https://horde.koboldai.net/register">Register</a>
|
<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
|
// Adjust token limit for Horde
|
||||||
let adjustedParams;
|
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 {
|
try {
|
||||||
adjustedParams = await adjustHordeGenerationParams(max_context, amount_gen);
|
adjustedParams = await adjustHordeGenerationParams(max_context, amount_gen);
|
||||||
}
|
}
|
||||||
@@ -1802,8 +1802,10 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
activateSendButtons();
|
activateSendButtons();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (horde_settings.auto_adjust_context_length) {
|
||||||
this_max_context = (adjustedParams.maxContextLength - adjustedParams.maxLength);
|
this_max_context = (adjustedParams.maxContextLength - adjustedParams.maxLength);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Extension added strings
|
// Extension added strings
|
||||||
const allAnchors = getAllExtensionPrompts();
|
const allAnchors = getAllExtensionPrompts();
|
||||||
@@ -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.min(this_amount_gen, adjustedParams.maxLength);
|
||||||
this_amount_gen = Math.max(this_amount_gen, MIN_AMOUNT_GEN); // prevent validation errors
|
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) {
|
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);
|
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, maxContext, isImpersonate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,8 @@ let horde_settings = {
|
|||||||
api_key: '0000000000',
|
api_key: '0000000000',
|
||||||
models: [],
|
models: [],
|
||||||
use_horde: false,
|
use_horde: false,
|
||||||
auto_adjust: true,
|
auto_adjust_response_length: true,
|
||||||
|
auto_adjust_context_length: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MAX_RETRIES = 100;
|
const MAX_RETRIES = 100;
|
||||||
@@ -76,9 +77,13 @@ async function adjustHordeGenerationParams(max_context_length, max_length) {
|
|||||||
|
|
||||||
//get the minimum requires parameters, lowest common value for all selected
|
//get the minimum requires parameters, lowest common value for all selected
|
||||||
for (const worker of availableWorkers) {
|
for (const worker of availableWorkers) {
|
||||||
|
if (horde_settings.auto_adjust_context_length) {
|
||||||
maxContextLength = Math.min(worker.max_context_length, maxContextLength);
|
maxContextLength = Math.min(worker.max_context_length, maxContextLength);
|
||||||
|
}
|
||||||
|
if (horde_settings.auto_adjust_response_length) {
|
||||||
maxLength = Math.min(worker.max_length, maxLength);
|
maxLength = Math.min(worker.max_length, maxLength);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { maxContextLength, maxLength };
|
return { maxContextLength, maxLength };
|
||||||
}
|
}
|
||||||
@@ -186,7 +191,8 @@ function loadHordeSettings(settings) {
|
|||||||
|
|
||||||
$('#use_horde').prop("checked", horde_settings.use_horde).trigger('input');
|
$('#use_horde').prop("checked", horde_settings.use_horde).trigger('input');
|
||||||
$('#horde_api_key').val(horde_settings.api_key);
|
$('#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 () {
|
jQuery(function () {
|
||||||
@@ -218,8 +224,13 @@ jQuery(function () {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#horde_auto_adjust").on("input", function () {
|
$("#horde_auto_adjust_response_length").on("input", function () {
|
||||||
horde_settings.auto_adjust = !!$(this).prop("checked");
|
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();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user