mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'feature/import' of https://github.com/BlipRanger/SillyTavern into feature/tags
This commit is contained in:
24
server.js
24
server.js
@ -752,6 +752,8 @@ function convertToV2(char) {
|
|||||||
creator_notes: char.creatorcomment,
|
creator_notes: char.creatorcomment,
|
||||||
talkativeness: char.talkativeness,
|
talkativeness: char.talkativeness,
|
||||||
fav: char.fav,
|
fav: char.fav,
|
||||||
|
creator: char.creator,
|
||||||
|
tags: char.tags,
|
||||||
});
|
});
|
||||||
|
|
||||||
result.chat = char.chat;
|
result.chat = char.chat;
|
||||||
@ -821,6 +823,7 @@ function charaFormatData(data) {
|
|||||||
// This is supposed to save all the foreign keys that ST doesn't care about
|
// This is supposed to save all the foreign keys that ST doesn't care about
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const char = tryParse(data.json_data) || {};
|
const char = tryParse(data.json_data) || {};
|
||||||
|
console.log(data.tags);
|
||||||
|
|
||||||
// This function uses _.cond() to create a series of conditional checks that return the desired output based on the input data.
|
// This function uses _.cond() to create a series of conditional checks that return the desired output based on the input data.
|
||||||
// It checks if data.alternate_greetings is an array, a string, or neither, and acts accordingly.
|
// It checks if data.alternate_greetings is an array, a string, or neither, and acts accordingly.
|
||||||
@ -860,7 +863,7 @@ function charaFormatData(data) {
|
|||||||
_.set(char, 'data.creator_notes', data.creator_notes || '');
|
_.set(char, 'data.creator_notes', data.creator_notes || '');
|
||||||
_.set(char, 'data.system_prompt', data.system_prompt || '');
|
_.set(char, 'data.system_prompt', data.system_prompt || '');
|
||||||
_.set(char, 'data.post_history_instructions', data.post_history_instructions || '');
|
_.set(char, 'data.post_history_instructions', data.post_history_instructions || '');
|
||||||
_.set(char, 'data.tags', typeof data.tags == 'string' ? (data.tags.split(',').map(x => x.trim()).filter(x => x)) : []);
|
_.set(char, 'data.tags', typeof data.tags == 'string' ? (data.tags.split(',').map(x => x.trim()).filter(x => x)) : data.tags || []);
|
||||||
_.set(char, 'data.creator', data.creator || '');
|
_.set(char, 'data.creator', data.creator || '');
|
||||||
_.set(char, 'data.character_version', data.character_version || '');
|
_.set(char, 'data.character_version', data.character_version || '');
|
||||||
_.set(char, 'data.alternate_greetings', getAlternateGreetings(data));
|
_.set(char, 'data.alternate_greetings', getAlternateGreetings(data));
|
||||||
@ -1791,7 +1794,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response
|
|||||||
let char = {
|
let char = {
|
||||||
"name": jsonData.name,
|
"name": jsonData.name,
|
||||||
"description": jsonData.description ?? '',
|
"description": jsonData.description ?? '',
|
||||||
"creatorcomment": jsonData.creatorcomment ?? '',
|
"creatorcomment": jsonData.creatorcomment ?? jsonData.creator_notes ?? '',
|
||||||
"personality": jsonData.personality ?? '',
|
"personality": jsonData.personality ?? '',
|
||||||
"first_mes": jsonData.first_mes ?? '',
|
"first_mes": jsonData.first_mes ?? '',
|
||||||
"avatar": 'none',
|
"avatar": 'none',
|
||||||
@ -1799,7 +1802,9 @@ app.post("/importcharacter", urlencodedParser, async function (request, response
|
|||||||
"mes_example": jsonData.mes_example ?? '',
|
"mes_example": jsonData.mes_example ?? '',
|
||||||
"scenario": jsonData.scenario ?? '',
|
"scenario": jsonData.scenario ?? '',
|
||||||
"create_date": humanizedISO8601DateTime(),
|
"create_date": humanizedISO8601DateTime(),
|
||||||
"talkativeness": jsonData.talkativeness ?? 0.5
|
"talkativeness": jsonData.talkativeness ?? 0.5,
|
||||||
|
"creator": jsonData.creator ?? '',
|
||||||
|
"tags": jsonData.tags ?? '',
|
||||||
};
|
};
|
||||||
char = convertToV2(char);
|
char = convertToV2(char);
|
||||||
char = JSON.stringify(char);
|
char = JSON.stringify(char);
|
||||||
@ -1812,7 +1817,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response
|
|||||||
let char = {
|
let char = {
|
||||||
"name": jsonData.char_name,
|
"name": jsonData.char_name,
|
||||||
"description": jsonData.char_persona ?? '',
|
"description": jsonData.char_persona ?? '',
|
||||||
"creatorcomment": '',
|
"creatorcomment": jsonData.creatorcomment ?? jsonData.creator_notes ?? '',
|
||||||
"personality": '',
|
"personality": '',
|
||||||
"first_mes": jsonData.char_greeting ?? '',
|
"first_mes": jsonData.char_greeting ?? '',
|
||||||
"avatar": 'none',
|
"avatar": 'none',
|
||||||
@ -1820,7 +1825,9 @@ app.post("/importcharacter", urlencodedParser, async function (request, response
|
|||||||
"mes_example": jsonData.example_dialogue ?? '',
|
"mes_example": jsonData.example_dialogue ?? '',
|
||||||
"scenario": jsonData.world_scenario ?? '',
|
"scenario": jsonData.world_scenario ?? '',
|
||||||
"create_date": humanizedISO8601DateTime(),
|
"create_date": humanizedISO8601DateTime(),
|
||||||
"talkativeness": jsonData.talkativeness ?? 0.5
|
"talkativeness": jsonData.talkativeness ?? 0.5,
|
||||||
|
"creator": jsonData.creator ?? '',
|
||||||
|
"tags": jsonData.tags ?? '',
|
||||||
};
|
};
|
||||||
char = convertToV2(char);
|
char = convertToV2(char);
|
||||||
char = JSON.stringify(char);
|
char = JSON.stringify(char);
|
||||||
@ -1859,10 +1866,11 @@ app.post("/importcharacter", urlencodedParser, async function (request, response
|
|||||||
charaWrite(uploadPath, char, png_name, response, { file_name: png_name });
|
charaWrite(uploadPath, char, png_name, response, { file_name: png_name });
|
||||||
} else if (jsonData.name !== undefined) {
|
} else if (jsonData.name !== undefined) {
|
||||||
console.log('Found a v1 character file.');
|
console.log('Found a v1 character file.');
|
||||||
|
console.log(jsonData);
|
||||||
let char = {
|
let char = {
|
||||||
"name": jsonData.name,
|
"name": jsonData.name,
|
||||||
"description": jsonData.description ?? '',
|
"description": jsonData.description ?? '',
|
||||||
"creatorcomment": jsonData.creatorcomment ?? '',
|
"creatorcomment": jsonData.creatorcomment ?? jsonData.creator_notes ?? '',
|
||||||
"personality": jsonData.personality ?? '',
|
"personality": jsonData.personality ?? '',
|
||||||
"first_mes": jsonData.first_mes ?? '',
|
"first_mes": jsonData.first_mes ?? '',
|
||||||
"avatar": 'none',
|
"avatar": 'none',
|
||||||
@ -1870,7 +1878,9 @@ app.post("/importcharacter", urlencodedParser, async function (request, response
|
|||||||
"mes_example": jsonData.mes_example ?? '',
|
"mes_example": jsonData.mes_example ?? '',
|
||||||
"scenario": jsonData.scenario ?? '',
|
"scenario": jsonData.scenario ?? '',
|
||||||
"create_date": humanizedISO8601DateTime(),
|
"create_date": humanizedISO8601DateTime(),
|
||||||
"talkativeness": jsonData.talkativeness ?? 0.5
|
"talkativeness": jsonData.talkativeness ?? 0.5,
|
||||||
|
"creator": jsonData.creator ?? '',
|
||||||
|
"tags": jsonData.tags ?? '',
|
||||||
};
|
};
|
||||||
char = convertToV2(char);
|
char = convertToV2(char);
|
||||||
char = JSON.stringify(char);
|
char = JSON.stringify(char);
|
||||||
|
Reference in New Issue
Block a user