single-URL ui for mancer.

automatically produce streaming URL from blocking URL.
This commit is contained in:
50h100a 2023-08-20 00:33:00 -04:00
parent 83eb3449f3
commit 8dca75f6c3
2 changed files with 28 additions and 17 deletions

View File

@ -1785,22 +1785,27 @@
<input id="use-mancer-api-checkbox" type="checkbox" /> <input id="use-mancer-api-checkbox" type="checkbox" />
</label> </label>
</div> </div>
<div id="mancer-api-ui" style="display:none;"> <div>
<div id="mancer_api_subpanel" class="flex-container flexFlowColumn" style="display:none;">
<h4 data-i18n="Mancer API key">Mancer API key</h4> <h4 data-i18n="Mancer API key">Mancer API key</h4>
<div class="flex-container"> <div class="flex-container">
<input id="api_key_mancer" name="api_key_mancer" class="text_pole flex1 wide100p" maxlength="500" size="35" type="text" autocomplete="off"> <input id="api_key_mancer" name="api_key_mancer" class="text_pole flex1 wide100p" maxlength="500" size="35" type="text" autocomplete="off">
<div title="Clear your API key" data-i18n="[title]Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_mancer"> <div title="Clear your API key" data-i18n="[title]Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_mancer">
</div> </div>
</div> </div>
</div>
<div>
<div class="flex-container flexFlowColumn">
<div data-for="api_key_mancer" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you reload the page."> <div data-for="api_key_mancer" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you reload the page.">
For privacy reasons, your API key will be hidden after you reload the page. For privacy reasons, your API key will be hidden after you reload the page.
</div> </div>
<div class="flex1">
<h4 data-i18n="Mancer API url">Mancer API url</h4>
<small>Example: https://neuro.mancer.tech/webui/MODEL/api</small>
<input id="mancer_api_url_text" name="mancer_api_url" class="text_pole wide100p" maxlength="500" value="" autocomplete="off">
</div>
</div>
<div id="tgwebui_api_subpanel" class="flex-container flexFlowColumn">
<div class="flex1"> <div class="flex1">
<h4 data-i18n="Blocking API url">Blocking API url</h4> <h4 data-i18n="Blocking API url">Blocking API url</h4>
<small>Example: http://127.0.0.1:5000/</small> <small>Example: http://127.0.0.1:5000/api</small>
<input id="textgenerationwebui_api_url_text" name="textgenerationwebui_api_url" class="text_pole wide100p" maxlength="500" value="" autocomplete="off"> <input id="textgenerationwebui_api_url_text" name="textgenerationwebui_api_url" class="text_pole wide100p" maxlength="500" value="" autocomplete="off">
</div> </div>
<div class="flex1"> <div class="flex1">

View File

@ -5402,9 +5402,8 @@ async function getSettings(type) {
setWorldInfoSettings(settings.world_info_settings ?? settings, data); setWorldInfoSettings(settings.world_info_settings ?? settings, data);
api_server_textgenerationwebui = settings.api_server_textgenerationwebui; api_server_textgenerationwebui = settings.api_server_textgenerationwebui;
$("#textgenerationwebui_api_url_text").val( $("#textgenerationwebui_api_url_text").val(api_server_textgenerationwebui);
api_server_textgenerationwebui $("#mancer_api_url_text").val(api_server_textgenerationwebui);
);
api_use_mancer_webui = settings.api_use_mancer_webui api_use_mancer_webui = settings.api_use_mancer_webui
$('#use-mancer-api-checkbox').prop("checked", api_use_mancer_webui); $('#use-mancer-api-checkbox').prop("checked", api_use_mancer_webui);
$('#use-mancer-api-checkbox').trigger("change"); $('#use-mancer-api-checkbox').trigger("change");
@ -8002,7 +8001,9 @@ $(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").toggle(enabled); $("#mancer_api_subpanel").toggle(enabled);
$("#tgwebui_api_subpanel").toggle(!enabled);
api_use_mancer_webui = enabled; api_use_mancer_webui = enabled;
saveSettingsDebounced(); saveSettingsDebounced();
getStatus(); getStatus();
@ -8010,8 +8011,9 @@ $(document).ready(function () {
$("#api_button_textgenerationwebui").click(async function (e) { $("#api_button_textgenerationwebui").click(async function (e) {
e.stopPropagation(); e.stopPropagation();
if ($("#textgenerationwebui_api_url_text").val() != "") { const url_source = api_use_mancer_webui ? "#mancer_api_url_text" : "#textgenerationwebui_api_url_text";
let value = formatTextGenURL($("#textgenerationwebui_api_url_text").val().trim(), api_use_mancer_webui); if ($(url_source).val() != "") {
let value = formatTextGenURL($(url_source).val().trim(), api_use_mancer_webui);
if (!value) { if (!value) {
callPopup("Please enter a valid URL.<br/>WebUI URLs should end with <tt>/api</tt><br/>Enable 'Relaxed API URLs' to allow other paths.", 'text'); callPopup("Please enter a valid URL.<br/>WebUI URLs should end with <tt>/api</tt><br/>Enable 'Relaxed API URLs' to allow other paths.", 'text');
return; return;
@ -8022,9 +8024,13 @@ $(document).ready(function () {
await writeSecret(SECRET_KEYS.MANCER, mancer_key); await writeSecret(SECRET_KEYS.MANCER, mancer_key);
} }
$("#textgenerationwebui_api_url_text").val(value); $(url_source).val(value);
$("#api_loading_textgenerationwebui").css("display", "inline-block"); $("#api_loading_textgenerationwebui").css("display", "inline-block");
$("#api_button_textgenerationwebui").css("display", "none"); $("#api_button_textgenerationwebui").css("display", "none");
if (api_use_mancer_webui) {
textgenerationwebui_settings.streaming_url = value.replace("http", "ws") + "/v1/stream";
}
api_server_textgenerationwebui = value; api_server_textgenerationwebui = value;
main_api = "textgenerationwebui"; main_api = "textgenerationwebui";
saveSettingsDebounced(); saveSettingsDebounced();