From db08d4eab39d99a4ed52a952c2a30fd5bbbdfd04 Mon Sep 17 00:00:00 2001 From: BlipRanger <1860540+BlipRanger@users.noreply.github.com> Date: Tue, 27 Jun 2023 21:29:05 -0400 Subject: [PATCH 1/2] Import creator and creator notes/comments (if they exist) --- server.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index dcf6f8dcd..91220b20a 100644 --- a/server.js +++ b/server.js @@ -752,6 +752,7 @@ function convertToV2(char) { creator_notes: char.creatorcomment, talkativeness: char.talkativeness, fav: char.fav, + creator: char.creator, }); result.chat = char.chat; @@ -1790,7 +1791,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response let char = { "name": jsonData.name, "description": jsonData.description ?? '', - "creatorcomment": jsonData.creatorcomment ?? '', + "creatorcomment": jsonData.creatorcomment ?? jsonData.creator_notes ?? '', "personality": jsonData.personality ?? '', "first_mes": jsonData.first_mes ?? '', "avatar": 'none', @@ -1798,7 +1799,8 @@ app.post("/importcharacter", urlencodedParser, async function (request, response "mes_example": jsonData.mes_example ?? '', "scenario": jsonData.scenario ?? '', "create_date": humanizedISO8601DateTime(), - "talkativeness": jsonData.talkativeness ?? 0.5 + "talkativeness": jsonData.talkativeness ?? 0.5, + "creator": jsonData.creator ?? '', }; char = convertToV2(char); char = JSON.stringify(char); @@ -1811,7 +1813,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response let char = { "name": jsonData.char_name, "description": jsonData.char_persona ?? '', - "creatorcomment": '', + "creatorcomment": jsonData.creatorcomment ?? jsonData.creator_notes ?? '', "personality": '', "first_mes": jsonData.char_greeting ?? '', "avatar": 'none', @@ -1819,7 +1821,8 @@ app.post("/importcharacter", urlencodedParser, async function (request, response "mes_example": jsonData.example_dialogue ?? '', "scenario": jsonData.world_scenario ?? '', "create_date": humanizedISO8601DateTime(), - "talkativeness": jsonData.talkativeness ?? 0.5 + "talkativeness": jsonData.talkativeness ?? 0.5, + "creator": jsonData.creator ?? '', }; char = convertToV2(char); char = JSON.stringify(char); @@ -1858,10 +1861,11 @@ app.post("/importcharacter", urlencodedParser, async function (request, response charaWrite(uploadPath, char, png_name, response, { file_name: png_name }); } else if (jsonData.name !== undefined) { console.log('Found a v1 character file.'); + console.log(jsonData); let char = { "name": jsonData.name, "description": jsonData.description ?? '', - "creatorcomment": jsonData.creatorcomment ?? '', + "creatorcomment": jsonData.creatorcomment ?? jsonData.creator_notes ?? '', "personality": jsonData.personality ?? '', "first_mes": jsonData.first_mes ?? '', "avatar": 'none', @@ -1869,7 +1873,8 @@ app.post("/importcharacter", urlencodedParser, async function (request, response "mes_example": jsonData.mes_example ?? '', "scenario": jsonData.scenario ?? '', "create_date": humanizedISO8601DateTime(), - "talkativeness": jsonData.talkativeness ?? 0.5 + "talkativeness": jsonData.talkativeness ?? 0.5, + "creator": jsonData.creator ?? '', }; char = convertToV2(char); char = JSON.stringify(char); From 696f9083f3bc878ef251ddea0f50ff09bd831580 Mon Sep 17 00:00:00 2001 From: BlipRanger <1860540+BlipRanger@users.noreply.github.com> Date: Tue, 27 Jun 2023 21:51:28 -0400 Subject: [PATCH 2/2] Import tags and just save them to the card --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 91220b20a..4cdb98a30 100644 --- a/server.js +++ b/server.js @@ -753,6 +753,7 @@ function convertToV2(char) { talkativeness: char.talkativeness, fav: char.fav, creator: char.creator, + tags: char.tags, }); result.chat = char.chat; @@ -821,6 +822,7 @@ function charaFormatData(data) { // This is supposed to save all the foreign keys that ST doesn't care about const _ = require('lodash'); 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. // It checks if data.alternate_greetings is an array, a string, or neither, and acts accordingly. @@ -860,7 +862,7 @@ function charaFormatData(data) { _.set(char, 'data.creator_notes', data.creator_notes || ''); _.set(char, 'data.system_prompt', data.system_prompt || ''); _.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.character_version', data.character_version || ''); _.set(char, 'data.alternate_greetings', getAlternateGreetings(data)); @@ -1801,6 +1803,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response "create_date": humanizedISO8601DateTime(), "talkativeness": jsonData.talkativeness ?? 0.5, "creator": jsonData.creator ?? '', + "tags": jsonData.tags ?? '', }; char = convertToV2(char); char = JSON.stringify(char); @@ -1823,6 +1826,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response "create_date": humanizedISO8601DateTime(), "talkativeness": jsonData.talkativeness ?? 0.5, "creator": jsonData.creator ?? '', + "tags": jsonData.tags ?? '', }; char = convertToV2(char); char = JSON.stringify(char); @@ -1875,6 +1879,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response "create_date": humanizedISO8601DateTime(), "talkativeness": jsonData.talkativeness ?? 0.5, "creator": jsonData.creator ?? '', + "tags": jsonData.tags ?? '', }; char = convertToV2(char); char = JSON.stringify(char);