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)
# 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()

View File

@ -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()
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)

View File

@ -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";

View File

@ -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