mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Hide SPs select for now, refactor async endpoints
This commit is contained in:
@ -3724,7 +3724,7 @@
|
|||||||
<h4>Content</h4>
|
<h4>Content</h4>
|
||||||
<h5>Text that will be inserted to the prompt upon activation.</h5>
|
<h5>Text that will be inserted to the prompt upon activation.</h5>
|
||||||
</label>
|
</label>
|
||||||
<textarea class="text_pole" name="content" rows="4" placeholder=""></textarea>
|
<textarea class="text_pole" name="content" rows="2" placeholder=""></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="world_entry_form_control world_entry_form_horizontal">
|
<div class="world_entry_form_control world_entry_form_horizontal">
|
||||||
<label class="checkbox" for="constant">
|
<label class="checkbox" for="constant">
|
||||||
|
@ -1152,6 +1152,11 @@ input[type=button] {
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* hidden until we find out a way to handle it better */
|
||||||
|
#softprompt_block {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
#world_info {
|
#world_info {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
45
server.js
45
server.js
@ -367,7 +367,6 @@ const formatApiUrl = (url) => (url.indexOf('localhost') !== -1)
|
|||||||
? url.replace('localhost', '127.0.0.1')
|
? url.replace('localhost', '127.0.0.1')
|
||||||
: url;
|
: url;
|
||||||
|
|
||||||
// TODO Rewrite using async wrapper from worldinfo branch
|
|
||||||
app.post('/getsoftprompts', jsonParser, async function (request, response) {
|
app.post('/getsoftprompts', jsonParser, async function (request, response) {
|
||||||
if (!request.body || !request.body.api_server) {
|
if (!request.body || !request.body.api_server) {
|
||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
@ -377,34 +376,8 @@ app.post('/getsoftprompts', jsonParser, async function (request, response) {
|
|||||||
let soft_prompts = [];
|
let soft_prompts = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var args = { headers: { "Content-Type": "application/json" } };
|
const softPromptsList = (await getAsync(`${baseUrl}/v1/config/soft_prompts_list`, baseRequestArgs)).values.map(x => x.value);
|
||||||
const softPromptsList = await new Promise((resolve, reject) => {
|
const softPromptSelected = (await getAsync(`${baseUrl}/v1/config/soft_prompt`, baseRequestArgs)).value;
|
||||||
client.get(`${baseUrl}/v1/config/soft_prompts_list`, args, function (data, response) {
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
const nameList = data.values.map(x => x.value);
|
|
||||||
resolve(nameList);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
reject(response.status);
|
|
||||||
}
|
|
||||||
}).on('error', function (err) {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const softPromptSelected = await new Promise((resolve, reject) => {
|
|
||||||
client.get(`${baseUrl}/v1/config/soft_prompt`, args, function (data, response) {
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
resolve(data.value);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
reject(response.status);
|
|
||||||
}
|
|
||||||
}).on('error', function (err) {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
soft_prompts = softPromptsList.map(x => ({ name: x, selected: x === softPromptSelected }));
|
soft_prompts = softPromptsList.map(x => ({ name: x, selected: x === softPromptSelected }));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
soft_prompts = [];
|
soft_prompts = [];
|
||||||
@ -413,7 +386,6 @@ app.post('/getsoftprompts', jsonParser, async function (request, response) {
|
|||||||
return response.send({ soft_prompts });
|
return response.send({ soft_prompts });
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO Rewrite using async wrapper from worldinfo branch
|
|
||||||
app.post("/setsoftprompt", jsonParser, async function(request, response) {
|
app.post("/setsoftprompt", jsonParser, async function(request, response) {
|
||||||
if (!request.body || !request.body.api_server) {
|
if (!request.body || !request.body.api_server) {
|
||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
@ -424,15 +396,10 @@ app.post("/setsoftprompt", jsonParser, async function(request, response) {
|
|||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
data: { value: request.body.name ?? '' },
|
data: { value: request.body.name ?? '' },
|
||||||
};
|
};
|
||||||
client.put(`${baseUrl}/v1/config/soft_prompt`, args, function (_, res) {
|
|
||||||
if (res.statusCode == 200) {
|
await putAsync(`${baseUrl}/v1/config/soft_prompt`, args);
|
||||||
return response.sendStatus(200);
|
|
||||||
} else {
|
return response.sendStatus(200);
|
||||||
return response.sendStatus(500);
|
|
||||||
}
|
|
||||||
}).on('error', () => {
|
|
||||||
return response.sendStatus(500);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkServer(){
|
function checkServer(){
|
||||||
|
Reference in New Issue
Block a user