diff --git a/lollms/binding.py b/lollms/binding.py index 430480d..6bd1c0d 100644 --- a/lollms/binding.py +++ b/lollms/binding.py @@ -173,19 +173,8 @@ class LLMBinding: """ return " ".join(tokens_list) - - # To implement by children - # @staticmethod - # def get_available_models(): - - -# =============================== - -class BindingInstaller: - def __init__(self, config: LOLLMSConfig) -> None: - self.config = config - - def reinstall_pytorch_with_cuda(self): + @staticmethod + def reinstall_pytorch_with_cuda(): result = subprocess.run(["pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir", "--index-url", "https://download.pytorch.org/whl/cu117"]) if result.returncode != 0: ASCIIColors.warning("Couldn't find Cuda build tools on your PC. Reverting to CPU.") @@ -196,6 +185,13 @@ class BindingInstaller: ASCIIColors.error("Pytorch installed successfully!!") + # To implement by children + # @staticmethod + # def get_available_models(): + + +# =============================== + class BindingBuilder: def build_binding( self, diff --git a/lollms/bindings_zoo b/lollms/bindings_zoo index 721fdce..df051a4 160000 --- a/lollms/bindings_zoo +++ b/lollms/bindings_zoo @@ -1 +1 @@ -Subproject commit 721fdce27c00950364db64677bffc621907b791a +Subproject commit df051a448c04579eb0cc8470691e43a50bbc3a8c diff --git a/lollms/personalities_zoo b/lollms/personalities_zoo index 25f8e84..8201e8a 160000 --- a/lollms/personalities_zoo +++ b/lollms/personalities_zoo @@ -1 +1 @@ -Subproject commit 25f8e84618c5a46c2bb7cb6fbb6817b53ef86c2d +Subproject commit 8201e8a413c0522499f226083f5982687894cadc diff --git a/lollms/server.py b/lollms/server.py index 6eb98c7..3e35bbc 100644 --- a/lollms/server.py +++ b/lollms/server.py @@ -100,12 +100,12 @@ class LoLLMsServer: if self.config.binding_name is None: self.menu.select_binding() else: - self.binding = self.build_binding(self.bindings_path, self.config) + self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths) if self.config.model_name is None: self.menu.select_model() else: try: - self.active_model = self.binding(self.config) + self.active_model = self.binding.build_model() except Exception as ex: print(f"{ASCIIColors.color_red}Couldn't load model Please select a valid model{ASCIIColors.color_reset}") print(f"{ASCIIColors.color_red}{ex}{ASCIIColors.color_reset}") @@ -151,17 +151,18 @@ class LoLLMsServer: # cfg.download_model(url) else: try: - self.binding = BindingBuilder().build_binding(self.lollms_paths.bindings_zoo_path, self.config) + self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths) except Exception as ex: print(ex) print(f"Couldn't find binding. Please verify your configuration file at {self.config.file_path} or use the next menu to select a valid binding") print(f"Trying to reinstall binding") - self.binding = BindingBuilder().build_binding(self.lollms_paths.bindings_zoo_path, self.config,force_reinstall=True) + self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.FORCE_INSTALL) self.menu.select_binding() def load_model(self): try: self.model = ModelBuilder(self.binding).get_model() + ASCIIColors.success("Model loaded successfully") except Exception as ex: ASCIIColors.error(f"Couldn't load model.") ASCIIColors.error(f"Binding returned this exception : {ex}") @@ -367,7 +368,7 @@ class LoLLMsServer: self.cp_config = copy.deepcopy(self.config) self.cp_config["model_name"] = data['model_name'] try: - self.active_model = self.binding(self.cp_config) + self.active_model = self.binding.build_model() emit('select_model', {'success':True, 'model_name': model_name}, room=request.sid) except Exception as ex: print(ex) diff --git a/setup.py b/setup.py index 50fc025..bee1b09 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.0.0", + version="2.0.3", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition",