mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-24 06:46:40 +00:00
upgraded
This commit is contained in:
parent
606430e9be
commit
e08a9166fb
@ -185,7 +185,7 @@ class LoLLMsServer(LollmsApplication):
|
||||
server_infos["system_disk_total_space"]=drive_disk_usage.total
|
||||
server_infos["system_disk_available_space"]=drive_disk_usage.free
|
||||
try:
|
||||
models_folder_disk_usage = psutil.disk_usage(str(self.lollms_paths.personal_models_path/f'{self.config["binding_name"]}'))
|
||||
models_folder_disk_usage = psutil.disk_usage(str(self.lollms_paths.binding_models_paths[0]))
|
||||
server_infos["binding_disk_total_space"]=models_folder_disk_usage.total
|
||||
server_infos["binding_disk_available_space"]=models_folder_disk_usage.free
|
||||
|
||||
|
@ -58,7 +58,8 @@ class LLMBinding:
|
||||
binding_config:TypedConfig,
|
||||
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY,
|
||||
supported_file_extensions='*.bin',
|
||||
binding_type:BindingType=BindingType.TEXT_ONLY
|
||||
binding_type:BindingType=BindingType.TEXT_ONLY,
|
||||
models_dir_names:list=None
|
||||
) -> None:
|
||||
|
||||
self.binding_type = binding_type
|
||||
@ -82,8 +83,15 @@ class LLMBinding:
|
||||
else:
|
||||
self.load_binding_config()
|
||||
|
||||
self.models_folder = config.lollms_paths.personal_models_path / self.binding_folder_name
|
||||
self.models_folder.mkdir(parents=True, exist_ok=True)
|
||||
if models_dir_names is not None:
|
||||
config.lollms_paths.binding_models_paths=[config.lollms_paths.personal_models_path / models_dir_name for models_dir_name in models_dir_names]
|
||||
self.models_folders = config.lollms_paths.binding_models_paths
|
||||
self.models_dir_names = models_dir_names
|
||||
else:
|
||||
self.models_folders = [config.lollms_paths.personal_models_path / self.binding_folder_name]
|
||||
self.models_dir_names = [self.binding_folder_name]
|
||||
for models_folder in self.models_folders:
|
||||
models_folder.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def handle_request(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
@ -199,6 +207,15 @@ class LLMBinding:
|
||||
ASCIIColors.red(f"UnInstalling {self.binding_folder_name}")
|
||||
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
|
||||
|
||||
def searchModelPath(self, model_name:str):
|
||||
model_path=None
|
||||
for mn in self.models_folders:
|
||||
if mn.name in model_name.lower():
|
||||
model_path = mn/model_name
|
||||
break
|
||||
if model_path is None:
|
||||
model_path = self.models_folders[0]/model_name
|
||||
return model_path
|
||||
|
||||
def get_model_path(self):
|
||||
"""
|
||||
@ -215,15 +232,15 @@ class LLMBinding:
|
||||
|
||||
if self.config.model_name.endswith(".reference"):
|
||||
ASCIIColors.yellow("Loading a reference model:")
|
||||
file_path = self.lollms_paths.personal_models_path / f"{self.binding_folder_name}/{self.config.model_name}"
|
||||
if file_path.exists():
|
||||
with open(str(file_path), 'r') as f:
|
||||
ref_path = self.searchModelPath(self.config.model_name)
|
||||
if ref_path.exists():
|
||||
with open(str(ref_path), 'r') as f:
|
||||
model_path = Path(f.read())
|
||||
ASCIIColors.yellow(model_path)
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
model_path = Path(self.lollms_paths.personal_models_path / f"{self.binding_folder_name}/{self.config.model_name}")
|
||||
model_path = self.searchModelPath(self.config.model_name)
|
||||
|
||||
return model_path
|
||||
|
||||
@ -317,11 +334,29 @@ class LLMBinding:
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def list_models(self, config:dict):
|
||||
"""Lists the models for this binding
|
||||
"""
|
||||
models_dir = self.lollms_paths.personal_models_path/config["binding_name"] # replace with the actual path to the models folder
|
||||
return [f.name for f in models_dir.iterdir() if f.suffix in self.supported_file_extensions or f.suffix==".reference"]
|
||||
models = []
|
||||
for models_folder in self.models_folders:
|
||||
if models_folder in ["ggml","gguf"]:
|
||||
models+=[f.name for f in models_folder.iterdir() if f.suffix in self.supported_file_extensions or f.suffix==".reference"]
|
||||
else:
|
||||
models+=[f.name for f in models_folder.iterdir() if f.is_dir() and not f.stem.startswith(".") or f.suffix==".reference"]
|
||||
return models
|
||||
|
||||
def get_available_models(self):
|
||||
# Create the file path relative to the child class's directory
|
||||
full_data = []
|
||||
for models_dir_name in self.models_dir_names:
|
||||
file_path = self.lollms_paths.models_zoo_path/f"{models_dir_name}.yaml"
|
||||
with open(file_path, 'r') as file:
|
||||
yaml_data = yaml.safe_load(file)
|
||||
full_data+=yaml_data
|
||||
|
||||
return full_data
|
||||
|
||||
|
||||
@staticmethod
|
||||
def reinstall_pytorch_with_cuda():
|
||||
@ -378,9 +413,6 @@ class LLMBinding:
|
||||
ASCIIColors.red("Cuda VRAM usage")
|
||||
ASCIIColors.red("*-*-*-*-*-*-*-*")
|
||||
print(LLMBinding.vram_usage())
|
||||
# To implement by children
|
||||
# @staticmethod
|
||||
# def get_available_models():
|
||||
|
||||
|
||||
# ===============================
|
||||
|
@ -141,8 +141,8 @@ class LOLLMSConfig(BaseConfig):
|
||||
return False
|
||||
|
||||
def download_model(self, url, binding, callback = None):
|
||||
folder_path = self.lollms_paths.personal_models_path/self.binding_name
|
||||
model_name = url.split("/")[-1]
|
||||
folder_path = binding.config.searchModelPath(model_name)
|
||||
model_full_path = (folder_path / model_name)
|
||||
if binding is not None and hasattr(binding,'download_model'):
|
||||
binding.download_model(url, model_full_path, callback)
|
||||
|
@ -49,16 +49,20 @@ class LollmsPaths:
|
||||
self.personal_trainers_path = self.personal_path / "trainers"
|
||||
self.gptqlora_path = self.personal_trainers_path / "gptqlora"
|
||||
|
||||
self.binding_models_paths = []
|
||||
|
||||
self.execution_path = Path(os.getcwd())
|
||||
if (self.execution_path/"zoos").exists():
|
||||
self.bindings_zoo_path = self.execution_path/"zoos" / "bindings_zoo"
|
||||
self.personalities_zoo_path = self.execution_path/"zoos" / "personalities_zoo"
|
||||
self.extensions_zoo_path = self.execution_path/"zoos" / "extensions_zoo"
|
||||
self.models_zoo_path = self.execution_path/"zoos" / "models_zoo"
|
||||
else:
|
||||
|
||||
self.bindings_zoo_path = self.personal_path / "bindings_zoo"
|
||||
self.personalities_zoo_path = self.personal_path / "personalities_zoo"
|
||||
self.extensions_zoo_path = self.personal_path / "extensions_zoo"
|
||||
self.models_zoo_path = self.execution_path/ "models_zoo"
|
||||
|
||||
ASCIIColors.green("----------------------Paths information-----------------------")
|
||||
ASCIIColors.yellow("personal_path:",end="")
|
||||
|
2
setup.py
2
setup.py
@ -26,7 +26,7 @@ def get_all_files(path):
|
||||
|
||||
setuptools.setup(
|
||||
name="lollms",
|
||||
version="5.7.9",
|
||||
version="5.8.2",
|
||||
author="Saifeddine ALOUI",
|
||||
author_email="aloui.saifeddine@gmail.com",
|
||||
description="A python library for AI personality definition",
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a330474b0be8ac89a08c5e7e4617f602f86eba7b
|
||||
Subproject commit 7bcff9612f874f6c516ecca65c70ea177683b68c
|
@ -1 +1 @@
|
||||
Subproject commit 1c761a8a894ebcfb2fc4083daff105347a9d54b9
|
||||
Subproject commit d49695c67a89c6d707ba5a838986c3330b25d8a3
|
@ -1 +1 @@
|
||||
Subproject commit 423a06157188c12a420f4e3f35e0a5793917a91e
|
||||
Subproject commit ecec471d269ff305b7fb1700d506ce8a63ba53cd
|
Loading…
Reference in New Issue
Block a user