From df8b25d56066f3bb8e6eb88dd0c1015837d35a66 Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Sat, 8 Apr 2023 13:00:32 +0200 Subject: [PATCH 1/3] Removed junk code --- static/js/chat.js | 98 ----------------------------------------------- 1 file changed, 98 deletions(-) diff --git a/static/js/chat.js b/static/js/chat.js index e378a6b9..b438be58 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -160,103 +160,6 @@ function addMessage(sender, message, id, can_edit=false) { return {'messageTextElement':messageTextElement, 'hiddenElement':hiddenElement} } - - - - - - -function add_collapsible_div(discussion_title, text, id) { - // Create the outer box element - const box = document.createElement('div'); - box.classList.add('bg-gray-100', 'rounded-lg', 'p-4'); - - // Create the title element - const title = document.createElement('h2'); - title.classList.add('text-lg', 'font-medium'); - title.textContent = discussion_title; - - // Create the toggle button element - const toggleBtn = document.createElement('button'); - toggleBtn.classList.add('focus:outline-none'); - toggleBtn.id = `${id}-toggle-btn`; - - // Create the expand icon element - const expandIcon = document.createElement('path'); - expandIcon.id = `${id}-expand-icon`; - expandIcon.setAttribute('d', 'M5 5h10v10H5z'); - - // Create the collapse icon element - const collapseIcon = document.createElement('path'); - collapseIcon.id = `${id}-collapse-icon`; - collapseIcon.setAttribute('d', 'M7 10h6'); - - // Add the icons to the toggle button element - toggleBtn.appendChild(expandIcon); - toggleBtn.appendChild(collapseIcon); - - // Create the content element - const content = document.createElement('div'); - content.id = `${id}-box-content`; - content.classList.add('mt-4'); - content.textContent = text; - // Add the title, toggle button, and content to the box element - // Create the title and toggle button container element - const titleToggleContainer = document.createElement('div'); - titleToggleContainer.classList.add('flex', 'justify-between', 'items-center'); - - // Add the title and toggle button to the container element - titleToggleContainer.appendChild(title); - titleToggleContainer.appendChild(toggleBtn); - - // Add the container element to the box element - box.appendChild(titleToggleContainer); - box.appendChild(content); - - // Add the box to the document - document.body.appendChild(box); - - // Add the CSS styles to the head of the document - const css = ` - #${id}-box-content { - max-height: 0; - overflow: hidden; - transition: max-height 0.2s ease-out; - } - - #${id}-box-content.expanded { - max-height: 1000px; - transition: max-height 0.5s ease-in; - } - - #${id}-toggle-btn:focus #${id}-collapse-icon { - display: block; - } - - #${id}-toggle-btn:focus #${id}-expand-icon { - display: none; - } - - #${id}-collapse-icon { - display: none; - } - `; - const head = document.head || document.getElementsByTagName('head')[0]; - const style = document.createElement('style'); - style.type = 'text/css'; - style.appendChild(document.createTextNode(css)); - head.appendChild(style); - - // Add the JavaScript code to toggle the box - const toggleBtnEl = document.querySelector(`#${id}-toggle-btn`); - const boxContentEl = document.querySelector(`#${id}-box-content`); - - toggleBtnEl.addEventListener('click', function() { - boxContentEl.classList.toggle('expanded'); - }); - return box - } - const welcome_message = `
This is a very early testing Web UI of GPT4All chatbot. @@ -278,7 +181,6 @@ const welcome_message = `
Welcome! I'm here to assist you with anything you need. What can I do for you today?
`; -//welcome_message = add_collapsible_div("Note:", text, 'hints'); addMessage("GPT4ALL",welcome_message,0); From 5684ade1904dac420651e82bc767bb5679814a3b Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Sat, 8 Apr 2023 17:43:01 +0200 Subject: [PATCH 2/3] Bugfix updating parameters --- app.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 785af307..6575c86e 100644 --- a/app.py +++ b/app.py @@ -458,18 +458,19 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo def update_model_params(self): data = request.get_json() + self.args.model = float(data["model"]) self.args.temp = float(data["temp"]) - self.args.top_k = float(data["top_k"]) - self.args.top_p = float(data["top_p"]) - self.args.repeat_penalty = float(data["repeat_penalty"]) - self.args.repeat_last_n = float(data["repeat_last_n"]) + self.args.top_k = float(data["topK"]) + self.args.top_p = float(data["topP"]) + self.args.repeat_penalty = float(data["repeatPenalty"]) + self.args.repeat_last_n = float(data["repeatLastN"]) print("Parameters changed to:") print(f"\tTemperature:{self.args.temp}") print(f"\top_k:{self.args.top_k}") print(f"\top_p:{self.args.top_p}") - print(f"\repeat_penalty:{self.args.repeat_penalty}") - print(f"\repeat_last_n:{self.args.repeat_last_n}") + print(f"\trepeat_penalty:{self.args.repeat_penalty}") + print(f"\trepeat_last_n:{self.args.repeat_last_n}") return jsonify({"status":"ok"}) From fb239bf4e5eec72058232f3d7d32f9db369ec6a5 Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Sat, 8 Apr 2023 18:00:02 +0200 Subject: [PATCH 3/3] fixed encoding issues --- app.py | 19 ++++++++++++------- static/js/settings.js | 1 + templates/chat.html | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index 6575c86e..506601c1 100644 --- a/app.py +++ b/app.py @@ -236,7 +236,7 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo top_p=self.args.top_p, repeat_penalty=self.args.repeat_penalty, repeat_last_n = self.args.repeat_last_n, - #seed=self.args.seed, + seed=self.args.seed, n_threads=8 ) print(f"Bot said:{self.bot_says}") @@ -267,7 +267,7 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo self.bot_says += text if self.current_message in self.full_text: self.is_bot_text_started = True - yield text + yield text.encode('utf-8').decode('latin-1') def add_endpoint( self, @@ -339,7 +339,7 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo ) self.current_discussion.update_message(response_id, self.bot_says) - yield self.bot_says + yield self.bot_says.encode('utf-8').decode('latin-1') # TODO : change this to use the yield version in order to send text word by word return "\n".join(bot_says) @@ -458,15 +458,20 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo def update_model_params(self): data = request.get_json() - self.args.model = float(data["model"]) + self.args.model = str(data["model"]) + self.args.n_predict = int(data["nPredict"]) + self.args.seed = int(data["seed"]) + self.args.temp = float(data["temp"]) - self.args.top_k = float(data["topK"]) + self.args.top_k = int(data["topK"]) self.args.top_p = float(data["topP"]) - self.args.repeat_penalty = float(data["repeatPenalty"]) - self.args.repeat_last_n = float(data["repeatLastN"]) + self.args.repeat_penalty = int(data["repeatPenalty"]) + self.args.repeat_last_n = int(data["repeatLastN"]) print("Parameters changed to:") print(f"\tTemperature:{self.args.temp}") + print(f"\tNPredict:{self.args.n_predict}") + print(f"\tSeed:{self.args.seed}") print(f"\top_k:{self.args.top_k}") print(f"\top_p:{self.args.top_p}") print(f"\trepeat_penalty:{self.args.repeat_penalty}") diff --git a/static/js/settings.js b/static/js/settings.js index 4fd39805..959f6ce6 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -5,6 +5,7 @@ submitButton.addEventListener('click', (event) => { event.preventDefault(); modelInput = document.getElementById('model'); + seedInput = document.getElementById('seed'); tempInput = document.getElementById('temp'); nPredictInput = document.getElementById('n-predict'); diff --git a/templates/chat.html b/templates/chat.html index de7aedb4..c524a60b 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -1,6 +1,7 @@ + GPT4All - WEBUI