#255 Fix WI tokenization if character is not selected

This commit is contained in:
SillyLossy
2023-05-07 15:36:55 +03:00
parent 78dabf7003
commit 28b5aa75a4

View File

@ -614,7 +614,18 @@ async function calculateLogitBias() {
} }
function countTokens(messages, full = false) { function countTokens(messages, full = false) {
let chatId = selected_group ? selected_group : characters[this_chid].chat; let chatId = 'undefined';
try {
if (selected_group) {
chatId = groups.find(x => x.id == selected_group)?.chat_id;
}
else if (this_chid) {
chatId = characters[this_chid].chat;
}
} catch {
console.log('No character / group selected. Using default cache item');
}
if (typeof tokenCache[chatId] !== 'object') { if (typeof tokenCache[chatId] !== 'object') {
tokenCache[chatId] = {}; tokenCache[chatId] = {};