mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Chat work
This commit is contained in:
@@ -618,7 +618,7 @@ gensettingstf = [
|
|||||||
"label": "Chat Style",
|
"label": "Chat Style",
|
||||||
"id": "chat_style",
|
"id": "chat_style",
|
||||||
"default": 0,
|
"default": 0,
|
||||||
"tooltip": "How to represent chat messages in the UI",
|
"tooltip": "How chat messages are shown",
|
||||||
"menu_path": "Interface",
|
"menu_path": "Interface",
|
||||||
"sub_path": "UI",
|
"sub_path": "UI",
|
||||||
"classname": "story",
|
"classname": "story",
|
||||||
|
@@ -5943,9 +5943,6 @@ function deleteChatPromptIfEmpty() {
|
|||||||
prompt.remove();
|
prompt.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial message
|
|
||||||
//addMessage(null, null, -1);
|
|
||||||
|
|
||||||
function computeChatGametext(actionId) {
|
function computeChatGametext(actionId) {
|
||||||
// TODO: Customizable format?
|
// TODO: Customizable format?
|
||||||
let lines = [];
|
let lines = [];
|
||||||
@@ -5962,6 +5959,8 @@ function computeChatGametext(actionId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateChatStyle() {
|
function updateChatStyle() {
|
||||||
|
const storyArea = document.getElementById("Selected Text");
|
||||||
|
|
||||||
if (chat.useV2) {
|
if (chat.useV2) {
|
||||||
// Already bubbles, do nothing
|
// Already bubbles, do nothing
|
||||||
if (document.getElementsByClassName("chat-message").length) {
|
if (document.getElementsByClassName("chat-message").length) {
|
||||||
@@ -5969,6 +5968,12 @@ function updateChatStyle() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete normal text
|
||||||
|
|
||||||
|
for (const child of storyArea.children) {
|
||||||
|
child.remove();
|
||||||
|
}
|
||||||
|
|
||||||
let addedMessages = 0;
|
let addedMessages = 0;
|
||||||
|
|
||||||
for (const [chunkId, chunk] of Object.entries(actions_data)) {
|
for (const [chunkId, chunk] of Object.entries(actions_data)) {
|
||||||
@@ -5983,11 +5988,29 @@ function updateChatStyle() {
|
|||||||
} else {
|
} else {
|
||||||
console.info("TODO: Convert 2 text")
|
console.info("TODO: Convert 2 text")
|
||||||
|
|
||||||
if (!document.getElementsByClassName("chat-message").length) {
|
if (!storyArea.children.length) {
|
||||||
console.info("Already text, do nothing")
|
for (const [chunkId, action] of Object.entries(actions_data)) {
|
||||||
return;
|
let item = document.createElement("span");
|
||||||
|
item.id = 'Selected Text Chunk '+chunkId;
|
||||||
|
item.classList.add("rawtext");
|
||||||
|
item.setAttribute("chunk", chunkId);
|
||||||
|
//need to find the closest element
|
||||||
|
next_id = chunkId+1;
|
||||||
|
if (Math.max.apply(null,Object.keys(actions_data).map(Number)) <= next_id) {
|
||||||
|
storyArea.append(item);
|
||||||
|
} else {
|
||||||
|
storyArea.prepend(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".chat-message").remove();
|
chunk_element = document.createElement("span");
|
||||||
|
chunk_element.textContent = action['Selected Text'];
|
||||||
|
item.append(chunk_element);
|
||||||
|
|
||||||
|
item.original_text = action['Selected Text'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const jQCM = $(".chat-message");
|
||||||
|
if (jQCM.length) jQCM.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user