From 39470b1c3205c1474464739b13da92ab42211cd9 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Tue, 18 Apr 2023 23:41:51 +0200 Subject: [PATCH] started working on extensions --- app.py | 2 +- pyGpt4All/extension.py | 7 +++++-- static/js/discussions.js | 2 +- static/js/main.js | 15 ++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index 0694d77b..c8f5e580 100644 --- a/app.py +++ b/app.py @@ -322,7 +322,7 @@ class Gpt4AllWebUI(GPT4AllAPI): app.config['executor'].submit(self.create_chatbot) # Return a success response - return json.dumps({"id": self.current_discussion.discussion_id, "time": timestamp, "welcome_message":self.personality["welcome_message"]}) + return json.dumps({"id": self.current_discussion.discussion_id, "time": timestamp, "welcome_message":self.personality["welcome_message"], "sender":self.personality["name"]}) def update_model_params(self): data = request.get_json() diff --git a/pyGpt4All/extension.py b/pyGpt4All/extension.py index 793b310f..4bf00c23 100644 --- a/pyGpt4All/extension.py +++ b/pyGpt4All/extension.py @@ -6,5 +6,8 @@ from config import load_config, save_config class Extension(): - def __init__(self, metadata_file_path:str) -> None: - self.config = load_config() \ No newline at end of file + def __init__(self, metadata_file_path:str, app) -> None: + self.app = app + self.metadata_file_path = metadata_file_path + self.config = load_config(metadata_file_path) + diff --git a/static/js/discussions.js b/static/js/discussions.js index 9e891229..54194dd4 100644 --- a/static/js/discussions.js +++ b/static/js/discussions.js @@ -233,7 +233,7 @@ function populate_menu(){ // Select the new discussion //selectDiscussion(discussionId); chatWindow.innerHTML="" - addMessage("GPT4ALL", data.welcome_message,0); + addMessage(data.sender, data.welcome_message,0); populate_discussions_list() sendbtn.style.display="block"; diff --git a/static/js/main.js b/static/js/main.js index 1c4817d2..7dd1c837 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -26,9 +26,6 @@ function update_main(){ waitAnimation.style.display="block"; console.log("Sending message to bot") - let hiddenElement = undefined - let messageTextElement = undefined - user_msg = addMessage('',message, 0, 0, can_edit=true); bot_msg = addMessage('', '', 0, 0, can_edit=true); @@ -81,8 +78,8 @@ function update_main(){ bot_msg.setSender(infos.bot); bot_msg.setID(infos.response_id); - messageTextElement = bot_msg.messageTextElement; - hiddenElement = bot_msg.hiddenElement; + bot_msg.messageTextElement; + bot_msg.hiddenElement; entry_counter ++; } else{ @@ -90,8 +87,8 @@ function update_main(){ prefix = "FINAL:"; if(text.startsWith(prefix)){ text = text.substring(prefix.length); - hiddenElement.innerHTML = text - messageTextElement.innerHTML = text + bot_msg.hiddenElement.innerHTML = text + bot_msg.messageTextElement.innerHTML = text } else{ // For the other enrtries, these are just the text of the chatbot @@ -99,8 +96,8 @@ function update_main(){ txt = hiddenElement.innerHTML; if (char != '\f') { txt += char - hiddenElement.innerHTML = txt; - messageTextElement.innerHTML = txt; + bot_msg.hiddenElement.innerHTML = txt; + bot_msg.messageTextElement.innerHTML = txt; } // scroll to bottom of chat window