mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/Cohee1207/SillyTavern into dev
This commit is contained in:
@ -1924,16 +1924,8 @@
|
||||
<div id="world_popup_export" class="menu_button">Export</div>
|
||||
<div id="world_popup_delete" class="menu_button">Delete World</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="softprompt_block">
|
||||
<h4>Soft Prompt</h4>
|
||||
<h5>About soft prompts <a href="https://docs.sillytavern.app/usage/api-connections/koboldai/#soft-prompts" class="notes-link" target="_blank"><span class="note-link-span">?</span></a></h5>
|
||||
<select id="softprompt">
|
||||
<option value="">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -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(
|
||||
`<option value="${prompt.name}">${prompt.name}</option>`
|
||||
);
|
||||
|
||||
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 = [
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
39
server.js
39
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;
|
||||
|
Reference in New Issue
Block a user