started working on extensions

This commit is contained in:
Saifeddine ALOUI 2023-04-18 23:41:51 +02:00
parent 2a6ebab6df
commit 39470b1c32
4 changed files with 13 additions and 13 deletions

2
app.py
View File

@ -322,7 +322,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
app.config['executor'].submit(self.create_chatbot) app.config['executor'].submit(self.create_chatbot)
# Return a success response # 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): def update_model_params(self):
data = request.get_json() data = request.get_json()

View File

@ -6,5 +6,8 @@
from config import load_config, save_config from config import load_config, save_config
class Extension(): class Extension():
def __init__(self, metadata_file_path:str) -> None: def __init__(self, metadata_file_path:str, app) -> None:
self.config = load_config() self.app = app
self.metadata_file_path = metadata_file_path
self.config = load_config(metadata_file_path)

View File

@ -233,7 +233,7 @@ function populate_menu(){
// Select the new discussion // Select the new discussion
//selectDiscussion(discussionId); //selectDiscussion(discussionId);
chatWindow.innerHTML="" chatWindow.innerHTML=""
addMessage("GPT4ALL", data.welcome_message,0); addMessage(data.sender, data.welcome_message,0);
populate_discussions_list() populate_discussions_list()
sendbtn.style.display="block"; sendbtn.style.display="block";

View File

@ -26,9 +26,6 @@ function update_main(){
waitAnimation.style.display="block"; waitAnimation.style.display="block";
console.log("Sending message to bot") console.log("Sending message to bot")
let hiddenElement = undefined
let messageTextElement = undefined
user_msg = addMessage('',message, 0, 0, can_edit=true); user_msg = addMessage('',message, 0, 0, can_edit=true);
bot_msg = addMessage('', '', 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.setSender(infos.bot);
bot_msg.setID(infos.response_id); bot_msg.setID(infos.response_id);
messageTextElement = bot_msg.messageTextElement; bot_msg.messageTextElement;
hiddenElement = bot_msg.hiddenElement; bot_msg.hiddenElement;
entry_counter ++; entry_counter ++;
} }
else{ else{
@ -90,8 +87,8 @@ function update_main(){
prefix = "FINAL:"; prefix = "FINAL:";
if(text.startsWith(prefix)){ if(text.startsWith(prefix)){
text = text.substring(prefix.length); text = text.substring(prefix.length);
hiddenElement.innerHTML = text bot_msg.hiddenElement.innerHTML = text
messageTextElement.innerHTML = text bot_msg.messageTextElement.innerHTML = text
} }
else{ else{
// For the other enrtries, these are just the text of the chatbot // For the other enrtries, these are just the text of the chatbot
@ -99,8 +96,8 @@ function update_main(){
txt = hiddenElement.innerHTML; txt = hiddenElement.innerHTML;
if (char != '\f') { if (char != '\f') {
txt += char txt += char
hiddenElement.innerHTML = txt; bot_msg.hiddenElement.innerHTML = txt;
messageTextElement.innerHTML = txt; bot_msg.messageTextElement.innerHTML = txt;
} }
// scroll to bottom of chat window // scroll to bottom of chat window