From 8dca75f6c3d7ba0b60d2fb63a42cfe42914e48b8 Mon Sep 17 00:00:00 2001 From: 50h100a Date: Sun, 20 Aug 2023 00:33:00 -0400 Subject: [PATCH] single-URL ui for mancer. automatically produce streaming URL from blocking URL. --- public/index.html | 25 +++++++++++++++---------- public/script.js | 20 +++++++++++++------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/public/index.html b/public/index.html index 299793e2b..098a4b6eb 100644 --- a/public/index.html +++ b/public/index.html @@ -1785,22 +1785,27 @@ -
-
+ +

Blocking API url

- Example: http://127.0.0.1:5000/ + Example: http://127.0.0.1:5000/api
diff --git a/public/script.js b/public/script.js index 443c09696..a65cc5f6a 100644 --- a/public/script.js +++ b/public/script.js @@ -5402,9 +5402,8 @@ async function getSettings(type) { setWorldInfoSettings(settings.world_info_settings ?? settings, data); api_server_textgenerationwebui = settings.api_server_textgenerationwebui; - $("#textgenerationwebui_api_url_text").val( - api_server_textgenerationwebui - ); + $("#textgenerationwebui_api_url_text").val(api_server_textgenerationwebui); + $("#mancer_api_url_text").val(api_server_textgenerationwebui); api_use_mancer_webui = settings.api_use_mancer_webui $('#use-mancer-api-checkbox').prop("checked", api_use_mancer_webui); $('#use-mancer-api-checkbox').trigger("change"); @@ -8002,7 +8001,9 @@ $(document).ready(function () { $("#use-mancer-api-checkbox").on("change", function (e) { 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; saveSettingsDebounced(); getStatus(); @@ -8010,8 +8011,9 @@ $(document).ready(function () { $("#api_button_textgenerationwebui").click(async function (e) { e.stopPropagation(); - if ($("#textgenerationwebui_api_url_text").val() != "") { - let value = formatTextGenURL($("#textgenerationwebui_api_url_text").val().trim(), api_use_mancer_webui); + const url_source = api_use_mancer_webui ? "#mancer_api_url_text" : "#textgenerationwebui_api_url_text"; + if ($(url_source).val() != "") { + let value = formatTextGenURL($(url_source).val().trim(), api_use_mancer_webui); if (!value) { callPopup("Please enter a valid URL.
WebUI URLs should end with /api
Enable 'Relaxed API URLs' to allow other paths.", 'text'); return; @@ -8022,9 +8024,13 @@ $(document).ready(function () { 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_button_textgenerationwebui").css("display", "none"); + + if (api_use_mancer_webui) { + textgenerationwebui_settings.streaming_url = value.replace("http", "ws") + "/v1/stream"; + } api_server_textgenerationwebui = value; main_api = "textgenerationwebui"; saveSettingsDebounced();