Fix saving of groups after edits

This commit is contained in:
SillyLossy
2023-04-06 12:43:02 +03:00
parent 7b10aa63a8
commit a1770b8c6b
4 changed files with 48 additions and 47 deletions

View File

@@ -19,7 +19,7 @@
<p> <p>
<u>Character Anchor</u> - affects the character played by the AI by motivating him to write longer messages.<br><br> <u>Character Anchor</u> - affects the character played by the AI by motivating him to write longer messages.<br><br>
Looks like: Looks like:
<code>[(Bot's name) talks a lot with descriptions]</code> <code>[Elaborate speaker]</code>
</p> </p>
<p> <p>
<u>Style Anchor</u> - affects the entire AI model, motivating the AI to write longer messages even when it is not acting as the character.<Br><br> <u>Style Anchor</u> - affects the entire AI model, motivating the AI to write longer messages even when it is not acting as the character.<Br><br>

View File

@@ -35,10 +35,9 @@
</p> </p>
<h4>2. Characters are activated by the "Talkativeness" factor.</h4> <h4>2. Characters are activated by the "Talkativeness" factor.</h4>
<p> <p>
Talkativeness defines how often the character speaks if it was not mentioned. Adjust this value on Talkativeness defines how often the character speaks if they were not mentioned. Adjust this value on
"Advanced definitions" screen in character editor. "Advanced definitions" screen in character editor. Slider values are on a linear scale from
Slider values are on a linear scale from <b>0% / Shy</b> (character never talks unless mentioned) to <b>0% / Shy</b> (character never talks unless mentioned) to <b>100% / Chatty</b> (character always replies).
<b>100% / Chatty</b> (character always replies).
Default value for new characters is 50% chance. Default value for new characters is 50% chance.
</p> </p>
<h4>3. Random character is selected.</h4> <h4>3. Random character is selected.</h4>

View File

@@ -215,7 +215,6 @@ const system_messages = {
'<li><tt>{{text}}</tt> set the behavioral bias for the AI character</li>', '<li><tt>{{text}}</tt> set the behavioral bias for the AI character</li>',
'<li><tt>{{}}</tt> cancel a previously set bias</li>', '<li><tt>{{}}</tt> cancel a previously set bias</li>',
'</ol>', '</ol>',
'Need more help? Visit our wiki <a href=\"https://github.com/TavernAI/TavernAI/wiki\">TavernAI Wiki</a>!'
].join('') ].join('')
}, },
welcome: welcome:
@@ -231,8 +230,7 @@ const system_messages = {
'<li>Create or pick a character from the list</li>', '<li>Create or pick a character from the list</li>',
'</ul>', '</ul>',
'Still have questions left?\n', 'Still have questions left?\n',
'Check out built-in help by typing <tt>/?</tt> in any chat or visit our ', 'Check out built-in help or type <tt>/?</tt> in any chat.'
'<a target="_blank" href="https://github.com/TavernAI/TavernAI/wiki">TavernAI Wiki</a>!'
].join('') ].join('')
}, },
group: { group: {

View File

@@ -529,37 +529,12 @@ async function groupChatAutoModeWorker() {
await generateGroupWrapper(true); await generateGroupWrapper(true);
} }
function select_group_chats(chat_id) { async function memberClickHandler(event) {
const group = chat_id && groups.find((x) => x.id == chat_id);
const groupName = group?.name ?? "";
$("#rm_group_chat_name").val(groupName);
$("#rm_group_chat_name").off();
$("#rm_group_chat_name").on("input", async function () {
if (chat_id) {
group.name = $(this).val();
$("#rm_button_selected_ch").children("h2").text(group.name);
await editGroup(chat_id);
}
});
$("#rm_group_filter").val("").trigger("input");
$('input[name="rm_group_activation_strategy"]').off();
$('input[name="rm_group_activation_strategy"]').on("input", async function(e) {
if (chat_id) {
group.activation_strategy = Number(e.target.value);
await editGroup(chat_id);
}
});
$(`input[name="rm_group_activation_strategy"][value="${Number(group?.activation_strategy ?? group_activation_strategy.NATURAL)}"]`).prop('checked', true);
selectRightMenuWithAnimation('rm_group_chats_block');
async function memberClickHandler(event) {
event.stopPropagation(); event.stopPropagation();
const id = $(this).data("id"); const id = $(this).data("id");
const isDelete = !!$(this).closest("#rm_group_members").length; const isDelete = !!$(this).closest("#rm_group_members").length;
const template = $(this).clone(); const template = $(this).clone();
let _thisGroup = groups.find((x) => x.id == selected_group);
template.data("id", id); template.data("id", id);
template.click(memberClickHandler); template.click(memberClickHandler);
@@ -573,23 +548,52 @@ function select_group_chats(chat_id) {
$("#rm_group_members").prepend(template); $("#rm_group_members").prepend(template);
} }
if (group) { if (_thisGroup) {
if (isDelete) { if (isDelete) {
const index = group.members.findIndex((x) => x === id); const index = _thisGroup.members.findIndex((x) => x === id);
if (index !== -1) { if (index !== -1) {
group.members.splice(index, 1); _thisGroup.members.splice(index, 1);
} }
} else { } else {
group.members.push(id); _thisGroup.members.push(id);
template.css({ 'order': _thisGroup.members.length });
} }
await editGroup(chat_id); await editGroup(selected_group);
updateGroupAvatar(group); updateGroupAvatar(_thisGroup);
} }
$(this).remove(); $(this).remove();
const groupHasMembers = !!$("#rm_group_members").children().length; const groupHasMembers = !!$("#rm_group_members").children().length;
$("#rm_group_submit").prop("disabled", !groupHasMembers); $("#rm_group_submit").prop("disabled", !groupHasMembers);
}
function select_group_chats(chat_id) {
const group = chat_id && groups.find((x) => x.id == chat_id);
const groupName = group?.name ?? "";
$("#rm_group_chat_name").val(groupName);
$("#rm_group_chat_name").off();
$("#rm_group_chat_name").on("input", async function () {
if (chat_id) {
let _thisGroup = groups.find((x) => x.id == chat_id);
_thisGroup.name = $(this).val();
$("#rm_button_selected_ch").children("h2").text(_thisGroup.name);
await editGroup(chat_id);
} }
});
$("#rm_group_filter").val("").trigger("input");
$('input[name="rm_group_activation_strategy"]').off();
$('input[name="rm_group_activation_strategy"]').on("input", async function(e) {
if (chat_id) {
let _thisGroup = groups.find((x) => x.id == chat_id);
_thisGroup.activation_strategy = Number(e.target.value);
await editGroup(chat_id);
}
});
$(`input[name="rm_group_activation_strategy"][value="${Number(group?.activation_strategy ?? group_activation_strategy.NATURAL)}"]`).prop('checked', true);
selectRightMenuWithAnimation('rm_group_chats_block');
// render characters list // render characters list
$("#rm_group_add_members").empty(); $("#rm_group_add_members").empty();