From 714b4d6bb3ee7355ac16cc37a295a690f479c439 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Tue, 18 Apr 2023 00:10:13 +0200 Subject: [PATCH] more bugfixes --- app.py | 2 +- static/js/chat.js | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index 7e63aeba..a1fd701c 100644 --- a/app.py +++ b/app.py @@ -252,7 +252,7 @@ class Gpt4AllWebUI(GPT4AllAPI): def run_to(self): data = request.get_json() - message_id = data["id"] + message_id = int(data["id"]) self.stop = True # Segmented (the user receives the output as it comes) # We will first send a json entry that contains the message id and so on, then the text as it goes diff --git a/static/js/chat.js b/static/js/chat.js index ac5be266..1a9d33d2 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -146,19 +146,27 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) { entry_counter++; } else { - // For the other enrtries, these are just the text of the chatbot - for (const char of text) { - txt = hiddenElement_.innerHTML; - if (char != '\f') { - txt += char - hiddenElement_.innerHTML = txt - messageTextElement_.innerHTML = txt - } - - // scroll to bottom of chat window - chatWindow.scrollTop = chatWindow.scrollHeight; - } entry_counter++; + prefix = "FINAL:"; + if(text.startsWith(prefix)){ + text = text.substring(prefix.length); + hiddenElement.innerHTML = text + messageTextElement.innerHTML = text + } + else{ + // For the other enrtries, these are just the text of the chatbot + for (const char of text) { + txt = hiddenElement_.innerHTML; + if (char != '\f') { + txt += char + hiddenElement_.innerHTML = txt + messageTextElement_.innerHTML = txt + } + + // scroll to bottom of chat window + chatWindow.scrollTop = chatWindow.scrollHeight; + } + } } readStream();