code review adjustments part 1

This commit is contained in:
50h100a
2023-08-03 06:07:54 -04:00
parent 61c0e3b08b
commit 2fc6813e66
4 changed files with 23 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ export {
textgenerationwebui_settings,
loadTextGenSettings,
generateTextGenWithStreaming,
formatTextGenURL,
}
const textgenerationwebui_settings = {
@@ -94,6 +95,16 @@ function selectPreset(name) {
saveSettingsDebounced();
}
function formatTextGenURL(value) {
try {
const url = new URL(value);
if (url.pathname.endsWith('/api')) {
return url.toString();
}
} catch { } // Try and Catch both fall through to the same return.
return null;
}
function convertPresets(presets) {
return Array.isArray(presets) ? presets.map(JSON.parse) : [];
}