removed extentions

This commit is contained in:
Saifeddine ALOUI 2024-12-08 23:24:44 +01:00
parent 1fa9b0b37b
commit ae9f595bd0
9 changed files with 174 additions and 325 deletions

View File

@ -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

View File

@ -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 "<p>This is a ui extension template</p>"
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

View File

@ -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")

View File

@ -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}")

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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