From 339160812acc3eefe7fb23e718d8030acf856aac Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Thu, 19 Oct 2023 02:30:09 +0200 Subject: [PATCH] fixed model install --- lollms/binding.py | 14 +++++++++++++- lollms/main_config.py | 16 +++++++++++++--- setup.py | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lollms/binding.py b/lollms/binding.py index b300e88..dde80fe 100644 --- a/lollms/binding.py +++ b/lollms/binding.py @@ -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: diff --git a/lollms/main_config.py b/lollms/main_config.py index 0dfa2ea..1943ca9 100644 --- a/lollms/main_config.py +++ b/lollms/main_config.py @@ -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 diff --git a/setup.py b/setup.py index 053afad..9c4cc8c 100644 --- a/setup.py +++ b/setup.py @@ -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",