Merge pull request #872 from 50h100a/kai-fmt

This commit is contained in:
Cohee
2023-08-08 00:41:12 +03:00
committed by GitHub
4 changed files with 28 additions and 8 deletions

View File

@@ -4,6 +4,10 @@ import {
getStoppingStrings,
} from "../script.js";
import {
power_user,
} from "./power-user.js";
export {
kai_settings,
loadKoboldSettings,
@@ -35,12 +39,12 @@ const MIN_STREAMING_KCPPVERSION = '1.30';
function formatKoboldUrl(value) {
try {
const url = new URL(value);
url.pathname = '/api';
if (!power_user.relaxed_api_urls) {
url.pathname = '/api';
}
return url.toString();
}
catch {
return null;
}
} catch { } // Just using URL as a validation check
return null;
}
function loadKoboldSettings(preset) {

View File

@@ -164,6 +164,7 @@ let power_user = {
prefer_character_jailbreak: true,
continue_on_send: false,
trim_spaces: true,
relaxed_api_urls: false,
instruct: {
enabled: false,
@@ -673,6 +674,7 @@ function loadPowerUserSettings(settings, data) {
power_user.chat_width = 50;
}
$('#relaxed_api_urls').prop("checked", power_user.relaxed_api_urls);
$('#trim_spaces').prop("checked", power_user.trim_spaces);
$('#continue_on_send').prop("checked", power_user.continue_on_send);
$('#auto_swipe').prop("checked", power_user.auto_swipe);
@@ -1982,6 +1984,12 @@ $(document).ready(() => {
saveSettingsDebounced();
});
$("#relaxed_api_urls").on("input", function () {
const value = !!$(this).prop('checked');
power_user.relaxed_api_urls = value;
saveSettingsDebounced();
});
$('#spoiler_free_mode').on('input', function () {
power_user.spoiler_free_mode = !!$(this).prop('checked');
switchSpoilerMode();

View File

@@ -6,6 +6,10 @@ import {
setGenerationParamsFromPreset,
} from "../script.js";
import {
power_user,
} from "./power-user.js";
export {
textgenerationwebui_settings,
loadTextGenSettings,
@@ -98,10 +102,11 @@ function selectPreset(name) {
function formatTextGenURL(value) {
try {
const url = new URL(value);
if (url.pathname.endsWith('/api')) {
return url.toString();
if (!power_user.relaxed_api_urls) {
url.pathname = '/api';
}
} catch { } // Try and Catch both fall through to the same return.
return url.toString();
} catch { } // Just using URL as a validation check
return null;
}