mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Support for group chat expressions
This commit is contained in:
@ -125,6 +125,7 @@ export {
|
|||||||
updateChatMetadata,
|
updateChatMetadata,
|
||||||
scrollChatToBottom,
|
scrollChatToBottom,
|
||||||
getTokenCount,
|
getTokenCount,
|
||||||
|
isStreamingEnabled,
|
||||||
chat,
|
chat,
|
||||||
this_chid,
|
this_chid,
|
||||||
settings,
|
settings,
|
||||||
|
@ -37,22 +37,22 @@ async function moduleWorker() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mes.mes;
|
return { mes: mes.mes, name: mes.name };
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return { mes: '', name: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
const context = getContext();
|
const context = getContext();
|
||||||
|
|
||||||
// group chats and non-characters not supported
|
// non-characters not supported
|
||||||
if (context.groupId || !context.characterId) {
|
if (!context.groupId && !context.characterId) {
|
||||||
removeExpression();
|
removeExpression();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// character changed
|
// character changed
|
||||||
if (lastCharacter !== context.characterId) {
|
if (context.groupId !== lastCharacter && context.characterId !== lastCharacter) {
|
||||||
removeExpression();
|
removeExpression();
|
||||||
validateImages();
|
validateImages();
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ async function moduleWorker() {
|
|||||||
|
|
||||||
// check if last message changed
|
// check if last message changed
|
||||||
const currentLastMessage = getLastCharacterMessage();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,13 +89,15 @@ async function moduleWorker() {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Bypass-Tunnel-Reminder': 'bypass',
|
'Bypass-Tunnel-Reminder': 'bypass',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ text: currentLastMessage })
|
body: JSON.stringify({ text: currentLastMessage.mes })
|
||||||
});
|
});
|
||||||
|
|
||||||
if (apiResult.ok) {
|
if (apiResult.ok) {
|
||||||
|
const name = context.groupId ? currentLastMessage.name : context.name2;
|
||||||
|
const force = !!context.groupId;
|
||||||
const data = await apiResult.json();
|
const data = await apiResult.json();
|
||||||
const expression = data.classification[0].label;
|
const expression = data.classification[0].label;
|
||||||
setExpression(context.name2, expression);
|
setExpression(name, expression, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -104,8 +106,8 @@ async function moduleWorker() {
|
|||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
inApiCall = false;
|
inApiCall = false;
|
||||||
lastCharacter = context.characterId;
|
lastCharacter = context.groupId || context.characterId;
|
||||||
lastMessage = currentLastMessage;
|
lastMessage = currentLastMessage.mes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ import {
|
|||||||
hideSwipeButtons,
|
hideSwipeButtons,
|
||||||
chat_metadata,
|
chat_metadata,
|
||||||
updateChatMetadata,
|
updateChatMetadata,
|
||||||
|
isStreamingEnabled,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -291,7 +292,7 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
|
|||||||
|
|
||||||
let typingIndicator = $("#chat .typing_indicator");
|
let typingIndicator = $("#chat .typing_indicator");
|
||||||
|
|
||||||
if (typingIndicator.length === 0) {
|
if (typingIndicator.length === 0 && !isStreamingEnabled()) {
|
||||||
typingIndicator = $(
|
typingIndicator = $(
|
||||||
"#typing_indicator_template .typing_indicator"
|
"#typing_indicator_template .typing_indicator"
|
||||||
).clone();
|
).clone();
|
||||||
|
Reference in New Issue
Block a user