mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
code review adjustments part 1
This commit is contained in:
@@ -1541,7 +1541,7 @@
|
|||||||
<div id="textgenerationwebui_api" style="display: none;position: relative;">
|
<div id="textgenerationwebui_api" style="display: none;position: relative;">
|
||||||
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||||
If you are using:
|
If you are using:
|
||||||
<div class="flex-container" style="margin-left:20px;">
|
<div class="flex-container indent20p">
|
||||||
<a href="https://github.com/oobabooga/text-generation-webui" target="_blank">
|
<a href="https://github.com/oobabooga/text-generation-webui" target="_blank">
|
||||||
oobabooga/text-generation-webui
|
oobabooga/text-generation-webui
|
||||||
</a>,
|
</a>,
|
||||||
@@ -1549,7 +1549,7 @@
|
|||||||
Make sure you run it with <tt>--api</tt> flag
|
Make sure you run it with <tt>--api</tt> flag
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container" style="margin-left:20px;">
|
<div class="flex-container indent20p">
|
||||||
<a href="https://mancer.tech/" target="_blank">
|
<a href="https://mancer.tech/" target="_blank">
|
||||||
Mancer AI
|
Mancer AI
|
||||||
</a>,
|
</a>,
|
||||||
|
@@ -17,6 +17,7 @@ import {
|
|||||||
loadTextGenSettings,
|
loadTextGenSettings,
|
||||||
generateTextGenWithStreaming,
|
generateTextGenWithStreaming,
|
||||||
getTextGenGenerationData,
|
getTextGenGenerationData,
|
||||||
|
formatTextGenURL,
|
||||||
} from "./scripts/textgen-settings.js";
|
} from "./scripts/textgen-settings.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -7687,24 +7688,24 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
$("#use-mancer-api-checkbox").on("change", function (e) {
|
$("#use-mancer-api-checkbox").on("change", function (e) {
|
||||||
const enabled = $("#use-mancer-api-checkbox").prop("checked");
|
const enabled = $("#use-mancer-api-checkbox").prop("checked");
|
||||||
$("#mancer-api-ui").css("display", enabled?"block":"none");
|
$("#mancer-api-ui").toggle(enabled);
|
||||||
api_use_mancer_webui = enabled;
|
api_use_mancer_webui = enabled;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
getStatus();
|
getStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#api_button_textgenerationwebui").click(function (e) {
|
$("#api_button_textgenerationwebui").click(async function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if ($("#textgenerationwebui_api_url_text").val() != "") {
|
if ($("#textgenerationwebui_api_url_text").val() != "") {
|
||||||
let value = $("#textgenerationwebui_api_url_text").val().trim();
|
let value = formatTextGenURL($("#textgenerationwebui_api_url_text").val().trim())
|
||||||
if (!value || !value.endsWith('/api')) {
|
if (!value) {
|
||||||
callPopup('Please enter a valid URL.<br/>WebUI URLs should end with <tt>/api</tt>', 'text');
|
callPopup('Please enter a valid URL.<br/>WebUI URLs should end with <tt>/api</tt>', 'text');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mancer_key = $("#api_key_mancer").val().trim();
|
const mancer_key = $("#api_key_mancer").val().trim();
|
||||||
if (mancer_key.length) {
|
if (mancer_key.length) {
|
||||||
writeSecret(SECRET_KEYS.MANCER, mancer_key);
|
await writeSecret(SECRET_KEYS.MANCER, mancer_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#textgenerationwebui_api_url_text").val(value);
|
$("#textgenerationwebui_api_url_text").val(value);
|
||||||
|
@@ -10,6 +10,7 @@ export {
|
|||||||
textgenerationwebui_settings,
|
textgenerationwebui_settings,
|
||||||
loadTextGenSettings,
|
loadTextGenSettings,
|
||||||
generateTextGenWithStreaming,
|
generateTextGenWithStreaming,
|
||||||
|
formatTextGenURL,
|
||||||
}
|
}
|
||||||
|
|
||||||
const textgenerationwebui_settings = {
|
const textgenerationwebui_settings = {
|
||||||
@@ -94,6 +95,16 @@ function selectPreset(name) {
|
|||||||
saveSettingsDebounced();
|
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) {
|
function convertPresets(presets) {
|
||||||
return Array.isArray(presets) ? presets.map(JSON.parse) : [];
|
return Array.isArray(presets) ? presets.map(JSON.parse) : [];
|
||||||
}
|
}
|
||||||
|
@@ -4409,6 +4409,10 @@ toolcool-color-picker {
|
|||||||
width: 50px;
|
width: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.indent20p {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.wi-enter-footer-text {
|
.wi-enter-footer-text {
|
||||||
font-size: calc(var(--mainFontSize) * 0.8);
|
font-size: calc(var(--mainFontSize) * 0.8);
|
||||||
color: var(--SmartThemeBodyColor);
|
color: var(--SmartThemeBodyColor);
|
||||||
|
Reference in New Issue
Block a user