diff --git a/public/index.html b/public/index.html
index 7a718c487..f76de0483 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1829,8 +1829,9 @@
}
}
- // activation by talkativeness
- for (let member of members) {
+ // activation by talkativeness (in shuffled order)
+ const shuffledMembers = shuffle([...members]);
+ for (let member of shuffledMembers) {
const character = characters.find(x => x.name === member);
if (!character) {
@@ -1840,7 +1841,7 @@
const rollValue = Math.random();
let talkativeness = Number(character.talkativeness);
talkativeness = Number.isNaN(talkativeness) ? talkativeness_default : talkativeness;
- if (talkativeness > rollValue) {
+ if (talkativeness >= rollValue) {
activatedNames.push(member);
}
}
@@ -1852,12 +1853,8 @@
}
// de-duplicate array of names
- function onlyUnique(value, index, array) {
- return array.indexOf(value) === index;
- }
activatedNames = activatedNames.filter(onlyUnique);
- console.log(activatedNames);
// map to character ids
const memberIds = activatedNames.map(x => characters.findIndex(y => y.name === x)).filter(x => x !== -1);
return memberIds;
@@ -4286,6 +4283,22 @@
$('#world_create_button').click(() => {
createNewWorldInfo();
});
+
+ /// UTILS
+ function onlyUnique(value, index, array) {
+ return array.indexOf(value) === index;
+ }
+
+ function shuffle(array) {
+ let currentIndex = array.length, randomIndex;
+
+ while (currentIndex != 0) {
+ randomIndex = Math.floor(Math.random() * currentIndex);
+ currentIndex--;
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
+ }
+ return array;
+ }
});
Tavern.AI
diff --git a/server.js b/server.js
index a0d727847..d13fe5fd9 100644
--- a/server.js
+++ b/server.js
@@ -1077,12 +1077,12 @@ app.post("/importcharacter", urlencodedParser, async function(request, response)
try {
if(jsonData.name !== undefined){
png_name = getPngName(jsonData.name);
- let char = {"name": jsonData.name, "description": jsonData.description ?? '', "personality": jsonData.personality ?? '', "first_mes": jsonData.first_mes ?? '', "avatar": 'none', "chat": Date.now(), "mes_example": jsonData.mes_example ?? '', "scenario": jsonData.scenario ?? '', "create_date": Date.now()};
+ let char = {"name": jsonData.name, "description": jsonData.description ?? '', "personality": jsonData.personality ?? '', "first_mes": jsonData.first_mes ?? '', "avatar": 'none', "chat": Date.now(), "mes_example": jsonData.mes_example ?? '', "scenario": jsonData.scenario ?? '', "create_date": Date.now(), "talkativeness": jsonData.talkativeness ?? 0.5};
char = JSON.stringify(char);
await charaWrite('./public/img/fluffy.png', char, png_name, response, {file_name: png_name});
}else if(jsonData.char_name !== undefined){//json Pygmalion notepad
png_name = getPngName(jsonData.char_name);
- let char = {"name": jsonData.char_name, "description": jsonData.char_persona ?? '', "personality": '', "first_mes": jsonData.char_greeting ?? '', "avatar": 'none', "chat": Date.now(), "mes_example": jsonData.example_dialogue ?? '', "scenario": jsonData.world_scenario ?? '', "create_date": Date.now()};
+ let char = {"name": jsonData.char_name, "description": jsonData.char_persona ?? '', "personality": '', "first_mes": jsonData.char_greeting ?? '', "avatar": 'none', "chat": Date.now(), "mes_example": jsonData.example_dialogue ?? '', "scenario": jsonData.world_scenario ?? '', "create_date": Date.now(), "talkativeness": jsonData.talkativeness ?? 0.5};
char = JSON.stringify(char);
await charaWrite('./public/img/fluffy.png', char, png_name, response, {file_name: png_name});
}else{
@@ -1101,7 +1101,7 @@ app.post("/importcharacter", urlencodedParser, async function(request, response)
png_name = getPngName(jsonData.name);
if(jsonData.name !== undefined){
- let char = {"name": jsonData.name, "description": jsonData.description ?? '', "personality": jsonData.personality ?? '', "first_mes": jsonData.first_mes ?? '', "avatar": 'none', "chat": Date.now(), "mes_example": jsonData.mes_example ?? '', "scenario": jsonData.scenario ?? '', "create_date": Date.now()};
+ let char = {"name": jsonData.name, "description": jsonData.description ?? '', "personality": jsonData.personality ?? '', "first_mes": jsonData.first_mes ?? '', "avatar": 'none', "chat": Date.now(), "mes_example": jsonData.mes_example ?? '', "scenario": jsonData.scenario ?? '', "create_date": Date.now(), "talkativeness": jsonData.talkativeness ?? 0.5};
char = JSON.stringify(char);
await charaWrite('./uploads/'+filedata.filename, char, png_name, response, {file_name: png_name});
/*