From ece46c505e0d72ebefd699557f4f0b2fbca2bad5 Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Thu, 6 Apr 2023 21:47:46 +0200 Subject: [PATCH 01/34] updated gitignore and added a README.md to the models folder --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e402fa61..193d14c7 100644 --- a/.gitignore +++ b/.gitignore @@ -130,4 +130,6 @@ dmypy.json # Database *.db -/data \ No newline at end of file +/data +models/ +!models/README.md \ No newline at end of file From 864c5769e9f18a30aec02cfcac23571fdee472f8 Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Thu, 6 Apr 2023 22:07:20 +0200 Subject: [PATCH 02/34] Upgraded install batch files --- .gitignore | 9 +++++- .vscode/settings.json | 3 ++ install.bat | 68 +++++++++++++++++++++++++++++++------------ uninstall.bat | 2 +- 4 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 193d14c7..2654392b 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,13 @@ dmypy.json # Database *.db + +# Docker files /data + +# models models/ -!models/README.md \ No newline at end of file +!models/README.md + +# Temporary files +tmp/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..5d7d7306 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "ros.distro": "noetic" +} \ No newline at end of file diff --git a/install.bat b/install.bat index 1388eb6a..e7ba234e 100644 --- a/install.bat +++ b/install.bat @@ -1,12 +1,47 @@ @echo off +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH .HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHH. ,HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHH.## HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH#.HHHHH/*,*,*,*,*,*,*,*,***,*,**#HHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHH.*,,***,***,***,***,***,***,*******HHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*,,,,,HHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH.,,,***,***,***,***,***,***,***,***,***,***/HHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH*,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHH#,***,***,***,***,***,***,***,***,***,***,***,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHH..HHH,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*#HHHHHHHHHHHHHHHH +echo HHHHHHH,,,**,/H*,***,***,***,,,*,***,***,***,**,,,**,***,***,***H,,*,***HHHHHHHH +echo HHHHHH.*,,,*,,,,,*,*,*,***#HHHHH.,,*,*,*,*,**/HHHHH.,*,*,*,*,*,*,*,*****HHHHHHHH +echo HHHHHH.*,***,*,*,***,***,.HHHHHHH/**,***,****HHHHHHH.***,***,***,*******HHHHHHHH +echo HHHHHH.,,,,,,,,,,,,,,,,,,,.HHHHH.,,,,,,,,,,,,.HHHHHH,,,,,,,,,,,,,,,,,***HHHHHHHH +echo HHHHHH.,,,,,,/H,,,**,***,***,,,*,***,***,***,**,,,,*,***,***,***H***,***HHHHHHHH +echo HHHHHHH.,,,,*.H,,,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,***H*,,,,/HHHHHHHHH +echo HHHHHHHHHHHHHHH*,***,***,**,,***,***,***,***,***,***,***,***,**.HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH,,,,,,,,*,,#H#,,,,,*,,,*,,,,,,,,*#H*,,,,,,,,,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH,,*,***,***,**/.HHHHHHHHHHHHH#*,,,*,***,***,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,***,***,***,***,***,***,***,***,*.HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,*******/..HHHHHHHHH.#/*,*,,,***,***HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH*,*,*,******#HHHHHHHHHHHHHHHHHHHHHHHHHHHH./**,,,.HHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH.,,*,***.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH.*#HHHHHHHHHHHH +echo HHHHHHHHHHHHHHH/,,,*.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHH,,#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + + REM Check if Python is installed set /p="Checking for python..." nul 2>&1 -if %ERRORLEVEL% neq 0 ( - echo Python is not installed. Would you like to install Python? [Y/N] - set /p choice= - if /i "%choice%" equ "Y" ( +where python >nul 2>&1 +if %errorlevel% neq 0 ( + set /p choice=Python is not installed. Would you like to install Python? [Y/N] + if /i ".choice." equ "Y" ( REM Download Python installer echo Downloading Python installer... powershell -Command "Invoke-WebRequest -Uri 'https://www.python.org/ftp/python/3.10.0/python-3.10.0-amd64.exe' -OutFile 'python.exe'" @@ -22,20 +57,20 @@ if %ERRORLEVEL% neq 0 ( echo OK ) + REM Check if pip is installed set /p="Checking for pip..." nul 2>&1 -if %ERRORLEVEL% neq 0 ( - echo Pip is not installed. Would you like to install pip? [Y/N] - set /p choice= - if /i "%choice%" equ "Y" ( +if %errorlevel% neq 0 ( + set /p choice=Pip is not installed. Would you like to install pip? [Y/N] + if /i ".choice." equ "Y" ( REM Download get-pip.py echo Downloading get-pip.py... powershell -Command "Invoke-WebRequest -Uri 'https://bootstrap.pypa.io/get-pip.py' -OutFile 'get-pip.py'" REM Install pip echo Installing pip... python get-pip.py - ) else ( + ) else . echo Please install pip and try again. pause exit /b 1 @@ -47,10 +82,9 @@ if %ERRORLEVEL% neq 0 ( REM Check if venv module is available set /p="Checking for venv..." nul 2>&1 -if %ERRORLEVEL% neq 0 ( - echo venv module is not available. Would you like to upgrade Python to the latest version? [Y/N] - set /p choice= - if /i "%choice%" equ "Y" ( +if %errorlevel% neq 0 ( + set /p choice=venv module is not available. Would you like to upgrade Python to the latest version? [Y/N] + if /i ".choice." equ "Y" ( REM Upgrade Python echo Upgrading Python... python -m pip install --upgrade pip setuptools wheel @@ -67,7 +101,7 @@ if %ERRORLEVEL% neq 0 ( REM Create a new virtual environment set /p="Creating virtual environment ..." Date: Thu, 6 Apr 2023 22:16:52 +0200 Subject: [PATCH 03/34] Upgraded batch file --- install.bat | 17 ++++++++++++----- run.bat | 0 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 run.bat diff --git a/install.bat b/install.bat index e7ba234e..799fc4fb 100644 --- a/install.bat +++ b/install.bat @@ -35,6 +35,7 @@ echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +if not exist "./tmp" mkdir "./tmp" REM Check if Python is installed set /p="Checking for python..." Date: Thu, 6 Apr 2023 23:15:01 +0200 Subject: [PATCH 04/34] Moved to the new python Bindings from nomic-AI --- app.py | 115 ++++++++++++++++++++++++++++---------------------------- run.bat | 39 +++++++++++++++++++ 2 files changed, 96 insertions(+), 58 deletions(-) diff --git a/app.py b/app.py index 4be17f7b..5c10d1ea 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ from flask import Flask, jsonify, request, render_template, Response, stream_with_context -from nomic.gpt4all import GPT4All +from pyllamacpp.model import Model import argparse import threading from io import StringIO @@ -148,7 +148,6 @@ class Gpt4AllWebUI(): self.app=app self.db_path= db_path self.add_endpoint('/', '', self.index, methods=['GET']) - self.add_endpoint('/stream', 'stream', self.stream, methods=['GET']) self.add_endpoint('/export', 'export', self.export, methods=['GET']) self.add_endpoint('/new_discussion', 'new_discussion', self.new_discussion, methods=['GET']) self.add_endpoint('/bot', 'bot', self.bot, methods=['POST']) @@ -159,12 +158,44 @@ class Gpt4AllWebUI(): self.add_endpoint('/update_message', 'update_message', self.update_message, methods=['GET']) - - + conditionning_message=""" +Instruction: Act as GPT4All. A kind and helpful AI bot built to help users solve problems. +Start by welcoming the user then stop sending text. +GPT4All:""" + self.prepare_query(conditionning_message) + chatbot_bindings.generate(conditionning_message, n_predict=55, new_text_callback=self.new_text_callback, n_threads=8) + print(f"Bot said:{self.bot_says}") # Chatbot conditionning # response = self.chatbot_bindings.prompt("This is a discussion between A user and an AI. AI responds to user questions in a helpful manner. AI is not allowed to lie or deceive. AI welcomes the user\n### Response:") # print(response) + def prepare_query(self, message): + self.bot_says='' + self.full_text='' + self.is_bot_text_started=False + self.current_message = message + + + def new_text_callback(self, text: str): + print(text, end="") + self.full_text += text + if self.is_bot_text_started: + self.bot_says += text + if self.current_message in self.full_text: + self.is_bot_text_started=True + + def new_text_callback_with_yield(self, text: str): + """ + To do , fix the problem with yield to be able to show interactive response as text comes + """ + print(text, end="") + self.full_text += text + if self.is_bot_text_started: + self.bot_says += text + if self.current_message in self.full_text: + self.is_bot_text_started=True + yield text + def add_endpoint(self, endpoint=None, endpoint_name=None, handler=None, methods=['GET'], *args, **kwargs): self.app.add_url_rule(endpoint, endpoint_name, handler, methods=methods, *args, **kwargs) @@ -184,63 +215,29 @@ class Gpt4AllWebUI(): # Return the formatted message return message - - def stream(self): - def generate(): - # Replace this with your text-generating code - for i in range(10): - yield f'This is line {i+1}\n' - time.sleep(1) - - return Response(stream_with_context(generate())) - def export(self): return jsonify(export_to_json(self.db_path)) - @stream_with_context def parse_to_prompt_stream(self, message, message_id): - bot_says = [''] - point = b'' - bot = self.chatbot_bindings.bot + bot_says = '' self.stop=False - # very important. This is the maximum time we wait for the model - wait_val = 15.0 # At the beginning the server may need time to send data. we wait 15s - # send the message to the bot print(f"Received message : {message}") - bot = self.chatbot_bindings.bot - bot.stdin.write(message.encode('utf-8')) - bot.stdin.write(b"\n") - bot.stdin.flush() - # First we need to send the new message ID to the client response_id = self.current_discussion.add_message("GPT4All",'') # first the content is empty, but we'll fill it at the end yield(json.dumps({'type':'input_message_infos','message':message, 'id':message_id, 'response_id':response_id})) - #Now let's wait for the bot to answer - while not self.stop: - readable, _, _ = select.select([bot.stdout], [], [], wait_val) - wait_val = 4.0 # Once started, the process doesn't take that much so we reduce the wait - if bot.stdout in readable: - point += bot.stdout.read(1) - try: - character = point.decode("utf-8") - if character == "\n": - bot_says.append('\n') - yield '\n' - else: - bot_says[-1] += character - yield character - point = b'' + self.current_message = "User: "+message+"\nGPT4All:" + self.prepare_query(self.current_message) + chatbot_bindings.generate(self.current_message, n_predict=55, new_text_callback=self.new_text_callback, n_threads=8) - except UnicodeDecodeError: - if len(point) > 4: - point = b'' - else: - self.current_discussion.update_message(response_id,bot_says) - return "\n".join(bot_says) + self.current_discussion.update_message(response_id,self.bot_says) + yield self.bot_says + # TODO : change this to use the yield version in order to send text word by word + + return "\n".join(bot_says) def bot(self): self.stop=True @@ -335,17 +332,19 @@ if __name__ == '__main__': args = parser.parse_args() - chatbot_bindings = GPT4All(decoder_config = { - 'temp': args.temp, - 'n_predict':args.n_predict, - 'top_k':args.top_k, - 'top_p':args.top_p, - #'color': True,#"## Instruction", - 'repeat_penalty': args.repeat_penalty, - 'repeat_last_n':args.repeat_last_n, - 'ctx_size': args.ctx_size - }) - chatbot_bindings.open() + chatbot_bindings = Model(ggml_model='./models/gpt4all-converted.bin', n_ctx=512) + + # Old Code + # GPT4All(decoder_config = { + # 'temp': args.temp, + # 'n_predict':args.n_predict, + # 'top_k':args.top_k, + # 'top_p':args.top_p, + # #'color': True,#"## Instruction", + # 'repeat_penalty': args.repeat_penalty, + # 'repeat_last_n':args.repeat_last_n, + # 'ctx_size': args.ctx_size + # }) check_discussion_db(args.db_path) bot = Gpt4AllWebUI(chatbot_bindings, app, args.db_path) diff --git a/run.bat b/run.bat index e69de29b..a86428ba 100644 --- a/run.bat +++ b/run.bat @@ -0,0 +1,39 @@ +echo off + +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH .HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHH. ,HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHH.## HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH#.HHHHH/*,*,*,*,*,*,*,*,***,*,**#HHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHH.*,,***,***,***,***,***,***,*******HHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*,,,,,HHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH.,,,***,***,***,***,***,***,***,***,***,***/HHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH*,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHH#,***,***,***,***,***,***,***,***,***,***,***,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHH..HHH,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*#HHHHHHHHHHHHHHHH +echo HHHHHHH,,,**,/H*,***,***,***,,,*,***,***,***,**,,,**,***,***,***H,,*,***HHHHHHHH +echo HHHHHH.*,,,*,,,,,*,*,*,***#HHHHH.,,*,*,*,*,**/HHHHH.,*,*,*,*,*,*,*,*****HHHHHHHH +echo HHHHHH.*,***,*,*,***,***,.HHHHHHH/**,***,****HHHHHHH.***,***,***,*******HHHHHHHH +echo HHHHHH.,,,,,,,,,,,,,,,,,,,.HHHHH.,,,,,,,,,,,,.HHHHHH,,,,,,,,,,,,,,,,,***HHHHHHHH +echo HHHHHH.,,,,,,/H,,,**,***,***,,,*,***,***,***,**,,,,*,***,***,***H***,***HHHHHHHH +echo HHHHHHH.,,,,*.H,,,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,***H*,,,,/HHHHHHHHH +echo HHHHHHHHHHHHHHH*,***,***,**,,***,***,***,***,***,***,***,***,**.HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH,,,,,,,,*,,#H#,,,,,*,,,*,,,,,,,,*#H*,,,,,,,,,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH,,*,***,***,**/.HHHHHHHHHHHHH#*,,,*,***,***,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,***,***,***,***,***,***,***,***,*.HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,*******/..HHHHHHHHH.#/*,*,,,***,***HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH*,*,*,******#HHHHHHHHHHHHHHHHHHHHHHHHHHHH./**,,,.HHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH.,,*,***.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH.*#HHHHHHHHHHHH +echo HHHHHHHHHHHHHHH/,,,*.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHH,,#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + +env/Scripts/activate.bat +python app.py \ No newline at end of file From 258c43c5dde3941f2a5503888860144c122bd00d Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Thu, 6 Apr 2023 23:26:42 +0200 Subject: [PATCH 05/34] Moving stuff from ParisNeo to nomic-ai --- README.md | 58 +++++++++++++++++++++++------------------------------ install.bat | 3 ++- install.sh | 41 +++++++++++++++++++++++++++++++++++++ run.sh | 43 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 34 deletions(-) create mode 100644 run.sh diff --git a/README.md b/README.md index b264221d..8020e78e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Gpt4All Web UI -![GitHub license](https://img.shields.io/github/license/ParisNeo/Gpt4All-webui) +![GitHub license](https://img.shields.io/github/license/nomic-ai/GPT4All-ui) -![GitHub issues](https://img.shields.io/github/issues/ParisNeo/Gpt4All-webui) +![GitHub issues](https://img.shields.io/github/issues/nomic-ai/GPT4All-ui) -![GitHub stars](https://img.shields.io/github/stars/ParisNeo/Gpt4All-webui) +![GitHub stars](https://img.shields.io/github/stars/nomic-ai/GPT4All-ui) -![GitHub forks](https://img.shields.io/github/forks/ParisNeo/Gpt4All-webui) +![GitHub forks](https://img.shields.io/github/forks/nomic-ai/GPT4All-ui) This is a Flask web application that provides a chat UI for interacting with the GPT4All chatbot. @@ -20,24 +20,9 @@ The app allows users to send messages to the chatbot and view its responses in r The model has just been released and it may evolve over time, this webui is meant for community to get easy and fully local access to a chatbot that may become better with time. -## Disclaimer - -The model used by GPT4ALL has been fine-tuned using the LORA technique on LLAMA 7B weights (for now). It is important to note that the LLAMA weights are under commercial proprietary license, and therefore, this model cannot be used for commercial purposes. We do not provide the weights ourselves, but have built a UI wrapper on top of the Nomic library, which downloads the weights automatically upon running the program. - -It is important to understand that we are not responsible for any misuse of this tool. Please use it responsibly and at your own risk. While we hope that Nomic will address this issue in the future by providing clean weights that can be used freely, for now, this model is intended for testing purposes only. - ## UI screenshot ![image](https://user-images.githubusercontent.com/827993/229951093-27114d9f-0e1f-4d84-b103-e35cd3f9310d.png) -**Note for Windows users:** At the moment, Nomic-AI has not provided a wheel for Windows, so you will need to use the app with the Windows Subsystem for Linux (WSL). To install WSL, follow these steps: - -- Open the Windows Features settings (you can find this by searching for "Windows Features" in the Start menu). -- Enable the "Windows Subsystem for Linux" feature. -- Restart your computer when prompted. -- Install a Linux distribution from the Microsoft Store (e.g., Ubuntu). -- Open the Linux distribution and follow the prompts to create a new user account. -- We apologize for any inconvenience this may cause. We are working on a more widespread version. - ## Installation To install the app, follow these steps: @@ -45,35 +30,42 @@ To install the app, follow these steps: 1. Clone the GitHub repository: ``` -git clone https://github.com/ParisNeo/Gpt4All-webui +git clone https://github.com/nomic-ai/gpt4all-ui ``` 1. Navigate to the project directory: ``` -cd Gpt4All-webui +cd GPT4All-ui ``` 1. Run the appropriate installation script for your platform: -On Windows with WSL: - -- When Nomic add windows support you would be able to use this : - - ``` - install.bat - ``` +On Windows : +``` +install.bat +``` - On linux/ Mac os - ``` +``` ./install.sh - ``` +``` On Linux/MacOS, if you have issues, refer more details are presented [here](docs/Linux_Osx_Install.md) +These scripts will create a Python virtual environment and install the required dependencies. It will also download the models and install them. -These scripts will create a Python virtual environment and install the required dependencies. - +Now you're ready to work! ## Usage +For simple newbies on Windows: +```bash +run.bat +``` + +For simple newbies on Linux/MacOsX: +```bash +run.bat +``` + To run the Flask server, execute the following command: ```bash @@ -144,7 +136,7 @@ We are excited about these future plans for the project and look forward to impl ## License -This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/ParisNeo/Gpt4All-webui/blob/main/LICENSE) file for details. +This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/nomic-ai/GPT4All-ui/blob/main/LICENSE) file for details. ## Special thanks diff --git a/install.bat b/install.bat index 799fc4fb..3bc4c594 100644 --- a/install.bat +++ b/install.bat @@ -130,6 +130,7 @@ powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models echo Cleaning tmp folder rd /s /q "./tmp" -echo Virtual environment created and packages installed successfully. Run app.py +echo Virtual environment created and packages installed successfully. +echo Every thing is setup. Just run run.bat pause exit /b 0 diff --git a/install.sh b/install.sh index 583f4bb4..5374cdb7 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,42 @@ #!/usr/bin/bash + +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH .HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHH. ,HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHH.## HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH#.HHHHH/*,*,*,*,*,*,*,*,***,*,**#HHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHH.*,,***,***,***,***,***,***,*******HHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*,,,,,HHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH.,,,***,***,***,***,***,***,***,***,***,***/HHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH*,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHH#,***,***,***,***,***,***,***,***,***,***,***,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHH..HHH,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*#HHHHHHHHHHHHHHHH +echo HHHHHHH,,,**,/H*,***,***,***,,,*,***,***,***,**,,,**,***,***,***H,,*,***HHHHHHHH +echo HHHHHH.*,,,*,,,,,*,*,*,***#HHHHH.,,*,*,*,*,**/HHHHH.,*,*,*,*,*,*,*,*****HHHHHHHH +echo HHHHHH.*,***,*,*,***,***,.HHHHHHH/**,***,****HHHHHHH.***,***,***,*******HHHHHHHH +echo HHHHHH.,,,,,,,,,,,,,,,,,,,.HHHHH.,,,,,,,,,,,,.HHHHHH,,,,,,,,,,,,,,,,,***HHHHHHHH +echo HHHHHH.,,,,,,/H,,,**,***,***,,,*,***,***,***,**,,,,*,***,***,***H***,***HHHHHHHH +echo HHHHHHH.,,,,*.H,,,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,***H*,,,,/HHHHHHHHH +echo HHHHHHHHHHHHHHH*,***,***,**,,***,***,***,***,***,***,***,***,**.HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH,,,,,,,,*,,#H#,,,,,*,,,*,,,,,,,,*#H*,,,,,,,,,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH,,*,***,***,**/.HHHHHHHHHHHHH#*,,,*,***,***,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,***,***,***,***,***,***,***,***,*.HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,*******/..HHHHHHHHH.#/*,*,,,***,***HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH*,*,*,******#HHHHHHHHHHHHHHHHHHHHHHHHHHHH./**,,,.HHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH.,,*,***.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH.*#HHHHHHHHHHHH +echo HHHHHHHHHHHHHHH/,,,*.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHH,,#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + + # Install Python 3.11 and pip echo -n "Checking for python3.11..." if command -v python3.11 > /dev/null 2>&1; then @@ -59,5 +96,9 @@ if [ $? -ne 0 ]; then exit 1 fi +echo Downloading latest model +wget -P model/ https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin + echo "Virtual environment created and packages installed successfully." +echo "Every thing is setup. Just run run.sh" exit 0 diff --git a/run.sh b/run.sh new file mode 100644 index 00000000..68c69bc9 --- /dev/null +++ b/run.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH .HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHH. ,HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHH.## HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH#.HHHHH/*,*,*,*,*,*,*,*,***,*,**#HHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHH.*,,***,***,***,***,***,***,*******HHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*,,,,,HHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH.,,,***,***,***,***,***,***,***,***,***,***/HHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH*,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHH#,***,***,***,***,***,***,***,***,***,***,***,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHH..HHH,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*#HHHHHHHHHHHHHHHH +echo HHHHHHH,,,**,/H*,***,***,***,,,*,***,***,***,**,,,**,***,***,***H,,*,***HHHHHHHH +echo HHHHHH.*,,,*,,,,,*,*,*,***#HHHHH.,,*,*,*,*,**/HHHHH.,*,*,*,*,*,*,*,*****HHHHHHHH +echo HHHHHH.*,***,*,*,***,***,.HHHHHHH/**,***,****HHHHHHH.***,***,***,*******HHHHHHHH +echo HHHHHH.,,,,,,,,,,,,,,,,,,,.HHHHH.,,,,,,,,,,,,.HHHHHH,,,,,,,,,,,,,,,,,***HHHHHHHH +echo HHHHHH.,,,,,,/H,,,**,***,***,,,*,***,***,***,**,,,,*,***,***,***H***,***HHHHHHHH +echo HHHHHHH.,,,,*.H,,,,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,***H*,,,,/HHHHHHHHH +echo HHHHHHHHHHHHHHH*,***,***,**,,***,***,***,***,***,***,***,***,**.HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH,,,,,,,,*,,#H#,,,,,*,,,*,,,,,,,,*#H*,,,,,,,,,**HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH,,*,***,***,**/.HHHHHHHHHHHHH#*,,,*,***,***,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*HHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,***,***,***,***,***,***,***,***,*.HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*HHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHH**,***,***,*******/..HHHHHHHHH.#/*,*,,,***,***HHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHH*,*,*,******#HHHHHHHHHHHHHHHHHHHHHHHHHHHH./**,,,.HHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHH.,,*,***.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH.*#HHHHHHHHHHHH +echo HHHHHHHHHHHHHHH/,,,*.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHH,,#HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHH.HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + + +# Activate the virtual environment +source venv/bin/activate + +# Launch the Python application +python app.py From ebe39b0b74e1bedb264b0d2913aa87f5e8bcc343 Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Thu, 6 Apr 2023 23:29:20 +0200 Subject: [PATCH 06/34] upgraded README.md --- README.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8020e78e..baa8a2dd 100644 --- a/README.md +++ b/README.md @@ -57,15 +57,28 @@ These scripts will create a Python virtual environment and install the required Now you're ready to work! ## Usage For simple newbies on Windows: -```bash +```cmd run.bat ``` For simple newbies on Linux/MacOsX: ```bash -run.bat +run.sh ``` +if you want more control on your launch, you can activate your environment: + +On Windows: +```cmd +env/Scripts/activate.bat +``` + +On Linux/MacOs: +```cmd +source venv/bin/activate +``` + +Now you are ready to customize your Bot. To run the Flask server, execute the following command: ```bash @@ -136,15 +149,4 @@ We are excited about these future plans for the project and look forward to impl ## License -This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/nomic-ai/GPT4All-ui/blob/main/LICENSE) file for details. - -## Special thanks - - -Special thanks to : -- [cclaar-byte](https://github.com/cclaar-byte) -- [CybearWarfare](https://github.com/CybearWarfare) -- [Jan Brummelte](https://github.com/brummelte) -- [higorvaz](https://github.com/higorvaz) - -for their contributions. +This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/nomic-ai/GPT4All-ui/blob/main/LICENSE) file for details. \ No newline at end of file From 3841792b8ef7d8d9903ba01cfb4c00815dbda89d Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Apr 2023 22:19:13 -0300 Subject: [PATCH 07/34] check wget dependency --- install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install.sh b/install.sh index 5374cdb7..eb135c5a 100644 --- a/install.sh +++ b/install.sh @@ -98,6 +98,11 @@ fi echo Downloading latest model wget -P model/ https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin +if [ $? -ne 0 ]; then + echo "Failed to download model. Please check your `wget` dependency, internet connection and try again." + exit 1 +fi + echo "Virtual environment created and packages installed successfully." echo "Every thing is setup. Just run run.sh" From 5e390fb28aec29546c888daa9e9a3b89275438fc Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Apr 2023 22:19:50 -0300 Subject: [PATCH 08/34] added mac pre-dependencies for installation --- docs/Linux_Osx_Install.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/Linux_Osx_Install.md b/docs/Linux_Osx_Install.md index 086a285e..52f32b62 100644 --- a/docs/Linux_Osx_Install.md +++ b/docs/Linux_Osx_Install.md @@ -1,5 +1,11 @@ # Installing GPT4All-Webui on Linux or macOS: +\- Make sure you have all the dependencies for requirements +`python3.11 -m pip install cmake` +`python3.11 -m pip install nproc` if you have issues with scikit-learn add the foollowing env var +`SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True` +`python3.11 -m pip install wget` + \- Install requirements python3.11 -m pip install -r requirements.txt  From 2b8fbd68aac1d4757a0a5bff6e1eb790ecbd4fd3 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Thu, 6 Apr 2023 20:24:14 -0700 Subject: [PATCH 09/34] fix typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index baa8a2dd..c27f9cf8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This is a Flask web application that provides a chat UI for interacting with the ## What is GPT4All -GPT4All is a language model built by Nomic-AI, a company specializing in natural language processing. The app uses Nomic-AI's library to communicate with the GPT4All model, which runs locally on the user's PC. For more details about this project, head on to their [github repository](https://github.com/nomic-ai/gpt4all). You can also reald their [Technical report](https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf) for more information about the training process, the batabase etc. +GPT4All is a language model built by Nomic-AI, a company specializing in natural language processing. The app uses Nomic-AI's library to communicate with the GPT4All model, which runs locally on the user's PC. For more details about this project, head on to their [github repository](https://github.com/nomic-ai/gpt4all). You can also reald their [Technical report](https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf) for more information about the training process, the database etc. The app allows users to send messages to the chatbot and view its responses in real-time. Additionally, users can export the entire chat history in text or JSON format. @@ -149,4 +149,4 @@ We are excited about these future plans for the project and look forward to impl ## License -This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/nomic-ai/GPT4All-ui/blob/main/LICENSE) file for details. \ No newline at end of file +This project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/nomic-ai/GPT4All-ui/blob/main/LICENSE) file for details. From b38303f7508d60e1e38c7558c1b0dd330e6c9a44 Mon Sep 17 00:00:00 2001 From: Andriy Mulyar Date: Thu, 6 Apr 2023 23:37:31 -0400 Subject: [PATCH 10/34] Updated default model path --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 5c10d1ea..a9d28f96 100644 --- a/app.py +++ b/app.py @@ -332,7 +332,7 @@ if __name__ == '__main__': args = parser.parse_args() - chatbot_bindings = Model(ggml_model='./models/gpt4all-converted.bin', n_ctx=512) + chatbot_bindings = Model(ggml_model='./models/gpt4all-lora-quantized-ggml.bin', n_ctx=512) # Old Code # GPT4All(decoder_config = { From 601bfcac321b95a80a46471cf260f143c5ddde5b Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 7 Apr 2023 05:39:16 +0200 Subject: [PATCH 11/34] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index c27f9cf8..d71e9f8d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,8 @@ # Gpt4All Web UI ![GitHub license](https://img.shields.io/github/license/nomic-ai/GPT4All-ui) - ![GitHub issues](https://img.shields.io/github/issues/nomic-ai/GPT4All-ui) - ![GitHub stars](https://img.shields.io/github/stars/nomic-ai/GPT4All-ui) - ![GitHub forks](https://img.shields.io/github/forks/nomic-ai/GPT4All-ui) This is a Flask web application that provides a chat UI for interacting with the GPT4All chatbot. From 3b3bfc6fd4843f27ece53a70e57dbcfc995ce902 Mon Sep 17 00:00:00 2001 From: Dennis Stanistan Date: Fri, 7 Apr 2023 07:26:29 +0300 Subject: [PATCH 12/34] fix model path in install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index eb135c5a..ffb1661e 100644 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ if [ $? -ne 0 ]; then fi echo Downloading latest model -wget -P model/ https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin +wget -P models/ https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin if [ $? -ne 0 ]; then echo "Failed to download model. Please check your `wget` dependency, internet connection and try again." exit 1 From 20e86d7dfcad2bd56d6f93ccb72ae2372de7a7b5 Mon Sep 17 00:00:00 2001 From: Dennis Stanistan Date: Fri, 7 Apr 2023 07:31:25 +0300 Subject: [PATCH 13/34] Update install.3.10.sh to wget the model --- install.3.10.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.3.10.sh b/install.3.10.sh index 171c0fb6..b8f5762c 100644 --- a/install.3.10.sh +++ b/install.3.10.sh @@ -59,5 +59,12 @@ if [ $? -ne 0 ]; then exit 1 fi +echo Downloading latest model +wget -P models/ https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin +if [ $? -ne 0 ]; then + echo "Failed to download model. Please check your `wget` dependency, internet connection and try again." + exit 1 +fi + echo "Virtual environment created and packages installed successfully." exit 0 From efea100f2c3d260968d32961bb884281e7579ad0 Mon Sep 17 00:00:00 2001 From: Dennis Stanistan Date: Fri, 7 Apr 2023 07:38:26 +0300 Subject: [PATCH 14/34] activate the correct virtual env in run.sh install.sh and install.3.10.sh runs python3.11 -m venv env but run.sh tries to activate in venv, this commit fixes it --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 68c69bc9..b3b1a4e0 100644 --- a/run.sh +++ b/run.sh @@ -37,7 +37,7 @@ echo HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH # Activate the virtual environment -source venv/bin/activate +source env/bin/activate # Launch the Python application python app.py From 8a22bc69e67e4e6765a2e119b78abd0a3d0eba2f Mon Sep 17 00:00:00 2001 From: arroyoquiel <81461845+arroyoquiel@users.noreply.github.com> Date: Fri, 7 Apr 2023 00:23:14 -0600 Subject: [PATCH 15/34] Update install.bat The current code assumes that the models directory exists, but this may not always be the case. If the models directory does not exist, the Invoke-WebRequest command fails with a DirectoryNotFoundException error. --- install.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/install.bat b/install.bat index 3bc4c594..9ad8e657 100644 --- a/install.bat +++ b/install.bat @@ -125,6 +125,7 @@ if .ERRORLEVEL. neq 0 ( ) echo Downloading latest model +md models powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" echo Cleaning tmp folder From 07ba3c564aa9e8ce57f38ce17d42beabeca5f355 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 7 Apr 2023 09:07:59 +0200 Subject: [PATCH 16/34] Now the models folder is checked before downloading If the models folder does not exist create it --- install.bat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.bat b/install.bat index 9ad8e657..f034f479 100644 --- a/install.bat +++ b/install.bat @@ -125,7 +125,9 @@ if .ERRORLEVEL. neq 0 ( ) echo Downloading latest model -md models +IF NOT EXIST models ( + md models +) else () powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" echo Cleaning tmp folder From 1b01a96ccccf771e8ca947f49dcd37364d22d07e Mon Sep 17 00:00:00 2001 From: arroyoquiel <81461845+arroyoquiel@users.noreply.github.com> Date: Fri, 7 Apr 2023 01:15:54 -0600 Subject: [PATCH 17/34] Resolved installation error Changed to "%ERRORLEVEL%" because ".ERRORLEVEL." is not a valid syntax, this should fix the "Failed to install required packages. Please check your internet connection and try again. Press any key to continue . . ." error despite the requirements being installed correctly. --- install.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.bat b/install.bat index f034f479..2cc97a33 100644 --- a/install.bat +++ b/install.bat @@ -118,7 +118,7 @@ REM Install the required packages echo Installing requirements ... python -m pip install pip --upgrade python -m pip install -r requirements.txt -if .ERRORLEVEL. neq 0 ( +if %ERRORLEVEL% neq 0 ( echo Failed to install required packages. Please check your internet connection and try again. pause exit /b 1 From e11128ba739a16e39dc0328f12fefe19f6e84c1e Mon Sep 17 00:00:00 2001 From: arroyoquiel <81461845+arroyoquiel@users.noreply.github.com> Date: Fri, 7 Apr 2023 01:47:43 -0600 Subject: [PATCH 18/34] Resolved model download error If previously there were a "models" folder, it would just close the install.bat window and wouldn't continue, so I removed the "else ()" and added a "IF NOT EXIST models/gpt4all-lora-quantized-ggml.bin" if the user already had the model manually downloaded --- install.bat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/install.bat b/install.bat index 2cc97a33..8aee0f21 100644 --- a/install.bat +++ b/install.bat @@ -127,8 +127,10 @@ if %ERRORLEVEL% neq 0 ( echo Downloading latest model IF NOT EXIST models ( md models -) else () -powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" +) +IF NOT EXIST models/gpt4all-lora-quantized-ggml.bin ( + powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" +) echo Cleaning tmp folder rd /s /q "./tmp" From 485e9611a3ffcea3a55bc717f5bee25ace325280 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 7 Apr 2023 10:27:36 +0200 Subject: [PATCH 19/34] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d71e9f8d..3bc4d593 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ This is a Flask web application that provides a chat UI for interacting with the GPT4All chatbot. -[Discord server](https://discord.gg/DZ4wsgg4) +Follow us on our [Discord server](https://discord.gg/DZ4wsgg4). -## What is GPT4All +## What is GPT4All ? GPT4All is a language model built by Nomic-AI, a company specializing in natural language processing. The app uses Nomic-AI's library to communicate with the GPT4All model, which runs locally on the user's PC. For more details about this project, head on to their [github repository](https://github.com/nomic-ai/gpt4all). You can also reald their [Technical report](https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf) for more information about the training process, the database etc. From 8430e26ad95f8f7bb0d215e3bd6da67ea53a5dc7 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 7 Apr 2023 10:30:41 +0200 Subject: [PATCH 20/34] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3bc4d593..71bacfee 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,13 @@ Follow us on our [Discord server](https://discord.gg/DZ4wsgg4). ## What is GPT4All ? -GPT4All is a language model built by Nomic-AI, a company specializing in natural language processing. The app uses Nomic-AI's library to communicate with the GPT4All model, which runs locally on the user's PC. For more details about this project, head on to their [github repository](https://github.com/nomic-ai/gpt4all). You can also reald their [Technical report](https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf) for more information about the training process, the database etc. +GPT4All is an exceptional language model, designed and developed by Nomic-AI, a proficient company dedicated to natural language processing. The app uses Nomic-AI's advanced library to communicate with the cutting-edge GPT4All model, which operates locally on the user's PC, ensuring seamless and efficient communication. -The app allows users to send messages to the chatbot and view its responses in real-time. Additionally, users can export the entire chat history in text or JSON format. +If you are interested in learning more about this groundbreaking project, visit their Github repository [github repository](https://github.com/nomic-ai/gpt4all), where you can find comprehensive information regarding the app's functionalities and technical details. Moreover, you can delve deeper into the training process and database by going through their detailed Technical report, available for download at [Technical report](https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf). -The model has just been released and it may evolve over time, this webui is meant for community to get easy and fully local access to a chatbot that may become better with time. +One of the app's impressive features is that it allows users to send messages to the chatbot and receive instantaneous responses in real-time, ensuring a seamless user experience. Additionally, the app facilitates the exportation of the entire chat history in either text or JSON format, providing greater flexibility to the users. + +It's worth noting that the model has recently been launched, and it's expected to evolve over time, enabling it to become even better in the future. This webui is designed to provide the community with easy and fully localized access to a chatbot that will continue to improve and adapt over time. ## UI screenshot ![image](https://user-images.githubusercontent.com/827993/229951093-27114d9f-0e1f-4d84-b103-e35cd3f9310d.png) From 701f28d7d9968307ebe6eee48bd975f0314eee8c Mon Sep 17 00:00:00 2001 From: arroyoquiel <81461845+arroyoquiel@users.noreply.github.com> Date: Fri, 7 Apr 2023 02:37:57 -0600 Subject: [PATCH 21/34] Resolved model download error If previously there were a "models" folder, it would just close the install.bat window and wouldn't continue, so I removed the "else ()" and also added a "IF NOT EXIST models/gpt4all-lora-quantized-ggml.bin" if the user already had the model manually downloaded Also added a (y/n) choice --- install.bat | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/install.bat b/install.bat index 8aee0f21..7b42715f 100644 --- a/install.bat +++ b/install.bat @@ -128,9 +128,24 @@ echo Downloading latest model IF NOT EXIST models ( md models ) + IF NOT EXIST models/gpt4all-lora-quantized-ggml.bin ( powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" +) ELSE ( + :PROMPT + echo. + set /p choice="The model file already exists. Do you want to override it? (y/n) " + if /i {%choice%}=={y} ( + powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" && goto :CONTINUE + ) else if /i {%choice%}=={n} ( + goto :CONTINUE + ) else ( + echo. + echo Invalid input. Please enter 'y' or 'n'. + goto :PROMPT + ) ) +:CONTINUE echo Cleaning tmp folder rd /s /q "./tmp" From 79543b1edf059822d99f43bc0a3818dc42bf807a Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 7 Apr 2023 12:23:46 +0200 Subject: [PATCH 22/34] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71bacfee..c5dce3d5 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ git clone https://github.com/nomic-ai/gpt4all-ui 1. Navigate to the project directory: ``` -cd GPT4All-ui +cd gpt4all-ui ``` 1. Run the appropriate installation script for your platform: From 6af9d54a4750880e6f10c2e8bb57823694ce8c09 Mon Sep 17 00:00:00 2001 From: arroyoquiel <81461845+arroyoquiel@users.noreply.github.com> Date: Fri, 7 Apr 2023 05:40:08 -0600 Subject: [PATCH 23/34] Fancier [Y/N/B] Fancier [Y/N/B], does not require for you to press the letter and then enter, and also asks you if you want to download the model instead of downloading it automatically if you don't have it. Pressing B lets you open the link in the browser for a faster download because most browsers support multi-segment downloads. With Invoke-WebRequest it would take me ~30 minutes to download with a 200Mbps speed. Also lets you retry the download if failed or disconnected. --- install.bat | 54 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/install.bat b/install.bat index 7b42715f..e96e7759 100644 --- a/install.bat +++ b/install.bat @@ -125,27 +125,51 @@ if %ERRORLEVEL% neq 0 ( ) echo Downloading latest model -IF NOT EXIST models ( +if not exist models ( md models ) -IF NOT EXIST models/gpt4all-lora-quantized-ggml.bin ( - powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" -) ELSE ( - :PROMPT +if not exist models/gpt4all-lora-quantized-ggml.bin ( echo. - set /p choice="The model file already exists. Do you want to override it? (y/n) " - if /i {%choice%}=={y} ( - powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" && goto :CONTINUE - ) else if /i {%choice%}=={n} ( - goto :CONTINUE - ) else ( - echo. - echo Invalid input. Please enter 'y' or 'n'. - goto :PROMPT - ) + choice /C YNB /M "The default model file (gpt4all-lora-quantized-ggml.bin) does not exist. Do you want to download it? Press B to download it with a browser (faster)." + if errorlevel 3 goto DOWNLOAD_WITH_BROWSER + if errorlevel 2 goto DOWNLOAD_SKIP + if errorlevel 1 goto MODEL_DOWNLOAD +) ELSE ( + echo. + choice /C YNB /M "The default model file (gpt4all-lora-quantized-ggml.bin) already exists. Do you want to replace it? Press B to download it with a browser (faster)." + if errorlevel 3 goto DOWNLOAD_WITH_BROWSER + if errorlevel 2 goto DOWNLOAD_SKIP + if errorlevel 1 goto MODEL_DOWNLOAD ) + +:DOWNLOAD_WITH_BROWSER +start https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin +echo Link has been opened with the default web browser, make sure to save it into the models folder. Press any key to continue. +pause +goto :CONTINUE + +:MODEL_DOWNLOAD +echo. +echo Downloading latest model... +powershell -Command "Invoke-WebRequest -Uri 'https://the-eye.eu/public/AI/models/nomic-ai/gpt4all/gpt4all-lora-quantized-ggml.bin' -OutFile 'models/gpt4all-lora-quantized-ggml.bin'" +if errorlevel 1 ( + echo Failed to download model. Please check your internet connection. + choice /C YN /M "Do you want to try downloading again?" + if errorlevel 2 goto DOWNLOAD_SKIP + if errorlevel 1 goto MODEL_DOWNLOAD +) else ( + echo Model successfully downloaded. +) +goto :CONTINUE + +:DOWNLOAD_SKIP +echo. +echo Skipping download of model file... +goto :CONTINUE + :CONTINUE +echo. echo Cleaning tmp folder rd /s /q "./tmp" From 4c04802baeefd7167fc05c4c55ac6e0d6886ddbd Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 7 Apr 2023 14:00:06 +0200 Subject: [PATCH 24/34] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c5dce3d5..745e4ddc 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ ![GitHub issues](https://img.shields.io/github/issues/nomic-ai/GPT4All-ui) ![GitHub stars](https://img.shields.io/github/stars/nomic-ai/GPT4All-ui) ![GitHub forks](https://img.shields.io/github/forks/nomic-ai/GPT4All-ui) +[![Discord](https://img.shields.io/discord/1092918764925882418?color=7289da&label=Discord&logo=discord&logoColor=ffffff)](https://discord.gg/DZ4wsgg4) This is a Flask web application that provides a chat UI for interacting with the GPT4All chatbot. From 5f67166f5b0dff53d94ca9a5a45b121e26c032ba Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 7 Apr 2023 14:20:48 +0200 Subject: [PATCH 25/34] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 745e4ddc..33a1523c 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ install.bat - On linux/ Mac os ``` -./install.sh +bash ./install.sh ``` On Linux/MacOS, if you have issues, refer more details are presented [here](docs/Linux_Osx_Install.md) @@ -63,9 +63,10 @@ run.bat For simple newbies on Linux/MacOsX: ```bash -run.sh +bash run.sh ``` + if you want more control on your launch, you can activate your environment: On Windows: From d72d3347fd50465ecefda717ebe33a76dfcedb2d Mon Sep 17 00:00:00 2001 From: Nils Jannasch Date: Fri, 7 Apr 2023 17:58:26 +0200 Subject: [PATCH 26/34] Smaller changes to structure and added .github folder with pipeline --- .github/ISSUE_TEMPLATE.md | 21 +++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 25 +++++++++++++++++++++++++ .github/dependabot.yml | 7 +++++++ .github/workflow/docker.yaml | 31 +++++++++++++++++++++++++++++++ .gitignore | 1 + Change Log.md => CHANGELOG.md | 0 Dockerfile | 6 +++--- models/.keep | 0 requirements.txt | 2 +- 9 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflow/docker.yaml rename Change Log.md => CHANGELOG.md (100%) create mode 100644 models/.keep diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..dccbd597 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,21 @@ +## Expected Behavior +Please describe the behavior you are expecting. + +## Current Behavior +Please describe the behavior you are currently experiencing. + +## Steps to Reproduce +Please provide detailed steps to reproduce the issue. + +1. Step 1 +2. Step 2 +3. Step 3 + +## Possible Solution +If you have any suggestions on how to fix the issue, please describe them here. + +## Context +Please provide any additional context about the issue. + +## Screenshots +If applicable, add screenshots to help explain the issue. \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..13f4bbb8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,25 @@ +## Description +Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. + +Fixes # (issue) + +## Type of change +Please delete options that are not relevant. + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to change) + +## Checklist: +Please put an `x` in the boxes that apply. You can also fill these out after creating the PR. + +- [ ] My code follows the style guidelines of this project +- [ ] I have performed a self-review of my own code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] My changes generate no new warnings +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] I have tested this code locally, and it is working as intended +- [ ] I have updated the documentation accordingly + +## Screenshots +If applicable, add screenshots to help explain your changes. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..23c4cb3b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflow/docker.yaml b/.github/workflow/docker.yaml new file mode 100644 index 00000000..c1cdd05f --- /dev/null +++ b/.github/workflow/docker.yaml @@ -0,0 +1,31 @@ +name: Docker Build and Lint + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Build Docker Image + uses: docker/build-push-action@v2 + with: + context: . + push: false + tags: gpt4all-ui:latest + + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Run Hadolint + run: | + docker run --rm -i ghcr.io/hadolint/hadolint < Dockerfile diff --git a/.gitignore b/.gitignore index 2654392b..cf5abb12 100644 --- a/.gitignore +++ b/.gitignore @@ -136,6 +136,7 @@ dmypy.json # models models/ +!models/.keep !models/README.md # Temporary files diff --git a/Change Log.md b/CHANGELOG.md similarity index 100% rename from Change Log.md rename to CHANGELOG.md diff --git a/Dockerfile b/Dockerfile index 673bcd5f..bcb18e43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,12 @@ FROM python:3.10 WORKDIR /srv COPY ./requirements.txt . -RUN python3.10 -m venv env -RUN . env/bin/activate -RUN python3.10 -m pip install -r requirements.txt --upgrade pip +RUN python3 -m venv venv && . venv/bin/activate +RUN python3 -m pip install --no-cache-dir -r requirements.txt --upgrade pip COPY ./app.py /srv/app.py COPY ./static /srv/static COPY ./templates /srv/templates +COPY ./models /srv/models CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "4685", "--db_path", "data/database.db"] diff --git a/models/.keep b/models/.keep new file mode 100644 index 00000000..e69de29b diff --git a/requirements.txt b/requirements.txt index c02e5403..a3275191 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ flask nomic pytest -pyllamacpp \ No newline at end of file +pyllamacpp From 241b35f6ae612e38b7ac886ff22c7f50da4b1e3f Mon Sep 17 00:00:00 2001 From: Nils Jannasch Date: Fri, 7 Apr 2023 18:02:01 +0200 Subject: [PATCH 27/34] Model mounting changed --- Dockerfile | 2 +- docker-compose.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bcb18e43..091c2f1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,5 @@ COPY ./app.py /srv/app.py COPY ./static /srv/static COPY ./templates /srv/templates -COPY ./models /srv/models +# COPY ./models /srv/models # Mounting model is more efficient CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "4685", "--db_path", "data/database.db"] diff --git a/docker-compose.yml b/docker-compose.yml index 1b53de2d..6adb6220 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,5 +8,6 @@ services: volumes: - ./data:/srv/data - ./data/.nomic:/root/.nomic/ + - ./models:/srv/models ports: - "4685:4685" From 3d2fa5c46e203f79beafd05c4bacfeb20d18479b Mon Sep 17 00:00:00 2001 From: Nils Jannasch Date: Fri, 7 Apr 2023 18:03:25 +0200 Subject: [PATCH 28/34] Model mounting changed --- .github/{workflow => workflows}/docker.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/docker.yaml (100%) diff --git a/.github/workflow/docker.yaml b/.github/workflows/docker.yaml similarity index 100% rename from .github/workflow/docker.yaml rename to .github/workflows/docker.yaml From 21a81291520136b870518f99bc4890fa6a9e2dbd Mon Sep 17 00:00:00 2001 From: Nils Jannasch Date: Fri, 7 Apr 2023 18:14:03 +0200 Subject: [PATCH 29/34] Hadolint config added --- .github/workflows/docker.yaml | 2 +- .hadolint.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .hadolint.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index c1cdd05f..4874cf83 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -28,4 +28,4 @@ jobs: - name: Run Hadolint run: | - docker run --rm -i ghcr.io/hadolint/hadolint < Dockerfile + docker run --rm -i -v ./.hadolint.yaml:/.config/hadolint.yaml hadolint/hadolint < Dockerfile diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 00000000..4cdad5fc --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,2 @@ +ignored: + - SC1091 From 0ddc00420a024d24dc68e7f82bff2c1ea2a785e4 Mon Sep 17 00:00:00 2001 From: Nils Jannasch Date: Fri, 7 Apr 2023 18:16:26 +0200 Subject: [PATCH 30/34] Hadolint config added --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 4874cf83..d562c2ed 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -28,4 +28,4 @@ jobs: - name: Run Hadolint run: | - docker run --rm -i -v ./.hadolint.yaml:/.config/hadolint.yaml hadolint/hadolint < Dockerfile + docker run --rm -i -v $PWD/.hadolint.yaml:/.config/hadolint.yaml hadolint/hadolint < Dockerfile From 6209066efea01dbe64f4a7d69f4968ffae9ec5c4 Mon Sep 17 00:00:00 2001 From: Nils Jannasch Date: Fri, 7 Apr 2023 18:32:27 +0200 Subject: [PATCH 31/34] Update README for docker-compose and use same ports --- Dockerfile | 2 +- README.md | 29 ++++++++++++++++++++++++----- docker-compose.yml | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 091c2f1e..09f4f64e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,4 @@ COPY ./static /srv/static COPY ./templates /srv/templates # COPY ./models /srv/models # Mounting model is more efficient -CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "4685", "--db_path", "data/database.db"] +CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "9600", "--db_path", "data/database.db"] diff --git a/README.md b/README.md index 33a1523c..8773063a 100644 --- a/README.md +++ b/README.md @@ -33,21 +33,24 @@ To install the app, follow these steps: git clone https://github.com/nomic-ai/gpt4all-ui ``` +### Manual setup +Hint: Scroll down for docker-compose setup + 1. Navigate to the project directory: -``` +```bash cd gpt4all-ui ``` -1. Run the appropriate installation script for your platform: +2. Run the appropriate installation script for your platform: On Windows : -``` +```cmd install.bat ``` - On linux/ Mac os -``` +```bash bash ./install.sh ``` @@ -55,6 +58,7 @@ On Linux/MacOS, if you have issues, refer more details are presented [here](docs These scripts will create a Python virtual environment and install the required dependencies. It will also download the models and install them. Now you're ready to work! + ## Usage For simple newbies on Windows: ```cmd @@ -66,7 +70,6 @@ For simple newbies on Linux/MacOsX: bash run.sh ``` - if you want more control on your launch, you can activate your environment: On Windows: @@ -107,6 +110,22 @@ Once the server is running, open your web browser and navigate to http://localho Make sure to adjust the default values and descriptions of the options to match your specific application. +### Docker Compose Setup +Make sure to have the `gpt4all-lora-quantized-ggml.bin` inside the `gpt4all-lora-quantized-ggml.bin` directory. +After that you can simply use docker-compose or podman-compose to build and start the application: + +Build +```bash +docker-compose -f docker-compose.yml build +``` + +Start +```bash +docker-compose -f docker-compose.yml up +``` + +After that you can open the application in your browser on http://localhost:9600 + ## Contribute This is an open-source project by the community for the community. Our chatbot is a UI wrapper for Nomic AI's model, which enables natural language processing and machine learning capabilities. diff --git a/docker-compose.yml b/docker-compose.yml index 6adb6220..aad5f07a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,4 +10,4 @@ services: - ./data/.nomic:/root/.nomic/ - ./models:/srv/models ports: - - "4685:4685" + - "9600:9600" From 2e86cc06e0ce4c1d40d384f7693db22950a1579b Mon Sep 17 00:00:00 2001 From: N Jannasch Date: Fri, 7 Apr 2023 18:38:21 +0200 Subject: [PATCH 32/34] Apply suggestions from code review --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8773063a..2eb3a098 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Once the server is running, open your web browser and navigate to http://localho Make sure to adjust the default values and descriptions of the options to match your specific application. ### Docker Compose Setup -Make sure to have the `gpt4all-lora-quantized-ggml.bin` inside the `gpt4all-lora-quantized-ggml.bin` directory. +Make sure to have the `gpt4all-lora-quantized-ggml.bin` inside the `models` directory. After that you can simply use docker-compose or podman-compose to build and start the application: Build From 1d30feac4bc2a33aee8f713d0ad333e415154490 Mon Sep 17 00:00:00 2001 From: Nils Jannasch Date: Fri, 7 Apr 2023 18:58:42 +0200 Subject: [PATCH 33/34] Update python code (isort, black, pylint) and some manual tuning --- app.py | 391 +++++++++++++++++++++++++++++++---------------- test/test_app.py | 5 +- 2 files changed, 261 insertions(+), 135 deletions(-) diff --git a/app.py b/app.py index a9d28f96..7df4b835 100644 --- a/app.py +++ b/app.py @@ -1,129 +1,150 @@ -from flask import Flask, jsonify, request, render_template, Response, stream_with_context -from pyllamacpp.model import Model import argparse -import threading -from io import StringIO -import sys +import json import re import sqlite3 +import traceback from datetime import datetime -import sqlite3 -import json -import time -import traceback +from flask import ( + Flask, + Response, + jsonify, + render_template, + request, + stream_with_context, +) +from pyllamacpp.model import Model -import select -#=================================== Database ================================================================== +# =================================== Database ================================================================== class Discussion: - def __init__(self, discussion_id, db_path='database.db'): + def __init__(self, discussion_id, db_path="database.db"): self.discussion_id = discussion_id self.db_path = db_path @staticmethod - def create_discussion(db_path='database.db', title='untitled'): + def create_discussion(db_path="database.db", title="untitled"): with sqlite3.connect(db_path) as conn: cur = conn.cursor() cur.execute("INSERT INTO discussion (title) VALUES (?)", (title,)) discussion_id = cur.lastrowid conn.commit() return Discussion(discussion_id, db_path) - + @staticmethod - def get_discussion(db_path='database.db', id=0): - return Discussion(id, db_path) + def get_discussion(db_path="database.db", discussion_id=0): + return Discussion(discussion_id, db_path) def add_message(self, sender, content): with sqlite3.connect(self.db_path) as conn: cur = conn.cursor() - cur.execute('INSERT INTO message (sender, content, discussion_id) VALUES (?, ?, ?)', - (sender, content, self.discussion_id)) + cur.execute( + "INSERT INTO message (sender, content, discussion_id) VALUES (?, ?, ?)", + (sender, content, self.discussion_id), + ) message_id = cur.lastrowid conn.commit() return message_id + @staticmethod def get_discussions(db_path): with sqlite3.connect(db_path) as conn: cursor = conn.cursor() - cursor.execute('SELECT * FROM discussion') + cursor.execute("SELECT * FROM discussion") rows = cursor.fetchall() - return [{'id': row[0], 'title': row[1]} for row in rows] + return [{"id": row[0], "title": row[1]} for row in rows] @staticmethod def rename(db_path, discussion_id, title): with sqlite3.connect(db_path) as conn: cursor = conn.cursor() - cursor.execute('UPDATE discussion SET title=? WHERE id=?', (title, discussion_id)) + cursor.execute( + "UPDATE discussion SET title=? WHERE id=?", (title, discussion_id) + ) conn.commit() def delete_discussion(self): with sqlite3.connect(self.db_path) as conn: cur = conn.cursor() - cur.execute('DELETE FROM message WHERE discussion_id=?', (self.discussion_id,)) - cur.execute('DELETE FROM discussion WHERE id=?', (self.discussion_id,)) + cur.execute( + "DELETE FROM message WHERE discussion_id=?", (self.discussion_id,) + ) + cur.execute("DELETE FROM discussion WHERE id=?", (self.discussion_id,)) conn.commit() def get_messages(self): with sqlite3.connect(self.db_path) as conn: cur = conn.cursor() - cur.execute('SELECT * FROM message WHERE discussion_id=?', (self.discussion_id,)) + cur.execute( + "SELECT * FROM message WHERE discussion_id=?", (self.discussion_id,) + ) rows = cur.fetchall() - return [{'sender': row[1], 'content': row[2], 'id':row[0]} for row in rows] - - + return [{"sender": row[1], "content": row[2], "id": row[0]} for row in rows] def update_message(self, message_id, new_content): with sqlite3.connect(self.db_path) as conn: cur = conn.cursor() - cur.execute('UPDATE message SET content = ? WHERE id = ?', (new_content, message_id)) + cur.execute( + "UPDATE message SET content = ? WHERE id = ?", (new_content, message_id) + ) conn.commit() def remove_discussion(self): with sqlite3.connect(self.db_path) as conn: - conn.cursor().execute('DELETE FROM discussion WHERE id=?', (self.discussion_id,)) + conn.cursor().execute( + "DELETE FROM discussion WHERE id=?", (self.discussion_id,) + ) conn.commit() -def last_discussion_has_messages(db_path='database.db'): + +def last_discussion_has_messages(db_path="database.db"): with sqlite3.connect(db_path) as conn: - c = conn.cursor() - c.execute("SELECT * FROM message ORDER BY id DESC LIMIT 1") - last_message = c.fetchone() + cursor = conn.cursor() + cursor.execute("SELECT * FROM message ORDER BY id DESC LIMIT 1") + last_message = cursor.fetchone() return last_message is not None -def export_to_json(db_path='database.db'): + +def export_to_json(db_path="database.db"): with sqlite3.connect(db_path) as conn: cur = conn.cursor() - cur.execute('SELECT * FROM discussion') + cur.execute("SELECT * FROM discussion") discussions = [] for row in cur.fetchall(): discussion_id = row[0] - discussion = {'id': discussion_id, 'messages': []} - cur.execute('SELECT * FROM message WHERE discussion_id=?', (discussion_id,)) + discussion = {"id": discussion_id, "messages": []} + cur.execute("SELECT * FROM message WHERE discussion_id=?", (discussion_id,)) for message_row in cur.fetchall(): - discussion['messages'].append({'sender': message_row[1], 'content': message_row[2]}) + discussion["messages"].append( + {"sender": message_row[1], "content": message_row[2]} + ) discussions.append(discussion) return discussions -def remove_discussions(db_path='database.db'): + +def remove_discussions(db_path="database.db"): with sqlite3.connect(db_path) as conn: cur = conn.cursor() - cur.execute('DELETE FROM message') - cur.execute('DELETE FROM discussion') + cur.execute("DELETE FROM message") + cur.execute("DELETE FROM discussion") conn.commit() + # create database schema def check_discussion_db(db_path): print("Checking discussions database...") with sqlite3.connect(db_path) as conn: cur = conn.cursor() - cur.execute(''' + cur.execute( + """ CREATE TABLE IF NOT EXISTS discussion ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT ) - ''') - cur.execute(''' + """ + ) + cur.execute( + """ CREATE TABLE IF NOT EXISTS message ( id INTEGER PRIMARY KEY AUTOINCREMENT, sender TEXT NOT NULL, @@ -131,58 +152,78 @@ def check_discussion_db(db_path): discussion_id INTEGER NOT NULL, FOREIGN KEY (discussion_id) REFERENCES discussion(id) ) - ''') + """ + ) conn.commit() print("Ok") + # ======================================================================================================================== +app = Flask("GPT4All-WebUI", static_url_path="/static", static_folder="static") -app = Flask("GPT4All-WebUI", static_url_path='/static', static_folder='static') -class Gpt4AllWebUI(): - def __init__(self, chatbot_bindings, app, db_path='database.db') -> None: + +class Gpt4AllWebUI: + def __init__(self, chatbot_bindings, _app, db_path="database.db") -> None: self.current_discussion = None self.chatbot_bindings = chatbot_bindings - self.app=app - self.db_path= db_path - self.add_endpoint('/', '', self.index, methods=['GET']) - self.add_endpoint('/export', 'export', self.export, methods=['GET']) - self.add_endpoint('/new_discussion', 'new_discussion', self.new_discussion, methods=['GET']) - self.add_endpoint('/bot', 'bot', self.bot, methods=['POST']) - self.add_endpoint('/discussions', 'discussions', self.discussions, methods=['GET']) - self.add_endpoint('/rename', 'rename', self.rename, methods=['POST']) - self.add_endpoint('/get_messages', 'get_messages', self.get_messages, methods=['POST']) - self.add_endpoint('/delete_discussion', 'delete_discussion', self.delete_discussion, methods=['POST']) + self.app = _app + self.db_path = db_path + self.add_endpoint("/", "", self.index, methods=["GET"]) + self.add_endpoint("/export", "export", self.export, methods=["GET"]) + self.add_endpoint( + "/new_discussion", "new_discussion", self.new_discussion, methods=["GET"] + ) + self.add_endpoint("/bot", "bot", self.bot, methods=["POST"]) + self.add_endpoint( + "/discussions", "discussions", self.discussions, methods=["GET"] + ) + self.add_endpoint("/rename", "rename", self.rename, methods=["POST"]) + self.add_endpoint( + "/get_messages", "get_messages", self.get_messages, methods=["POST"] + ) + self.add_endpoint( + "/delete_discussion", + "delete_discussion", + self.delete_discussion, + methods=["POST"], + ) - self.add_endpoint('/update_message', 'update_message', self.update_message, methods=['GET']) - - conditionning_message=""" + self.add_endpoint( + "/update_message", "update_message", self.update_message, methods=["GET"] + ) + + conditionning_message = """ Instruction: Act as GPT4All. A kind and helpful AI bot built to help users solve problems. Start by welcoming the user then stop sending text. GPT4All:""" self.prepare_query(conditionning_message) - chatbot_bindings.generate(conditionning_message, n_predict=55, new_text_callback=self.new_text_callback, n_threads=8) - print(f"Bot said:{self.bot_says}") + chatbot_bindings.generate( + conditionning_message, + n_predict=55, + new_text_callback=self.new_text_callback, + n_threads=8, + ) + print(f"Bot said:{self.bot_says}") # Chatbot conditionning # response = self.chatbot_bindings.prompt("This is a discussion between A user and an AI. AI responds to user questions in a helpful manner. AI is not allowed to lie or deceive. AI welcomes the user\n### Response:") # print(response) def prepare_query(self, message): - self.bot_says='' - self.full_text='' - self.is_bot_text_started=False + self.bot_says = "" + self.full_text = "" + self.is_bot_text_started = False self.current_message = message - def new_text_callback(self, text: str): print(text, end="") self.full_text += text if self.is_bot_text_started: self.bot_says += text if self.current_message in self.full_text: - self.is_bot_text_started=True + self.is_bot_text_started = True def new_text_callback_with_yield(self, text: str): """ @@ -193,14 +234,24 @@ GPT4All:""" if self.is_bot_text_started: self.bot_says += text if self.current_message in self.full_text: - self.is_bot_text_started=True + self.is_bot_text_started = True yield text - def add_endpoint(self, endpoint=None, endpoint_name=None, handler=None, methods=['GET'], *args, **kwargs): - self.app.add_url_rule(endpoint, endpoint_name, handler, methods=methods, *args, **kwargs) + def add_endpoint( + self, + endpoint=None, + endpoint_name=None, + handler=None, + methods=["GET"], + *args, + **kwargs, + ): + self.app.add_url_rule( + endpoint, endpoint_name, handler, methods=methods, *args, **kwargs + ) def index(self): - return render_template('chat.html') + return render_template("chat.html") def format_message(self, message): # Look for a code block within the message @@ -220,120 +271,192 @@ GPT4All:""" @stream_with_context def parse_to_prompt_stream(self, message, message_id): - bot_says = '' - self.stop=False + bot_says = "" + self.stop = False # send the message to the bot print(f"Received message : {message}") # First we need to send the new message ID to the client - response_id = self.current_discussion.add_message("GPT4All",'') # first the content is empty, but we'll fill it at the end - yield(json.dumps({'type':'input_message_infos','message':message, 'id':message_id, 'response_id':response_id})) + response_id = self.current_discussion.add_message( + "GPT4All", "" + ) # first the content is empty, but we'll fill it at the end + yield ( + json.dumps( + { + "type": "input_message_infos", + "message": message, + "id": message_id, + "response_id": response_id, + } + ) + ) - self.current_message = "User: "+message+"\nGPT4All:" + self.current_message = "User: " + message + "\nGPT4All:" self.prepare_query(self.current_message) - chatbot_bindings.generate(self.current_message, n_predict=55, new_text_callback=self.new_text_callback, n_threads=8) + chatbot_model_bindings.generate( + self.current_message, + n_predict=55, + new_text_callback=self.new_text_callback, + n_threads=8, + ) - self.current_discussion.update_message(response_id,self.bot_says) + self.current_discussion.update_message(response_id, self.bot_says) yield self.bot_says # TODO : change this to use the yield version in order to send text word by word return "\n".join(bot_says) - + def bot(self): - self.stop=True - with sqlite3.connect(self.db_path) as conn: - try: - if self.current_discussion is None or not last_discussion_has_messages(self.db_path): - self.current_discussion=Discussion.create_discussion(self.db_path) + self.stop = True - message_id = self.current_discussion.add_message("user", request.json['message']) - message = f"{request.json['message']}" + try: + if self.current_discussion is None or not last_discussion_has_messages( + self.db_path + ): + self.current_discussion = Discussion.create_discussion(self.db_path) + + message_id = self.current_discussion.add_message( + "user", request.json["message"] + ) + message = f"{request.json['message']}" + + # Segmented (the user receives the output as it comes) + # We will first send a json entry that contains the message id and so on, then the text as it goes + return Response( + stream_with_context( + self.parse_to_prompt_stream(message, message_id) + ) + ) + except Exception as ex: + print(ex) + return ( + "Exception :" + + str(ex) + + "
" + + traceback.format_exc() + + "
Please report exception" + ) - # Segmented (the user receives the output as it comes) - # We will first send a json entry that contains the message id and so on, then the text as it goes - return Response(stream_with_context(self.parse_to_prompt_stream(message, message_id))) - except Exception as ex: - print(ex) - msg = traceback.print_exc() - return "Exception :"+str(ex)+"
"+traceback.format_exc()+"
Please report exception" - def discussions(self): try: - discussions = Discussion.get_discussions(self.db_path) + discussions = Discussion.get_discussions(self.db_path) return jsonify(discussions) except Exception as ex: print(ex) - msg = traceback.print_exc() - return "Exception :"+str(ex)+"
"+traceback.format_exc()+"
Please report exception" + return ( + "Exception :" + + str(ex) + + "
" + + traceback.format_exc() + + "
Please report exception" + ) def rename(self): data = request.get_json() - id = data['id'] - title = data['title'] - Discussion.rename(self.db_path, id, title) + discussion_id = data["id"] + title = data["title"] + Discussion.rename(self.db_path, discussion_id, title) return "renamed successfully" def get_messages(self): data = request.get_json() - id = data['id'] - self.current_discussion = Discussion(id,self.db_path) + discussion_id = data["id"] + self.current_discussion = Discussion(discussion_id, self.db_path) messages = self.current_discussion.get_messages() return jsonify(messages) - def delete_discussion(self): data = request.get_json() - id = data['id'] - self.current_discussion = Discussion(id, self.db_path) + discussion_id = data["id"] + self.current_discussion = Discussion(discussion_id, self.db_path) self.current_discussion.delete_discussion() self.current_discussion = None return jsonify({}) - + def update_message(self): try: - id = request.args.get('id') - new_message = request.args.get('message') - self.current_discussion.update_message(id, new_message) - return jsonify({"status":'ok'}) + discussion_id = request.args.get("id") + new_message = request.args.get("message") + self.current_discussion.update_message(discussion_id, new_message) + return jsonify({"status": "ok"}) except Exception as ex: print(ex) - msg = traceback.print_exc() - return "Exception :"+str(ex)+"
"+traceback.format_exc()+"
Please report exception" + return ( + "Exception :" + + str(ex) + + "
" + + traceback.format_exc() + + "
Please report exception" + ) def new_discussion(self): - title = request.args.get('title') - self.current_discussion= Discussion.create_discussion(self.db_path, title) + title = request.args.get("title") + self.current_discussion = Discussion.create_discussion(self.db_path, title) # Get the current timestamp timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # add a new discussion - self.chatbot_bindings.close() - self.chatbot_bindings.open() + # self.chatbot_bindings.close() + # self.chatbot_bindings.open() # Return a success response - return json.dumps({'id': self.current_discussion.discussion_id}) + return json.dumps({"id": self.current_discussion.discussion_id, "time": timestamp}) -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Start the chatbot Flask app.') +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Start the chatbot Flask app.") - parser.add_argument('--temp', type=float, default=0.1, help='Temperature parameter for the model.') - parser.add_argument('--n_predict', type=int, default=128, help='Number of tokens to predict at each step.') - parser.add_argument('--top_k', type=int, default=40, help='Value for the top-k sampling.') - parser.add_argument('--top_p', type=float, default=0.95, help='Value for the top-p sampling.') - parser.add_argument('--repeat_penalty', type=float, default=1.3, help='Penalty for repeated tokens.') - parser.add_argument('--repeat_last_n', type=int, default=64, help='Number of previous tokens to consider for the repeat penalty.') - parser.add_argument('--ctx_size', type=int, default=2048, help='Size of the context window for the model.') - parser.add_argument('--debug', dest='debug', action='store_true', help='launch Flask server in debug mode') - parser.add_argument('--host', type=str, default='localhost', help='the hostname to listen on') - parser.add_argument('--port', type=int, default=9600, help='the port to listen on') - parser.add_argument('--db_path', type=str, default='database.db', help='Database path') + parser.add_argument( + "--temp", type=float, default=0.1, help="Temperature parameter for the model." + ) + parser.add_argument( + "--n_predict", + type=int, + default=128, + help="Number of tokens to predict at each step.", + ) + parser.add_argument( + "--top_k", type=int, default=40, help="Value for the top-k sampling." + ) + parser.add_argument( + "--top_p", type=float, default=0.95, help="Value for the top-p sampling." + ) + parser.add_argument( + "--repeat_penalty", type=float, default=1.3, help="Penalty for repeated tokens." + ) + parser.add_argument( + "--repeat_last_n", + type=int, + default=64, + help="Number of previous tokens to consider for the repeat penalty.", + ) + parser.add_argument( + "--ctx_size", + type=int, + default=2048, + help="Size of the context window for the model.", + ) + parser.add_argument( + "--debug", + dest="debug", + action="store_true", + help="launch Flask server in debug mode", + ) + parser.add_argument( + "--host", type=str, default="localhost", help="the hostname to listen on" + ) + parser.add_argument("--port", type=int, default=9600, help="the port to listen on") + parser.add_argument( + "--db_path", type=str, default="database.db", help="Database path" + ) parser.set_defaults(debug=False) args = parser.parse_args() - chatbot_bindings = Model(ggml_model='./models/gpt4all-lora-quantized-ggml.bin', n_ctx=512) - + chatbot_model_bindings = Model( + ggml_model="./models/gpt4all-lora-quantized-ggml.bin", n_ctx=512 + ) + # Old Code # GPT4All(decoder_config = { # 'temp': args.temp, @@ -346,7 +469,7 @@ if __name__ == '__main__': # 'ctx_size': args.ctx_size # }) check_discussion_db(args.db_path) - bot = Gpt4AllWebUI(chatbot_bindings, app, args.db_path) + bot = Gpt4AllWebUI(chatbot_model_bindings, app, args.db_path) if args.debug: app.run(debug=True, host=args.host, port=args.port) diff --git a/test/test_app.py b/test/test_app.py index c02e1508..07217d35 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -1,12 +1,15 @@ import pytest + from app import app + @pytest.fixture def client(): with app.test_client() as client: yield client + def test_homepage(client): - response = client.get('/') + response = client.get("/") assert response.status_code == 200 assert b"Welcome to my Flask app" in response.data From fed181db8eb3a24303f6022397d05f4ba50e85aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Apr 2023 17:29:18 +0000 Subject: [PATCH 34/34] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index d562c2ed..5cd47d19 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build Docker Image uses: docker/build-push-action@v2 @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run Hadolint run: |