fixed model install

This commit is contained in:
Saifeddine ALOUI 2023-10-19 02:30:09 +02:00
parent f6eb8c3672
commit 339160812a
3 changed files with 27 additions and 5 deletions

View File

@ -88,7 +88,8 @@ class LLMBinding:
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]
config.lollms_paths.binding_models_paths= [config.lollms_paths.personal_models_path / self.binding_folder_name]
self.models_folders = config.lollms_paths.binding_models_paths
self.models_dir_names = [self.binding_folder_name]
for models_folder in self.models_folders:
models_folder.mkdir(parents=True, exist_ok=True)
@ -207,6 +208,17 @@ class LLMBinding:
ASCIIColors.red(f"UnInstalling {self.binding_folder_name}")
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
def searchModelParentFolder(self, model_name:str):
model_path=None
for mn in self.models_folders:
if mn.name in model_name.lower():
model_path = mn
break
if model_path is None:
model_path = self.models_folders[0]
return model_path
def searchModelPath(self, model_name:str):
model_path=None
for mn in self.models_folders:

View File

@ -139,10 +139,20 @@ class LOLLMSConfig(BaseConfig):
except Exception as ex:
print(f"Exception in checking model existance: {ex}")
return False
def searchModelPath(self, model_name:str):
model_path=None
for mn in self.lollms_paths.binding_models_paths:
if mn.name in model_name.lower():
model_path = mn/model_name
break
if model_path is None:
model_path = self.lollms_paths.binding_models_paths[0]/model_name
return model_path
def download_model(self, url, binding, callback = None):
model_name = url.split("/")[-1]
folder_path = binding.config.searchModelPath(model_name)
folder_path = self.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)
@ -169,8 +179,8 @@ class LOLLMSConfig(BaseConfig):
def reference_model(self, path):
path = str(path).replace("\\","/")
folder_path = self.lollms_paths.personal_models_path/self.binding_name
model_name = path.split("/")[-1]+".reference"
folder_path = self.searchModelPath(model_name)
model_full_path = (folder_path / model_name)
# Check if file already exists in folder

View File

@ -26,7 +26,7 @@ def get_all_files(path):
setuptools.setup(
name="lollms",
version="5.8.2",
version="5.8.3",
author="Saifeddine ALOUI",
author_email="aloui.saifeddine@gmail.com",
description="A python library for AI personality definition",