mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Shuffle randomly activated chars
This commit is contained in:
@ -1829,8 +1829,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// activation by talkativeness
|
// activation by talkativeness (in shuffled order)
|
||||||
for (let member of members) {
|
const shuffledMembers = shuffle([...members]);
|
||||||
|
for (let member of shuffledMembers) {
|
||||||
const character = characters.find(x => x.name === member);
|
const character = characters.find(x => x.name === member);
|
||||||
|
|
||||||
if (!character) {
|
if (!character) {
|
||||||
@ -1840,7 +1841,7 @@
|
|||||||
const rollValue = Math.random();
|
const rollValue = Math.random();
|
||||||
let talkativeness = Number(character.talkativeness);
|
let talkativeness = Number(character.talkativeness);
|
||||||
talkativeness = Number.isNaN(talkativeness) ? talkativeness_default : talkativeness;
|
talkativeness = Number.isNaN(talkativeness) ? talkativeness_default : talkativeness;
|
||||||
if (talkativeness > rollValue) {
|
if (talkativeness >= rollValue) {
|
||||||
activatedNames.push(member);
|
activatedNames.push(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1852,12 +1853,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// de-duplicate array of names
|
// de-duplicate array of names
|
||||||
function onlyUnique(value, index, array) {
|
|
||||||
return array.indexOf(value) === index;
|
|
||||||
}
|
|
||||||
activatedNames = activatedNames.filter(onlyUnique);
|
activatedNames = activatedNames.filter(onlyUnique);
|
||||||
|
|
||||||
console.log(activatedNames);
|
|
||||||
// map to character ids
|
// map to character ids
|
||||||
const memberIds = activatedNames.map(x => characters.findIndex(y => y.name === x)).filter(x => x !== -1);
|
const memberIds = activatedNames.map(x => characters.findIndex(y => y.name === x)).filter(x => x !== -1);
|
||||||
return memberIds;
|
return memberIds;
|
||||||
@ -4286,6 +4283,22 @@
|
|||||||
$('#world_create_button').click(() => {
|
$('#world_create_button').click(() => {
|
||||||
createNewWorldInfo();
|
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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<title>Tavern.AI</title>
|
<title>Tavern.AI</title>
|
||||||
|
@ -1077,12 +1077,12 @@ app.post("/importcharacter", urlencodedParser, async function(request, response)
|
|||||||
try {
|
try {
|
||||||
if(jsonData.name !== undefined){
|
if(jsonData.name !== undefined){
|
||||||
png_name = getPngName(jsonData.name);
|
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);
|
char = JSON.stringify(char);
|
||||||
await charaWrite('./public/img/fluffy.png', char, png_name, response, {file_name: png_name});
|
await charaWrite('./public/img/fluffy.png', char, png_name, response, {file_name: png_name});
|
||||||
}else if(jsonData.char_name !== undefined){//json Pygmalion notepad
|
}else if(jsonData.char_name !== undefined){//json Pygmalion notepad
|
||||||
png_name = getPngName(jsonData.char_name);
|
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);
|
char = JSON.stringify(char);
|
||||||
await charaWrite('./public/img/fluffy.png', char, png_name, response, {file_name: png_name});
|
await charaWrite('./public/img/fluffy.png', char, png_name, response, {file_name: png_name});
|
||||||
}else{
|
}else{
|
||||||
@ -1101,7 +1101,7 @@ app.post("/importcharacter", urlencodedParser, async function(request, response)
|
|||||||
png_name = getPngName(jsonData.name);
|
png_name = getPngName(jsonData.name);
|
||||||
|
|
||||||
if(jsonData.name !== undefined){
|
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);
|
char = JSON.stringify(char);
|
||||||
await charaWrite('./uploads/'+filedata.filename, char, png_name, response, {file_name: png_name});
|
await charaWrite('./uploads/'+filedata.filename, char, png_name, response, {file_name: png_name});
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user