diff --git a/public/index.html b/public/index.html index 5bb94d4cc..be7229e98 100644 --- a/public/index.html +++ b/public/index.html @@ -1924,16 +1924,8 @@ - -
-

Soft Prompt

-
About soft prompts ?
- -
diff --git a/public/script.js b/public/script.js index b103ce139..da702bbea 100644 --- a/public/script.js +++ b/public/script.js @@ -777,63 +777,6 @@ function resultCheckStatus() { $("#api_button_textgenerationwebui").css("display", "inline-block"); } -async function getSoftPromptsList() { - if (!api_server) { - return; - } - - const response = await fetch("/getsoftprompts", { - method: "POST", - headers: getRequestHeaders(), - body: JSON.stringify({ api_server: api_server }), - }); - - if (response.ok) { - const data = await response.json(); - updateSoftPromptsList(data.soft_prompts); - } -} - -function clearSoftPromptsList() { - $('#softprompt option[value!=""]').each(function () { - $(this).remove(); - }); -} - -function updateSoftPromptsList(soft_prompts) { - // Delete SPs removed from Kobold - $("#softprompt option").each(function () { - const value = $(this).attr("value"); - - if (value == "") { - return; - } - - const prompt = soft_prompts.find((x) => x.name === value); - if (!prompt) { - $(this).remove(); - } - }); - - // Add SPs added to Kobold - soft_prompts.forEach((prompt) => { - if ($(`#softprompt option[value="${prompt.name}"]`).length === 0) { - $("#softprompt").append( - `` - ); - - if (prompt.selected) { - $("#softprompt").val(prompt.name); - } - } - }); - - // No SP selected or no SPs - if (soft_prompts.length === 0 || !soft_prompts.some((x) => x.selected)) { - $("#softprompt").val(""); - } -} - async function printCharacters() { $("#rm_print_characters_block").empty(); characters.forEach(function (item, i, arr) { @@ -3770,7 +3713,6 @@ function changeMainAPI() { apiRanges: $("#range_block"), maxContextElem: $("#max_context_block"), amountGenElem: $("#amount_gen_block"), - softPromptElem: $("#softprompt_block") }, "kobold": { apiSettings: $("#kobold_api-settings"), @@ -3779,7 +3721,6 @@ function changeMainAPI() { apiRanges: $("#range_block"), maxContextElem: $("#max_context_block"), amountGenElem: $("#amount_gen_block"), - softPromptElem: $("#softprompt_block") }, "textgenerationwebui": { apiSettings: $("#textgenerationwebui_api-settings"), @@ -3788,7 +3729,6 @@ function changeMainAPI() { apiRanges: $("#range_block_textgenerationwebui"), maxContextElem: $("#max_context_block"), amountGenElem: $("#amount_gen_block"), - softPromptElem: $("#softprompt_block") }, "novel": { apiSettings: $("#novel_api-settings"), @@ -3797,7 +3737,6 @@ function changeMainAPI() { apiRanges: $("#range_block_novel"), maxContextElem: $("#max_context_block"), amountGenElem: $("#amount_gen_block"), - softPromptElem: $("#softprompt_block") }, "openai": { apiSettings: $("#openai_settings"), @@ -3806,7 +3745,6 @@ function changeMainAPI() { apiRanges: $("#range_block_openai"), maxContextElem: $("#max_context_block"), amountGenElem: $("#amount_gen_block"), - softPromptElem: $("#softprompt_block"), }, "poe": { apiSettings: $("#poe_settings"), @@ -3815,7 +3753,6 @@ function changeMainAPI() { apiRanges: $("#range_block_poe"), maxContextElem: $("#max_context_block"), amountGenElem: $("#amount_gen_block"), - softPromptElem: $("#softprompt_block"), } }; //console.log('--- apiElements--- '); @@ -3847,11 +3784,6 @@ function changeMainAPI() { activeItem.apiPresets.css("display", "flex"); } - if (selectedVal === "kobold" || selectedVal === 'koboldhorde') { - //console.log("enabling SP for kobold"); - $("#softprompt_block").css("display", "block"); - } - if (selectedVal === "textgenerationwebui" || selectedVal === "novel") { console.log("enabling amount_gen for ooba/novel"); activeItem.amountGenElem.find('input').prop("disabled", false); @@ -6478,8 +6410,6 @@ $(document).ready(function () { is_get_status = true; is_api_button_press = true; getStatus(); - clearSoftPromptsList(); - getSoftPromptsList(); } }); @@ -6710,29 +6640,11 @@ $(document).ready(function () { setOpenAIOnlineStatus(false); setPoeOnlineStatus(false); online_status = "no_connection"; - clearSoftPromptsList(); checkOnlineStatus(); changeMainAPI(); saveSettingsDebounced(); }); - $("#softprompt").change(async function () { - if (!api_server) { - return; - } - - const selected = $("#softprompt").find(":selected").val(); - const response = await fetch("/setsoftprompt", { - method: "POST", - headers: getRequestHeaders(), - body: JSON.stringify({ name: selected, api_server: api_server }), - }); - - if (!response.ok) { - console.error("Couldn't change soft prompt"); - } - }); - ////////////////// OPTIMIZED RANGE SLIDER LISTENERS//////////////// const sliders = [ diff --git a/public/style.css b/public/style.css index 65fa0daca..3c6fceefd 100644 --- a/public/style.css +++ b/public/style.css @@ -1864,16 +1864,6 @@ input[type=search]:focus::-webkit-search-cancel-button { column-gap: 20px; } - -#softprompt { - margin-bottom: 10px; -} - -/* hidden until we find out a way to handle it better */ -#softprompt_block { - display: none; -} - .world_info_select_block { display: flex; flex-direction: row; @@ -4654,4 +4644,4 @@ body.waifuMode #avatar_zoom_popup { overflow-y: auto; overflow-x: hidden; } -} \ No newline at end of file +} diff --git a/server.js b/server.js index 827cec2b1..ee6890b4f 100644 --- a/server.js +++ b/server.js @@ -661,45 +661,6 @@ const formatApiUrl = (url) => (url.indexOf('localhost') !== -1) ? url.replace('localhost', '127.0.0.1') : url; -app.post('/getsoftprompts', jsonParser, async function (request, response) { - if (!request.body || !request.body.api_server) { - return response.sendStatus(400); - } - - const baseUrl = formatApiUrl(request.body.api_server); - let soft_prompts = []; - - try { - const softPromptsList = (await getAsync(`${baseUrl}/v1/config/soft_prompts_list`, baseRequestArgs)).values.map(x => x.value); - const softPromptSelected = (await getAsync(`${baseUrl}/v1/config/soft_prompt`, baseRequestArgs)).value; - soft_prompts = softPromptsList.map(x => ({ name: x, selected: x === softPromptSelected })); - } catch (err) { - soft_prompts = []; - } - - return response.send({ soft_prompts }); -}); - -app.post("/setsoftprompt", jsonParser, async function (request, response) { - if (!request.body || !request.body.api_server) { - return response.sendStatus(400); - } - - const baseUrl = formatApiUrl(request.body.api_server); - const args = { - headers: { "Content-Type": "application/json" }, - data: { value: request.body.name ?? '' }, - }; - - try { - await putAsync(`${baseUrl}/v1/config/soft_prompt`, args); - } catch { - return response.sendStatus(500); - } - - return response.sendStatus(200); -}); - function getVersion() { let pkgVersion = 'UNKNOWN'; let gitRevision = null;