mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
More tidy for PR
This commit is contained in:
10
server.js
10
server.js
@@ -631,9 +631,7 @@ app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's cod
|
|||||||
|
|
||||||
const worldFiles = fs
|
const worldFiles = fs
|
||||||
.readdirSync('public/KoboldAI Worlds')
|
.readdirSync('public/KoboldAI Worlds')
|
||||||
.filter(file => {
|
.filter(file => path.extname(file).toLowerCase() === '.json')
|
||||||
return path.extname(file).toLowerCase() === '.json';
|
|
||||||
})
|
|
||||||
.sort((a, b) => a < b);
|
.sort((a, b) => a < b);
|
||||||
const koboldai_world_names = worldFiles.map(item => path.parse(item).name);
|
const koboldai_world_names = worldFiles.map(item => path.parse(item).name);
|
||||||
|
|
||||||
@@ -1099,7 +1097,7 @@ async function synchronizeKoboldWorldInfo(worldInfoName) {
|
|||||||
const baseRequestArgs = { headers: { "Content-Type": "application/json" } };
|
const baseRequestArgs = { headers: { "Content-Type": "application/json" } };
|
||||||
|
|
||||||
// Get existing world info
|
// Get existing world info
|
||||||
const koboldWorldInfo = await getAsync(api_server + "/v1/world_info", baseRequestArgs);
|
const koboldWorldInfo = await getAsync(`${api_server}/v1/world_info`, baseRequestArgs);
|
||||||
|
|
||||||
// Validate kobold world info
|
// Validate kobold world info
|
||||||
let {
|
let {
|
||||||
@@ -1145,13 +1143,13 @@ async function setKoboldEntryData(tavernEntry, koboldEntry) {
|
|||||||
const setDataRequests = [];
|
const setDataRequests = [];
|
||||||
|
|
||||||
// 1. Set primary key
|
// 1. Set primary key
|
||||||
if (tavernEntry.key.length) {
|
if (tavernEntry.key?.length) {
|
||||||
const keyArgs = { data: { value: tavernEntry.key.join(',') }, ...baseRequestArgs };
|
const keyArgs = { data: { value: tavernEntry.key.join(',') }, ...baseRequestArgs };
|
||||||
await putAsync(`${api_server}/v1/world_info/${koboldEntry.uid}/key`, keyArgs);
|
await putAsync(`${api_server}/v1/world_info/${koboldEntry.uid}/key`, keyArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Set secondary key
|
// 2. Set secondary key
|
||||||
if (tavernEntry.keysecondary) {
|
if (tavernEntry.keysecondary?.length) {
|
||||||
const keySecondaryArgs = { data: { value: tavernEntry.keysecondary.join(',') }, ...baseRequestArgs };
|
const keySecondaryArgs = { data: { value: tavernEntry.keysecondary.join(',') }, ...baseRequestArgs };
|
||||||
await putAsync(`${api_server}/v1/world_info/${koboldEntry.uid}/keysecondary`, keySecondaryArgs);
|
await putAsync(`${api_server}/v1/world_info/${koboldEntry.uid}/keysecondary`, keySecondaryArgs);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user