From 970a78776402031a0c0569619a28f16e231a2bcd Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 16 Apr 2023 23:22:09 +0200 Subject: [PATCH] upgraded conversion tool --- app.py | 5 +++-- scripts/convert model.bat | 6 +++--- static/js/chat.js | 5 ++++- static/js/main.js | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index 7660df36..2e92e5d4 100644 --- a/app.py +++ b/app.py @@ -32,6 +32,7 @@ import time from pyGpt4All.config import load_config, save_config from pyGpt4All.api import GPT4AllAPI import shutil +import markdown class Gpt4AllWebUI(GPT4AllAPI): def __init__(self, _app, config:dict, personality:dict, config_file_path) -> None: super().__init__(config, personality, config_file_path) @@ -212,13 +213,13 @@ class Gpt4AllWebUI(GPT4AllAPI): try: while not self.text_queue.empty(): value = self.text_queue.get(False) - value.replace("\n","
") - yield value + yield value.replace("\n","
") except : time.sleep(0.1) self.current_discussion.update_message(response_id, self.bot_says) self.full_message_list.append(self.bot_says) + bot_says = markdown.markdown(self.bot_says) return "\n".join(bot_says) diff --git a/scripts/convert model.bat b/scripts/convert model.bat index 172f238c..8dd723ce 100644 --- a/scripts/convert model.bat +++ b/scripts/convert model.bat @@ -1,7 +1,7 @@ @echo off @echo off -set filename=../models/ggml-alpaca-7b-q4.bin -set newname=../models/ggml-alpaca-7b-q4.bin.original +set filename=../models/$1 +set newname=../models/$1.original echo %modelPath% echo Converting the model to the new format... @@ -10,6 +10,6 @@ cd tmp\llama.cpp git checkout 6c248707f51c8a50f7792e7f7787ec481881db88 cd ../.. pwd -move /y "%filename%" "%filename%.original" +move /y "%filename%" "%newname%" echo Converting ... python tmp\llama.cpp\migrate-ggml-2023-03-30-pr613.py "%newname%" "%filename%" \ No newline at end of file diff --git a/static/js/chat.js b/static/js/chat.js index d641dc57..b5651a6b 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -82,8 +82,11 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) { function push() { reader.read().then(function (result) { if (result.done) { + console.log(result) sendbtn.style.display = "block"; waitAnimation.style.display = "none"; + hiddenElement_.innerHTML = txt + messageTextElement_.innerHTML = txt controller.close(); return; } @@ -100,6 +103,7 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) { function readStream() { readableStreamDefaultReader.read().then(function (result) { if (result.done) { + console.log(result) return; } @@ -109,7 +113,6 @@ function addMessage(sender, message, id, rank = 0, can_edit = false) { if (entry_counter == 0) { // We parse it and infos = JSON.parse(text) - console.log(infos) elements = addMessage(infos.sender, '', infos.response_id, 0, can_edit = true); messageTextElement_ = elements['messageTextElement']; hiddenElement_ = elements['hiddenElement']; diff --git a/static/js/main.js b/static/js/main.js index d1524288..276184c9 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -36,6 +36,7 @@ function update_main(){ if (result.done) { sendbtn.style.display="block"; waitAnimation.style.display="none"; + console.log(result) controller.close(); return; } @@ -62,7 +63,6 @@ function update_main(){ { // We parse it and infos = JSON.parse(text) - console.log(infos) addMessage('User', infos.message, infos.id, 0, can_edit=true); elements = addMessage(infos.sender, '', infos.response_id, 0, can_edit=true); messageTextElement=elements['messageTextElement']; @@ -74,7 +74,6 @@ function update_main(){ // For the other enrtries, these are just the text of the chatbot for (const char of text) { txt = hiddenElement.innerHTML; - console.log(txt) if (char != '\f') { txt += char hiddenElement.innerHTML = txt