More tidy for PR

This commit is contained in:
SillyLossy
2023-02-10 11:14:30 +02:00
parent c760ba54f2
commit 26790f9b3c

View File

@@ -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);
} }