Kobold API url formatting

This commit is contained in:
SillyLossy
2023-03-25 23:38:51 +02:00
parent a9b52767a5
commit 19def2536f
2 changed files with 26 additions and 16 deletions

View File

@ -5,6 +5,7 @@ import {
export {
kai_settings,
loadKoboldSettings,
formatKoboldUrl,
};
const kai_settings = {
@ -20,6 +21,17 @@ const kai_settings = {
single_line: false,
};
function formatKoboldUrl(value) {
try {
const url = new URL(value);
url.pathname = '/api';
return url.toString();
}
catch {
return null;
}
}
function loadKoboldSettings(preset) {
for (const name of Object.keys(kai_settings)) {
const value = preset[name];