mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-02-07 11:30:15 +00:00
added uninstall option
This commit is contained in:
parent
6a9004c6d1
commit
c78255f9ea
@ -7,6 +7,7 @@
|
|||||||
# Description :
|
# Description :
|
||||||
# This is an interface class for lollms bindings.
|
# This is an interface class for lollms bindings.
|
||||||
######
|
######
|
||||||
|
from typing import Dict, Any
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from lollms.paths import LollmsPaths
|
from lollms.paths import LollmsPaths
|
||||||
@ -66,6 +67,27 @@ class LLMBinding:
|
|||||||
self.models_folder = config.lollms_paths.personal_models_path / self.binding_folder_name
|
self.models_folder = config.lollms_paths.personal_models_path / self.binding_folder_name
|
||||||
self.models_folder.mkdir(parents=True, exist_ok=True)
|
self.models_folder.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
def handle_request(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
"""
|
||||||
|
Handle client requests.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data (dict): A dictionary containing the request data.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary containing the response, including at least a "status" key.
|
||||||
|
|
||||||
|
This method should be implemented by a class that inherits from this one.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
```
|
||||||
|
handler = YourHandlerClass()
|
||||||
|
request_data = {"command": "some_command", "parameters": {...}}
|
||||||
|
response = handler.handle_request(request_data)
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
return {"status":True}
|
||||||
|
|
||||||
def print_class_attributes(self, cls):
|
def print_class_attributes(self, cls):
|
||||||
for attr in cls.__dict__:
|
for attr in cls.__dict__:
|
||||||
if isinstance(attr, property) or isinstance(attr, type):
|
if isinstance(attr, property) or isinstance(attr, type):
|
||||||
@ -151,6 +173,14 @@ class LLMBinding:
|
|||||||
ASCIIColors.red(f"Installing {self.binding_folder_name}")
|
ASCIIColors.red(f"Installing {self.binding_folder_name}")
|
||||||
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
|
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
|
||||||
|
|
||||||
|
def uninstall(self):
|
||||||
|
"""
|
||||||
|
UnInstallation procedure (to be implemented)
|
||||||
|
"""
|
||||||
|
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
|
||||||
|
ASCIIColors.red(f"UnInstalling {self.binding_folder_name}")
|
||||||
|
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
|
||||||
|
|
||||||
|
|
||||||
def get_model_path(self):
|
def get_model_path(self):
|
||||||
"""
|
"""
|
||||||
@ -301,6 +331,20 @@ class BindingBuilder:
|
|||||||
lollms_paths:LollmsPaths,
|
lollms_paths:LollmsPaths,
|
||||||
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY
|
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY
|
||||||
)->LLMBinding:
|
)->LLMBinding:
|
||||||
|
|
||||||
|
binding:LLMBinding = self.getBinding(config, lollms_paths, installation_option)
|
||||||
|
return binding(
|
||||||
|
config,
|
||||||
|
lollms_paths=lollms_paths,
|
||||||
|
installation_option = installation_option
|
||||||
|
)
|
||||||
|
|
||||||
|
def getBinding(
|
||||||
|
self,
|
||||||
|
config: LOLLMSConfig,
|
||||||
|
lollms_paths:LollmsPaths,
|
||||||
|
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY
|
||||||
|
)->LLMBinding:
|
||||||
|
|
||||||
if len(str(config.binding_name).split("/"))>1:
|
if len(str(config.binding_name).split("/"))>1:
|
||||||
binding_path = Path(config.binding_name)
|
binding_path = Path(config.binding_name)
|
||||||
@ -315,11 +359,7 @@ class BindingBuilder:
|
|||||||
loader = importlib.machinery.SourceFileLoader(module_name, str(absolute_path / "__init__.py"))
|
loader = importlib.machinery.SourceFileLoader(module_name, str(absolute_path / "__init__.py"))
|
||||||
binding_module = loader.load_module()
|
binding_module = loader.load_module()
|
||||||
binding:LLMBinding = getattr(binding_module, binding_module.binding_name)
|
binding:LLMBinding = getattr(binding_module, binding_module.binding_name)
|
||||||
return binding(
|
return binding
|
||||||
config,
|
|
||||||
lollms_paths=lollms_paths,
|
|
||||||
installation_option = installation_option
|
|
||||||
)
|
|
||||||
|
|
||||||
class ModelBuilder:
|
class ModelBuilder:
|
||||||
def __init__(self, binding:LLMBinding):
|
def __init__(self, binding:LLMBinding):
|
||||||
|
@ -21,6 +21,7 @@ from typing import Callable
|
|||||||
import json
|
import json
|
||||||
from lollms.utilities import TextVectorizer, GenericDataLoader
|
from lollms.utilities import TextVectorizer, GenericDataLoader
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from typing import Dict, Any
|
||||||
|
|
||||||
def is_package_installed(package_name):
|
def is_package_installed(package_name):
|
||||||
try:
|
try:
|
||||||
@ -1031,6 +1032,28 @@ class APScript(StateMachine):
|
|||||||
else:
|
else:
|
||||||
self.load_personality_config()
|
self.load_personality_config()
|
||||||
|
|
||||||
|
def handle_request(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
"""
|
||||||
|
Handle client requests.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data (dict): A dictionary containing the request data.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary containing the response, including at least a "status" key.
|
||||||
|
|
||||||
|
This method should be implemented by a class that inherits from this one.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
```
|
||||||
|
handler = YourHandlerClass()
|
||||||
|
request_data = {"command": "some_command", "parameters": {...}}
|
||||||
|
response = handler.handle_request(request_data)
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
return {"status":True}
|
||||||
|
|
||||||
|
|
||||||
def load_personality_config(self):
|
def load_personality_config(self):
|
||||||
"""
|
"""
|
||||||
Load the content of local_config.yaml file.
|
Load the content of local_config.yaml file.
|
||||||
|
2
setup.py
2
setup.py
@ -26,7 +26,7 @@ def get_all_files(path):
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="lollms",
|
name="lollms",
|
||||||
version="5.5.2",
|
version="5.5.3",
|
||||||
author="Saifeddine ALOUI",
|
author="Saifeddine ALOUI",
|
||||||
author_email="aloui.saifeddine@gmail.com",
|
author_email="aloui.saifeddine@gmail.com",
|
||||||
description="A python library for AI personality definition",
|
description="A python library for AI personality definition",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user