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:
34
server.js
34
server.js
@ -1708,6 +1708,40 @@ app.post("/importchat", urlencodedParser, function (request, response) {
|
||||
response.send('Errors occurred while writing character files. Errors: ' + JSON.stringify(errors));
|
||||
}
|
||||
|
||||
response.send({ res: true });
|
||||
} else if (Array.isArray(jsonData.data_visible)) {
|
||||
// oobabooga's format
|
||||
const chat = [{
|
||||
user_name: 'You',
|
||||
character_name: ch_name,
|
||||
create_date: humanizedISO8601DateTime(),
|
||||
}];
|
||||
|
||||
for (const arr of jsonData.data_visible) {
|
||||
if (arr[0]) {
|
||||
const userMessage = {
|
||||
name: 'You',
|
||||
is_user: true,
|
||||
is_name: true,
|
||||
send_date: humanizedISO8601DateTime(),
|
||||
mes: arr[0],
|
||||
};
|
||||
chat.push(userMessage);
|
||||
}
|
||||
if (arr[1]) {
|
||||
const charMessage = {
|
||||
name: ch_name,
|
||||
is_user: false,
|
||||
is_name: true,
|
||||
send_date: humanizedISO8601DateTime(),
|
||||
mes: arr[1],
|
||||
};
|
||||
chat.push(charMessage);
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(`${chatsPath + avatar_url}/${ch_name} - ${humanizedISO8601DateTime()} imported.jsonl`, chat.map(JSON.stringify).join('\n'), 'utf8');
|
||||
|
||||
response.send({ res: true });
|
||||
} else {
|
||||
response.send({ error: true });
|
||||
|
Reference in New Issue
Block a user