mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 12:26:29 +00:00
removed extentions
This commit is contained in:
parent
1fa9b0b37b
commit
ae9f595bd0
@ -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
|
||||
|
@ -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
|
@ -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")
|
||||
|
@ -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}")
|
||||
|
@ -30,7 +30,6 @@
|
||||
"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",
|
||||
|
@ -30,7 +30,6 @@
|
||||
"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"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user