diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 34b5be1a..48d4531f 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -18,7 +18,7 @@ jobs: with: context: . push: false - tags: gpt4all-ui:latest + tags: lollms-webui:latest lint: runs-on: ubuntu-latest diff --git a/.github/workflows/rsync.yml b/.github/workflows/rsync.yml index 523456d0..24b1db2c 100644 --- a/.github/workflows/rsync.yml +++ b/.github/workflows/rsync.yml @@ -24,7 +24,7 @@ jobs: id: sync uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 with: - upstream_sync_repo: ParisNeo/Gpt4All-ui + upstream_sync_repo: ParisNeo/lollms-webui upstream_sync_branch: main target_sync_branch: main target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 190879af..274cfe3c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to GPT4All-ui +# Contributing to lollms-webui Thank you for your interest in contributing to [Your Repository Name]! We appreciate your efforts to help make our project better. @@ -30,4 +30,4 @@ To submit a contribution, please follow these steps: Once your pull request is approved, your changes will be merged into the main repository. -Thank you for your contributions to GPT4All-ui! +Thank you for your contributions to lollms-webui! diff --git a/README.md b/README.md index 4a49df35..6c88157b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # 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) +![GitHub license](https://img.shields.io/github/license/nomic-ai/lollms-webui) +![GitHub issues](https://img.shields.io/github/issues/nomic-ai/lollms-webui) +![GitHub stars](https://img.shields.io/github/stars/nomic-ai/lollms-webui) +![GitHub forks](https://img.shields.io/github/forks/nomic-ai/lollms-webui) [![Discord](https://img.shields.io/discord/1092918764925882418?color=7289da&label=Discord&logo=discord&logoColor=ffffff)](https://discord.gg/4rR282WJb6) [![Follow me on Twitter](https://img.shields.io/twitter/follow/SpaceNerduino?style=social)](https://twitter.com/SpaceNerduino) [![Follow Me on YouTube](https://img.shields.io/badge/Follow%20Me%20on-YouTube-red?style=flat&logo=youtube)](https://www.youtube.com/user/Parisneo) @@ -58,8 +58,8 @@ If you use conda, you can create a virtual environment and install the required First clone the project or download the zip file and unzip it: ```bash -git clone https://github.com/ParisNeo/gpt4all-ui.git -cd gpt4all-ui +git clone https://github.com/ParisNeo/lollms-webui.git +cd lollms-webui ``` Now create a new conda environment, activate it and install requirements @@ -100,7 +100,7 @@ Once the app is running, you can go to the application front link displayed in t Contributions to GPT4ALL WebUI are welcome! If you encounter any issues, have ideas for improvements, or want to contribute code, please open an issue or submit a pull request on the GitHub repository. # License -This project is licensed under the Apache 2.0 License. You are free to use this software commercially, build upon it, and integrate it into your own projects. See the [LICENSE](https://github.com/ParisNeo/GPT4All-ui/blob/main/LICENSE) file for details. +This project is licensed under the Apache 2.0 License. You are free to use this software commercially, build upon it, and integrate it into your own projects. See the [LICENSE](https://github.com/ParisNeo/lollms-webui/blob/main/LICENSE) file for details. # Acknowledgements Please note that GPT4ALL WebUI is not affiliated with the GPT4All application developed by Nomic AI. The latter is a separate professional application available at gpt4all.io, which has its own unique features and community. diff --git a/api/__init__.py b/api/__init__.py index 0e76319b..5e6e2154 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -1,14 +1,15 @@ ###### -# Project : GPT4ALL-UI +# Project : lollms-webui # File : api.py # Author : ParisNeo with the help of the community # Supported by Nomic-AI # license : Apache 2.0 # Description : -# A simple api to communicate with gpt4all-ui and its models. +# A simple api to communicate with lollms-webui and its models. ###### from datetime import datetime from api.db import DiscussionsDB +from api.helpers import compare_lists from pathlib import Path import importlib from lollms import AIPersonality, lollms_path, MSG_TYPE @@ -22,7 +23,7 @@ import traceback import sys __author__ = "parisneo" -__github__ = "https://github.com/ParisNeo/gpt4all-ui" +__github__ = "https://github.com/ParisNeo/lollms-webui" __copyright__ = "Copyright 2023, " __license__ = "Apache 2.0" @@ -110,7 +111,7 @@ class ModelProcess: 'status': 'succeeded', 'binding_status':True, 'model_status':True, - 'personality_status':True, + 'personalities_status':True, 'errors':[] } @@ -245,44 +246,58 @@ class ModelProcess: self._set_config_result['binding_status'] ='failed' self._set_config_result['errors'].append(f"couldn't build binding:{ex}") - def rebuild_personality(self): - try: - personality = self.config['personalities'][self.config['default_personality_id']] - print(f" ******************* Building Personality {personality} from main Process *************************") - personality_path = lollms_path/f"personalities_zoo/{personality}" - personality = AIPersonality(personality_path, run_scripts=False) - print(f" ************ Personality {personality.name} is ready (Main process) ***************************") - except Exception as ex: - print(f"Personality file not found or is corrupted ({personality_path}).\nPlease verify that the personality you have selected exists or select another personality. Some updates may lead to change in personality name or category, so check the personality selection in settings to be sure.") - if self.config["debug"]: - print(ex) - personality = AIPersonality() + def rebuild_personalities(self): + mounted_personalities=[] + print(f" ******************* Building mounted Personalities from main Process *************************") + for personality in self.config['personalities']: + try: + print(f" {personality}") + personality_path = lollms_path/f"personalities_zoo/{personality}" + personality = AIPersonality(personality_path, run_scripts=False) + mounted_personalities.append(personality) + except Exception as ex: + print(f"Personality file not found or is corrupted ({personality_path}).\nPlease verify that the personality you have selected exists or select another personality. Some updates may lead to change in personality name or category, so check the personality selection in settings to be sure.") + if self.config["debug"]: + print(ex) + personality = AIPersonality() - return personality + print(f" ************ Personalities mounted (Main process) ***************************") + + return mounted_personalities - def _rebuild_personality(self): - try: - self.reset_config_result() - personality = self.config['personalities'][self.config['default_personality_id']] - print(f" ******************* Building Personality {personality} from generation Process *************************") - personality_path = lollms_path/f"personalities_zoo/{personality}" - self.personality = AIPersonality(personality_path) - print(f" ************ Personality {self.personality.name} is ready (generation process) ***************************") - except Exception as ex: - print(f"Personality file not found or is corrupted ({personality_path}).") - print(f"Please verify that the personality you have selected exists or select another personality. Some updates may lead to change in personality name or category, so check the personality selection in settings to be sure.") - print(f"Exception: {ex}") - if self.config["debug"]: - print(ex) - self.personality = AIPersonality() + def _rebuild_personalities(self): + self.mounted_personalities=[] + failed_personalities=[] + self.reset_config_result() + print(f" ******************* Building mounted Personalities from generation Process *************************") + for personality in self.config['personalities']: + try: + print(f" {personality}") + personality_path = lollms_path/f"personalities_zoo/{personality}" + personality = AIPersonality(personality_path, run_scripts=True) + self.mounted_personalities.append(personality) + except Exception as ex: + print(f"Personality file not found or is corrupted ({personality_path}).\nPlease verify that the personality you have selected exists or select another personality. Some updates may lead to change in personality name or category, so check the personality selection in settings to be sure.") + if self.config["debug"]: + print(ex) + personality = AIPersonality() + failed_personalities.append(personality_path) + self._set_config_result['errors'].append(f"couldn't build personalities:{ex}") + + print(f" ************ Personalities mounted (Generation process) ***************************") + if len(failed_personalities)==len(self.config['personalities']): self._set_config_result['status'] ='failed' - self._set_config_result['binding_status'] ='failed' - self._set_config_result['errors'].append(f"couldn't build binding:{ex}") - + self._set_config_result['personalities_status'] ='failed' + elif len(failed_personalities)>0: + self._set_config_result['status'] ='semi_failed' + self._set_config_result['personalities_status'] ='semi_failed' + + self.personality = self.mounted_personalities[self.config['active_personality_id']] + print("Personality set successfully") def _run(self): self._rebuild_model() - self._rebuild_personality() + self._rebuild_personalities() self.check_set_config_thread = threading.Thread(target=self._check_set_config_queue, args=()) print("Launching config verification thread") self.check_set_config_thread.start() @@ -438,8 +453,9 @@ class ModelProcess: self._rebuild_model() # verify that the personality is the same - if self.config["personalities"][-1]!=bk_cfg["personalities"][-1]: - self._rebuild_personality() + + if not compare_lists(self.config["personalities"], bk_cfg["personalities"]): + self._rebuild_personalities() class LoLLMsAPPI(): @@ -450,7 +466,8 @@ class LoLLMsAPPI(): self.config = config self.binding = self.process.rebuild_binding(self.config) - self.personality = self.process.rebuild_personality() + self.personalities = self.process.rebuild_personalities() + self.personality = self.personalities[self.config["active_personality_id"]] if config["debug"]: print(print(f"{self.personality}")) self.config_file_path = config_file_path diff --git a/api/binding.py b/api/binding.py index dee9cabd..d97ee0a1 100644 --- a/api/binding.py +++ b/api/binding.py @@ -1,11 +1,11 @@ ###### -# Project : GPT4ALL-UI +# Project : lollms-webui # File : binding.py # Author : ParisNeo with the help of the community # Supported by Nomic-AI # license : Apache 2.0 # Description : -# This is an interface class for GPT4All-ui bindings. +# This is an interface class for lollms-webui bindings. ###### from pathlib import Path from typing import Callable @@ -14,7 +14,7 @@ import yaml import sys __author__ = "parisneo" -__github__ = "https://github.com/ParisNeo/gpt4all-ui" +__github__ = "https://github.com/ParisNeo/lollms-webui" __copyright__ = "Copyright 2023, " __license__ = "Apache 2.0" diff --git a/api/config.py b/api/config.py index bc1c0e97..41876fe7 100644 --- a/api/config.py +++ b/api/config.py @@ -1,5 +1,5 @@ ###### -# Project : GPT4ALL-UI +# Project : lollms-webui # File : config.py # Author : ParisNeo with the help of the community # Supported by Nomic-AI @@ -12,7 +12,7 @@ import yaml __author__ = "parisneo" -__github__ = "https://github.com/ParisNeo/gpt4all-ui" +__github__ = "https://github.com/ParisNeo/lollms-webui" __copyright__ = "Copyright 2023, " __license__ = "Apache 2.0" diff --git a/api/db.py b/api/db.py index 767aef85..bfe99e53 100644 --- a/api/db.py +++ b/api/db.py @@ -2,7 +2,7 @@ import sqlite3 __author__ = "parisneo" -__github__ = "https://github.com/ParisNeo/gpt4all-ui" +__github__ = "https://github.com/ParisNeo/lollms-webui" __copyright__ = "Copyright 2023, " __license__ = "Apache 2.0" diff --git a/api/extension.py b/api/extension.py index b30904d0..525cc7a8 100644 --- a/api/extension.py +++ b/api/extension.py @@ -6,7 +6,7 @@ from config import load_config, save_config __author__ = "parisneo" -__github__ = "https://github.com/ParisNeo/gpt4all-ui" +__github__ = "https://github.com/ParisNeo/lollms-webui" __copyright__ = "Copyright 2023, " __license__ = "Apache 2.0" diff --git a/api/helpers.py b/api/helpers.py new file mode 100644 index 00000000..9982cffd --- /dev/null +++ b/api/helpers.py @@ -0,0 +1,11 @@ + +__author__ = "parisneo" +__github__ = "https://github.com/ParisNeo/lollms-webui" +__copyright__ = "Copyright 2023, " +__license__ = "Apache 2.0" + +def compare_lists(list1, list2): + if len(list1) != len(list2): + return False + else: + return list1 == list2 diff --git a/app.py b/app.py index 6fa7751d..f09a3a54 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ ###### -# Project : GPT4ALL-UI +# Project : lollms-webui # Author : ParisNeo with the help of the community # Supported by Nomic-AI # license : Apache 2.0 @@ -10,7 +10,7 @@ ###### __author__ = "parisneo" -__github__ = "https://github.com/ParisNeo/gpt4all-ui" +__github__ = "https://github.com/ParisNeo/lollms-webui" __copyright__ = "Copyright 2023, " __license__ = "Apache 2.0" @@ -25,7 +25,9 @@ from tqdm import tqdm import subprocess import signal from lollms import AIPersonality, lollms_path, MSG_TYPE +from lollms.console import ASCIIColors from api.db import DiscussionsDB, Discussion +from api.helpers import compare_lists from flask import ( Flask, Response, @@ -77,9 +79,9 @@ class LoLLMsWebUI(LoLLMsAPPI): app.template_folder = "web/dist" - self.personality_language= config["personalities"][config["default_personality_id"]].split("/")[0] - self.personality_category= config["personalities"][config["default_personality_id"]].split("/")[1] - self.personality_name= config["personalities"][config["default_personality_id"]].split("/")[2] + self.personality_language= config["personalities"][config["active_personality_id"]].split("/")[0] + self.personality_category= config["personalities"][config["active_personality_id"]].split("/")[1] + self.personality_name= config["personalities"][config["active_personality_id"]].split("/")[2] # ========================================================================================= # Endpoints @@ -87,6 +89,9 @@ class LoLLMsWebUI(LoLLMsAPPI): self.add_endpoint("/add_reference_to_local_model", "add_reference_to_local_model", self.add_reference_to_local_model, methods=["POST"]) self.add_endpoint("/send_file", "send_file", self.send_file, methods=["POST"]) + self.add_endpoint("/mount_personality", "mount_personality", self.mount_personality, methods=["POST"]) + self.add_endpoint("/unmount_personality", "unmount_personality", self.unmount_personality, methods=["POST"]) + self.add_endpoint("/select_personality", "select_personality", self.select_personality, methods=["POST"]) self.add_endpoint( @@ -669,6 +674,51 @@ class LoLLMsWebUI(LoLLMsAPPI): else: return jsonify({"status": True}) + + def mount_personality(self): + language = request.files['language'] + category = request.files['category'] + name = request.files['name'] + + package_path = f"{language}/{category}/{name}" + package_full_path = lollms_path/"personalities_zoo"/package_path + config_file = package_full_path / "config.yaml" + if not config_file.exists(): + self.config["personalities"].append() + self.personalities = self.process.rebuild_personalities() + self.personality = self.personalities[self.config["active_personality_id"]] + self.apply_settings() + return jsonify({"status": True}) + else: + return jsonify({"status": False, "error":"Personality not found"}) + + def unmount_personality(self): + language = request.files['language'] + category = request.files['category'] + name = request.files['name'] + try: + index = self.config["personalities"].index(f"{language}/{category}/{name}") + self.config["personalities"].remove(f"{language}/{category}/{name}") + if self.config["active_personality_id"]>=index: + self.config["active_personality_id"]=0 + self.personalities = self.process.rebuild_personalities() + self.personality = self.personalities[self.config["active_personality_id"]] + self.apply_settings() + return jsonify({"status": True}) + except: + return jsonify({"status": False, "error":"Couldn't unmount personality"}) + + def select_personality(self): + id = request.files['id'] + if id **Note** > -> This command creates new directory `/gpt4all-ui/` in your /home/ direcory, downloads a file [webui.sh](https://raw.githubusercontent.com/nomic-ai/gpt4all-ui/main/webui.sh), makes file executable and executes webui.sh that downloads and installs everything that is needed. +> This command creates new directory `/lollms-webui/` in your /home/ direcory, downloads a file [webui.sh](https://raw.githubusercontent.com/nomic-ai/lollms-webui/main/webui.sh), makes file executable and executes webui.sh that downloads and installs everything that is needed. 3. Follow instructions on screen until it launches webui. 4. To relaunch application: @@ -87,10 +87,10 @@ sudo pacman -S curl git python3 2. Clone repository: ```bash -git clone https://github.com/ParisNeo/gpt4all-ui.git +git clone https://github.com/ParisNeo/lollms-webui.git ``` ```bash -cd gpt4all-ui +cd lollms-webui ``` 3. Install/run application: @@ -116,10 +116,10 @@ brew install git python3 3. Clone repository: ```bash -git clone https://github.com/ParisNeo/gpt4all-ui.git +git clone https://github.com/ParisNeo/lollms-webui.git ``` ```bash -cd gpt4all-ui +cd lollms-webui ``` 4. Install/run application: diff --git a/docs/youtube/script_install.md b/docs/youtube/script_install.md index b7ee43c6..e743cd24 100644 --- a/docs/youtube/script_install.md +++ b/docs/youtube/script_install.md @@ -21,7 +21,7 @@ Before installing this tool you need to install python 3.10 or higher as well as Now let's cut to the chace. Let's start by installing the tool. -First, go to the github repository page at github.com/ParisNeo/gpt4all-ui then press the latest release button. Depending on your platform download webui.bat for windows or webui.sh for linux. +First, go to the github repository page at github.com/ParisNeo/lollms-webui then press the latest release button. Depending on your platform download webui.bat for windows or webui.sh for linux. We call this file, the application launcher. Make sure you install the launcher in a folder you choose. For example I'll put it in my ai folder at gpt4all-webui. diff --git a/package-lock.json b/package-lock.json index 88757d23..9906a6cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "gpt4all-ui", + "name": "lollms-webui", "lockfileVersion": 3, "requires": true, "packages": {} diff --git a/setup.py b/setup.py index 97b21113..79c2a941 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setuptools.setup( description="A web ui for running chat models with different bindings. Supports multiple personalities and extensions.", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/ParisNeo/gpt4all-ui", + url="https://github.com/ParisNeo/lollms-webui", packages=setuptools.find_packages(), install_requires=requirements, extras_require={"dev": requirements_dev}, diff --git a/static/js/websocket.js b/static/js/websocket.js index 024aa160..e3130342 100644 --- a/static/js/websocket.js +++ b/static/js/websocket.js @@ -1,4 +1,4 @@ -// Project : GPT4ALL-ui +// Project : lollms-webui // Author : ParisNeo // Description : // All websocket stuff can be found here. diff --git a/templates/help.html b/templates/help.html index 86794715..1e63e36c 100644 --- a/templates/help.html +++ b/templates/help.html @@ -4,7 +4,7 @@ - Help | GPT4All-ui + Help | lollms-webui @@ -17,7 +17,7 @@