From ae9f595bd0bf4df34cdf585438fb79be349dbf32 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 8 Dec 2024 23:24:44 +0100 Subject: [PATCH] removed extentions --- lollms/app.py | 1 - lollms/extension.py | 110 --------- lollms/paths.py | 12 - .../endpoints/lollms_binding_files_server.py | 20 -- notebooks/lollms_discord.ipynb | 221 +++++++++--------- notebooks/lollms_service.ipynb | 129 +++++----- scripts/linux/linux_install.sh | 2 - scripts/macos/macos_install.sh | 2 - scripts/windows/win_install.bat | 2 - 9 files changed, 174 insertions(+), 325 deletions(-) delete mode 100644 lollms/extension.py diff --git a/lollms/app.py b/lollms/app.py index 5192a81..7fe3bec 100644 --- a/lollms/app.py +++ b/lollms/app.py @@ -3,7 +3,6 @@ from lollms.paths import LollmsPaths from lollms.personality import PersonalityBuilder, AIPersonality from lollms.binding import LLMBinding, BindingBuilder, ModelBuilder from lollms.databases.discussions_database import Message -from lollms.extension import LOLLMSExtension, ExtensionBuilder from lollms.config import InstallOption from lollms.helpers import ASCIIColors, trace_exception from lollms.com import NotificationType, NotificationDisplayType, LoLLMsCom diff --git a/lollms/extension.py b/lollms/extension.py deleted file mode 100644 index 90b1308..0000000 --- a/lollms/extension.py +++ /dev/null @@ -1,110 +0,0 @@ -# File : extension.py -# Author : ParisNeo -# Description : -# This is the main class to be imported by the extension -# it gives your code access to the model, the callback functions, the model conditionning etc -from ascii_colors import ASCIIColors - -from lollms.config import InstallOption, TypedConfig, BaseConfig, ConfigTemplate -from lollms.paths import LollmsPaths -from enum import Enum -from pathlib import Path -import importlib - - -__author__ = "parisneo" -__github__ = "https://github.com/ParisNeo/lollms-webui" -__copyright__ = "Copyright 2023, " -__license__ = "Apache 2.0" - - -class EXTENSION_TYPE(Enum): - EXTENSION_TYPE_STAND_ALONE = 0 # An extension that has access to the current personality and model but has an independant - - -class LOLLMSExtension(): - def __init__(self, - name:str, - script_path:str|Path, - config:TypedConfig, - app, - installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY) -> None: - self.name = name - self.app = app - self.config = config - self.script_path = script_path - self.category = str(script_path).replace("\\","/").split("/")[-2] - self.extension_folder_name = str(script_path).replace("\\","/").split("/")[-1] - self.card = self.script_path /"card.yaml" - - self.configuration_path = app.lollms_paths.personal_configuration_path/"extensions"/f"{name}" - self.configuration_path.mkdir(parents=True, exist_ok=True) - self.configuration_path= self.configuration_path/"config.yaml" - - self.installation_option = installation_option - # Installation - if (not self.configuration_path.exists() or self.installation_option==InstallOption.FORCE_INSTALL) and self.installation_option!=InstallOption.NEVER_INSTALL: - self.install() - self.config.save(self.configuration_path) - - - def build_extension(self): - return self - - def install(self): - """ - Installation procedure (to be implemented) - """ - ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*") - ASCIIColors.red(f"Installing {self.name}") - ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*") - - - def pre_gen(self, previous_prompt:str, prompt:str): - return previous_prompt, prompt - - def in_gen(self, chunk:str)->str: - return chunk - - def post_gen(self, ai_output:str): - pass - - - def get_ui(): - """ - Get user interface of the extension - """ - return "

This is a ui extension template

" - - - -class ExtensionBuilder: - def build_extension( - self, - extension_path:str, - lollms_paths:LollmsPaths, - app, - installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY - )->LOLLMSExtension: - - extension, script_path = self.getExtension(extension_path, lollms_paths, app) - return extension(app = app, installation_option = installation_option) - - def getExtension( - self, - extension_path:str, - lollms_paths:LollmsPaths, - app - )->LOLLMSExtension: - - extension_path = lollms_paths.extensions_zoo_path / extension_path - - # define the full absolute path to the module - absolute_path = extension_path.resolve() - # infer the module name from the file path - module_name = extension_path.stem - # use importlib to load the module from the file path - loader = importlib.machinery.SourceFileLoader(module_name, str(absolute_path / "__init__.py")) - extension_module = loader.load_module() - extension:LOLLMSExtension = getattr(extension_module, extension_module.extension_name) - return extension, absolute_path \ No newline at end of file diff --git a/lollms/paths.py b/lollms/paths.py index 6db3348..7023d91 100644 --- a/lollms/paths.py +++ b/lollms/paths.py @@ -10,14 +10,12 @@ lollms_path = Path(__file__).parent lollms_default_cfg_path = lollms_path / "configs/config.yaml" lollms_bindings_zoo_path = lollms_path / "zoos/bindings_zoo" lollms_personalities_zoo_path = lollms_path / "zoos/personalities_zoo" -lollms_extensions_zoo_path = lollms_path / "zoos/extensions_zoo" lollms_core_repo = "https://github.com/ParisNeo/lollms.git" safe_store_repo = "https://github.com/ParisNeo/safe_store.git" personalities_zoo_repo = "https://github.com/ParisNeo/lollms_personalities_zoo.git" bindings_zoo_repo = "https://github.com/ParisNeo/lollms_bindings_zoo.git" -extensions_zoo_repo = "https://github.com/ParisNeo/lollms_extensions_zoo.git" models_zoo_repo = "https://github.com/ParisNeo/models_zoo.git" gptqlora_repo = "https://github.com/ParisNeo/gptqlora.git" @@ -103,7 +101,6 @@ class LollmsPaths: rt.mkdir(parents=True, exist_ok=True) self.bindings_zoo_path = rt / "bindings_zoo" self.personalities_zoo_path = rt / "personalities_zoo" - self.extensions_zoo_path = rt / "extensions_zoo" self.models_zoo_path = rt / "models_zoo" else: ASCIIColors.orange("local zoos folder not found") @@ -111,7 +108,6 @@ class LollmsPaths: rt.mkdir(parents=True, exist_ok=True) self.bindings_zoo_path = rt / "bindings_zoo" self.personalities_zoo_path = rt / "personalities_zoo" - self.extensions_zoo_path = rt / "extensions_zoo" self.models_zoo_path = rt / "models_zoo" ASCIIColors.green("----------------------Paths information-----------------------") @@ -168,8 +164,6 @@ class LollmsPaths: ASCIIColors.yellow(f"{self.bindings_zoo_path}") ASCIIColors.red("personalities_zoo_path:",end="") ASCIIColors.yellow(f"{self.personalities_zoo_path}") - ASCIIColors.red("extensions_zoo_path:",end="") - ASCIIColors.yellow(f"{self.extensions_zoo_path}") ASCIIColors.red("models_zoo_path:",end="") ASCIIColors.yellow(f"{self.models_zoo_path}") ASCIIColors.green("-------------------------------------------------------------") @@ -191,7 +185,6 @@ class LollmsPaths: "Personal outputs Path": self.personal_outputs_path, "Bindings Zoo Path": self.bindings_zoo_path, "Personalities Zoo Path": self.personalities_zoo_path, - "Extensions zoo path": self.extensions_zoo_path, "Personal user infos path": self.personal_user_infos_path, "Personal trainers path": self.personal_trainers_path, "Personal gptqlora trainer path": self.gptqlora_path, @@ -244,11 +237,6 @@ class LollmsPaths: ASCIIColors.info("No personalities found in your personal space.\nCloning the personalities zoo") subprocess.run(["git", "clone", personalities_zoo_repo, self.personalities_zoo_path]) - if not self.extensions_zoo_path.exists(): - # Clone the repository to the target path - ASCIIColors.info("No extensions found in your personal space.\nCloning the extensions zoo") - subprocess.run(["git", "clone", extensions_zoo_repo, self.extensions_zoo_path]) - if not self.models_zoo_path.exists(): # Clone the repository to the target path ASCIIColors.info("No models found in your personal space.\nCloning the models zoo") diff --git a/lollms/server/endpoints/lollms_binding_files_server.py b/lollms/server/endpoints/lollms_binding_files_server.py index eb7fa06..d5cbd83 100644 --- a/lollms/server/endpoints/lollms_binding_files_server.py +++ b/lollms/server/endpoints/lollms_binding_files_server.py @@ -92,26 +92,6 @@ async def serve_personalities(path: str): return FileResponse(str(file_path)) -@router.get("/extensions/{path:path}") -async def serve_extensions(path: str): - """ - Serve personalities file. - - Args: - path (str): The path of the extensions file to serve. - - Returns: - FileResponse: The file response containing the requested extensions file. - """ - path = sanitize_path_from_endpoint(path) - - file_path = lollmsElfServer.lollms_paths.extensions_zoo_path / path - - if not Path(file_path).exists(): - raise HTTPException(status_code=400, detail="File not found") - - return FileResponse(str(file_path)) - # ----------------------------------- Services ----------------------------------------- @router.get("/audio/{path:path}") diff --git a/notebooks/lollms_discord.ipynb b/notebooks/lollms_discord.ipynb index 9ab9316..423eee1 100644 --- a/notebooks/lollms_discord.ipynb +++ b/notebooks/lollms_discord.ipynb @@ -1,116 +1,115 @@ { - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "Lm1ahQJs7lMk", - "outputId": "f486f019-ff7e-4971-ab2d-53eddf47cdec" - }, - "outputs": [], - "source": [ - "!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n", - "!pip install lollms --upgrade" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "YP6kXgau8Wej", - "outputId": "3c7196be-4ce1-4314-f0a0-7738e13eb957" - }, - "outputs": [], - "source": [ - "!mkdir zoos\n", - "!git clone https://github.com/ParisNeo/lollms_bindings_zoo.git zoos/bindings_zoo\n", - "!git clone https://github.com/ParisNeo/lollms_extensions_zoo.git zoos/extensions_zoo\n", - "!git clone https://github.com/ParisNeo/models_zoo.git zoos/models_zoo\n", - "!git clone https://github.com/ParisNeo/lollms_personalities_zoo.git zoos/personalities_zoo\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "DSsf2L1kPc0K", - "outputId": "fe6dc4d1-c652-46bf-ed6e-9c4dfb80dc82" - }, - "outputs": [], - "source": [ - "!lollms-settings --silent --tool_prefix lollms_discord_ --set_personal_folder_path ./personal_data --install_binding hugging_face --install_model TheBloke/Airoboros-L2-13B-3.1.1-GPTQ" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "R3IOhe7KJZQT", - "outputId": "95022a48-2e25-479f-aef7-e20f9c3ed1f9" - }, - "outputs": [], - "source": [ - "!pip install discord.py" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "x1oO7C_v8oTI", - "outputId": "cdca280b-d8bc-4d18-de80-86e4a4637b41" - }, - "outputs": [], - "source": [ - "!lollms-discord" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "fbPrg7RH-Ui8", - "outputId": "1b82968d-06c6-4a73-8a28-67e8f7619099" - }, - "outputs": [], - "source": [ - "!ip addr show" - ] - } - ], - "metadata": { - "accelerator": "GPU", + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { "colab": { - "provenance": [] + "base_uri": "https://localhost:8080/" }, - "kernelspec": { - "display_name": "Python 3", - "name": "python3" - }, - "language_info": { - "name": "python" - } + "id": "Lm1ahQJs7lMk", + "outputId": "f486f019-ff7e-4971-ab2d-53eddf47cdec" + }, + "outputs": [], + "source": [ + "!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n", + "!pip install lollms --upgrade" + ] }, - "nbformat": 4, - "nbformat_minor": 0 + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "YP6kXgau8Wej", + "outputId": "3c7196be-4ce1-4314-f0a0-7738e13eb957" + }, + "outputs": [], + "source": [ + "!mkdir zoos\n", + "!git clone https://github.com/ParisNeo/lollms_bindings_zoo.git zoos/bindings_zoo\n", + "!git clone https://github.com/ParisNeo/models_zoo.git zoos/models_zoo\n", + "!git clone https://github.com/ParisNeo/lollms_personalities_zoo.git zoos/personalities_zoo\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "DSsf2L1kPc0K", + "outputId": "fe6dc4d1-c652-46bf-ed6e-9c4dfb80dc82" + }, + "outputs": [], + "source": [ + "!lollms-settings --silent --tool_prefix lollms_discord_ --set_personal_folder_path ./personal_data --install_binding hugging_face --install_model TheBloke/Airoboros-L2-13B-3.1.1-GPTQ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "R3IOhe7KJZQT", + "outputId": "95022a48-2e25-479f-aef7-e20f9c3ed1f9" + }, + "outputs": [], + "source": [ + "!pip install discord.py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "x1oO7C_v8oTI", + "outputId": "cdca280b-d8bc-4d18-de80-86e4a4637b41" + }, + "outputs": [], + "source": [ + "!lollms-discord" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "fbPrg7RH-Ui8", + "outputId": "1b82968d-06c6-4a73-8a28-67e8f7619099" + }, + "outputs": [], + "source": [ + "!ip addr show" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 } diff --git a/notebooks/lollms_service.ipynb b/notebooks/lollms_service.ipynb index 5dd5a78..4e383b1 100644 --- a/notebooks/lollms_service.ipynb +++ b/notebooks/lollms_service.ipynb @@ -1,70 +1,69 @@ { - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "Lm1ahQJs7lMk", - "outputId": "0af9d0e2-2385-4123-b2ca-4f82ae29b374" - }, - "outputs": [], - "source": [ - "!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n", - "!pip install lollms --upgrade" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "YP6kXgau8Wej", - "outputId": "4a9492f9-4843-4e56-9cd1-7e031b337a30" - }, - "outputs": [], - "source": [ - "!mkdir zoos\n", - "!git clone https://github.com/ParisNeo/lollms_bindings_zoo.git zoos/bindings_zoo\n", - "!git clone https://github.com/ParisNeo/lollms_extensions_zoo.git zoos/extensions_zoo\n", - "!git clone https://github.com/ParisNeo/models_zoo.git zoos/models_zoo\n", - "!git clone https://github.com/ParisNeo/lollms_personalities_zoo.git zoos/personalities_zoo\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "DSsf2L1kPc0K", - "outputId": "5a7c6af4-99f0-4c6f-a1cc-cb174b968879" - }, - "outputs": [], - "source": [ - "!lollms-settings --silent --set_personal_folder_path ./personal_data --install_binding exllama2 --install_model TheBloke/Airoboros-L2-13B-3.1.1-GPTQ" - ] - } - ], - "metadata": { - "accelerator": "GPU", + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { "colab": { - "provenance": [] + "base_uri": "https://localhost:8080/" }, - "kernelspec": { - "display_name": "Python 3", - "name": "python3" - }, - "language_info": { - "name": "python" - } + "id": "Lm1ahQJs7lMk", + "outputId": "0af9d0e2-2385-4123-b2ca-4f82ae29b374" + }, + "outputs": [], + "source": [ + "!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n", + "!pip install lollms --upgrade" + ] }, - "nbformat": 4, - "nbformat_minor": 0 + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "YP6kXgau8Wej", + "outputId": "4a9492f9-4843-4e56-9cd1-7e031b337a30" + }, + "outputs": [], + "source": [ + "!mkdir zoos\n", + "!git clone https://github.com/ParisNeo/lollms_bindings_zoo.git zoos/bindings_zoo\n", + "!git clone https://github.com/ParisNeo/models_zoo.git zoos/models_zoo\n", + "!git clone https://github.com/ParisNeo/lollms_personalities_zoo.git zoos/personalities_zoo\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "DSsf2L1kPc0K", + "outputId": "5a7c6af4-99f0-4c6f-a1cc-cb174b968879" + }, + "outputs": [], + "source": [ + "!lollms-settings --silent --set_personal_folder_path ./personal_data --install_binding exllama2 --install_model TheBloke/Airoboros-L2-13B-3.1.1-GPTQ" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 } diff --git a/scripts/linux/linux_install.sh b/scripts/linux/linux_install.sh index dcb717c..ceeed4a 100644 --- a/scripts/linux/linux_install.sh +++ b/scripts/linux/linux_install.sh @@ -134,8 +134,6 @@ cd zoos/bindings_zoo git checkout main cd ../personalities_zoo git checkout main -cd ../extensions_zoo -git checkout main cd ../models_zoo git checkout main diff --git a/scripts/macos/macos_install.sh b/scripts/macos/macos_install.sh index 4ba9ba9..2b82ee4 100644 --- a/scripts/macos/macos_install.sh +++ b/scripts/macos/macos_install.sh @@ -126,8 +126,6 @@ cd zoos/bindings_zoo git checkout main cd ../personalities_zoo git checkout main -cd ../extensions_zoo -git checkout main cd ../models_zoo git checkout main diff --git a/scripts/windows/win_install.bat b/scripts/windows/win_install.bat index 093b07d..638ab17 100644 --- a/scripts/windows/win_install.bat +++ b/scripts/windows/win_install.bat @@ -123,8 +123,6 @@ cd zoos/bindings_zoo git checkout main cd ../personalities_zoo git checkout main -cd ../extensions_zoo -git checkout main cd ../models_zoo git checkout main