upgraded tool

This commit is contained in:
ParisNeo 2023-04-24 23:11:32 +02:00
parent 9fd814a3b3
commit 18eb207fa8
6 changed files with 14 additions and 7 deletions

7
app.py
View File

@ -386,9 +386,10 @@ class Gpt4AllWebUI(GPT4AllAPI):
def new_discussion(self):
title = request.args.get("title")
timestamp = self.create_new_discussion(title)
app.config['executor'] = ThreadPoolExecutor(max_workers=1)
app.config['executor'].submit(self.create_chatbot)
# app.config['executor'] = ThreadPoolExecutor(max_workers=1)
# app.config['executor'].submit(self.create_chatbot)
# target=self.create_chatbot()
# Return a success response
return json.dumps({"id": self.current_discussion.discussion_id, "time": timestamp, "welcome_message":self.personality["welcome_message"], "sender":self.personality["name"]})

View File

@ -17,7 +17,7 @@ __copyright__ = "Copyright 2023, "
__license__ = "Apache 2.0"
def load_config(file_path):
with open(file_path, 'r') as stream:
with open(file_path, 'r', encoding='utf-8') as stream:
config = yaml.safe_load(stream)
return config

View File

@ -93,7 +93,8 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) {
let hiddenElement_ = undefined
elements = addMessage("", "", 0, 0, can_edit = true);
// scroll to bottom of chat window
chatWindow.scrollTop = chatWindow.scrollHeight;
fetch("/run_to", {
method: 'POST',
headers: {

View File

@ -1,6 +1,6 @@
function load_discussion(discussion=0){
var container = document.getElementById('chat-window');
var chatWindow = document.getElementById('chat-window');
if(discussion)
{
@ -24,12 +24,14 @@ function load_discussion(discussion=0){
const messages = JSON.parse(data);
console.log(messages)
// process messages
container.innerHTML = '';
chatWindow.innerHTML = '';
messages.forEach(message => {
console.log(`Adding message ${message.type}`)
if(message.type==0){
console.log("Showing message")
addMessage(message.sender, message.content, message.id, message.rank, true);
// scroll to bottom of chat window
chatWindow.scrollTop = chatWindow.scrollHeight;
}
});
});

View File

@ -35,6 +35,8 @@ function update_main(){
user_msg = addMessage('',message, 0, 0, can_edit=true);
bot_msg = addMessage('', '', 0, 0, can_edit=true);
// scroll to bottom of chat window
chatWindow.scrollTop = chatWindow.scrollHeight;
fetch('/generate', {
method: 'POST',

View File

@ -231,6 +231,7 @@ fetch('/settings')
}
function populate_models(){
selectModel.innerHTML=""
// Fetch the list of .bin files from the models subfolder
fetch('/list_models')
.then(response => response.json())