diff --git a/public/script.js b/public/script.js index 6e242f65a..fedd74ad1 100644 --- a/public/script.js +++ b/public/script.js @@ -125,6 +125,7 @@ export { updateChatMetadata, scrollChatToBottom, getTokenCount, + isStreamingEnabled, chat, this_chid, settings, diff --git a/public/scripts/extensions/expressions/index.js b/public/scripts/extensions/expressions/index.js index f2e1af48f..cdb1669ff 100644 --- a/public/scripts/extensions/expressions/index.js +++ b/public/scripts/extensions/expressions/index.js @@ -37,22 +37,22 @@ async function moduleWorker() { continue; } - return mes.mes; + return { mes: mes.mes, name: mes.name }; } - return ''; + return { mes: '', name: null }; } const context = getContext(); - // group chats and non-characters not supported - if (context.groupId || !context.characterId) { + // non-characters not supported + if (!context.groupId && !context.characterId) { removeExpression(); return; } // character changed - if (lastCharacter !== context.characterId) { + if (context.groupId !== lastCharacter && context.characterId !== lastCharacter) { removeExpression(); validateImages(); } @@ -69,7 +69,7 @@ async function moduleWorker() { // check if last message changed const currentLastMessage = getLastCharacterMessage(); - if (lastCharacter === context.characterId && lastMessage === currentLastMessage && $('img.expression').attr('src')) { + if (lastCharacter === context.characterId && lastMessage === currentLastMessage.mes && $('img.expression').attr('src')) { return; } @@ -89,13 +89,15 @@ async function moduleWorker() { 'Content-Type': 'application/json', 'Bypass-Tunnel-Reminder': 'bypass', }, - body: JSON.stringify({ text: currentLastMessage }) + body: JSON.stringify({ text: currentLastMessage.mes }) }); if (apiResult.ok) { + const name = context.groupId ? currentLastMessage.name : context.name2; + const force = !!context.groupId; const data = await apiResult.json(); const expression = data.classification[0].label; - setExpression(context.name2, expression); + setExpression(name, expression, force); } } @@ -104,8 +106,8 @@ async function moduleWorker() { } finally { inApiCall = false; - lastCharacter = context.characterId; - lastMessage = currentLastMessage; + lastCharacter = context.groupId || context.characterId; + lastMessage = currentLastMessage.mes; } } diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index 0c9f0fc87..d602ed8d0 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -38,6 +38,7 @@ import { hideSwipeButtons, chat_metadata, updateChatMetadata, + isStreamingEnabled, } from "../script.js"; export { @@ -291,7 +292,7 @@ async function generateGroupWrapper(by_auto_mode, type = null) { let typingIndicator = $("#chat .typing_indicator"); - if (typingIndicator.length === 0) { + if (typingIndicator.length === 0 && !isStreamingEnabled()) { typingIndicator = $( "#typing_indicator_template .typing_indicator" ).clone();