From 2fbc5ac426794e95517f71f9bcd2b7c40d3f3425 Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 15 Jun 2023 12:14:17 +0200 Subject: [PATCH] upgraded configurations --- lollms/binding.py | 2 ++ lollms/configs/config.yaml | 2 +- lollms/console.py | 5 +++- lollms/paths.py | 50 ++++++++++++++++++++------------------ 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/lollms/binding.py b/lollms/binding.py index 0f60dcb..82b0456 100644 --- a/lollms/binding.py +++ b/lollms/binding.py @@ -79,6 +79,7 @@ class LOLLMSConfig(BaseConfig): self.lollms_paths = LollmsPaths() else: self.lollms_paths = lollms_paths + @staticmethod def autoload(lollms_paths, config_path:str=None): @@ -103,6 +104,7 @@ class LOLLMSConfig(BaseConfig): config.save_config(cfg_path) else: config = LOLLMSConfig() + return config def sync_cfg(self, default_config): diff --git a/lollms/configs/config.yaml b/lollms/configs/config.yaml index 15925b9..f41777c 100644 --- a/lollms/configs/config.yaml +++ b/lollms/configs/config.yaml @@ -1,6 +1,6 @@ # =================== Lord Of Large Language Models Configuration file =========================== version: 6 -binding_name: llama_cpp_official +binding_name: c_transformers model_name: null # Host information diff --git a/lollms/console.py b/lollms/console.py index 3e58efb..025636c 100644 --- a/lollms/console.py +++ b/lollms/console.py @@ -265,6 +265,9 @@ class Conversation: # Configuration loading part self.config = LOLLMSConfig.autoload(self.lollms_paths, configuration_path) + + if self.config.model_name is None: + self.menu.select_model(self) # load binding @@ -332,7 +335,7 @@ class Conversation: if Path(file_name).is_absolute(): self.log_file_path = Path(file_name) else: - home_dir = Path.home()/"Documents/lollms/logs" + home_dir = self.lollms_paths.personal_log_path home_dir.mkdir(parents=True, exist_ok=True) self.log_file_path = home_dir/file_name if self.log_file_path.exists(): diff --git a/lollms/paths.py b/lollms/paths.py index 1e059c6..3055da1 100644 --- a/lollms/paths.py +++ b/lollms/paths.py @@ -34,6 +34,7 @@ class LollmsPaths: self.personal_databases_path = personal_path / "databases" self.personal_models_path = personal_path / "models" self.personal_personalities_path = lollms_path / "personalities" + self.personal_log_path = lollms_path / "logs" self.create_directories() @@ -49,7 +50,7 @@ class LollmsPaths: self.personal_data_path.mkdir(parents=True, exist_ok=True) self.personal_databases_path.mkdir(parents=True, exist_ok=True) self.personal_personalities_path.mkdir(parents=True, exist_ok=True) - + self.personal_log_path.mkdir(parents=True, exist_ok=True) def copy_default_config(self): local_config_path = self.personal_configuration_path / "local_config.yaml" @@ -100,30 +101,33 @@ class LollmsPaths: print(f"To make it clear where your data are stored, we now give the user the choice where to put its data.") print(f"This allows you to mutualize models which are heavy, between multiple lollms compatible apps.") print(f"You can change this at any tome using the lollms-update_path script or by simply change the content of the global_paths_cfg.yaml file.") - print(f"Please provide a folder to store your configurations files, your models and your personal data (database, custom personalities etc).") - cfg = BaseConfig(config={ - "lollms_path":str(Path(__file__).parent), - "lollms_personal_path":str(Path.home()/"Documents/lollms") - }) + found = False + while not found: + print(f"Please provide a folder to store your configurations files, your models and your personal data (database, custom personalities etc).") + cfg = BaseConfig(config={ + "lollms_path":str(Path(__file__).parent), + "lollms_personal_path":str(Path.home()/"Documents/lollms") + }) - cfg.lollms_personal_path = input(f"Folder path: ({cfg.lollms_personal_path}):") - if cfg.lollms_personal_path=="": - cfg.lollms_personal_path = str(Path.home()/"Documents/lollms") + cfg.lollms_personal_path = input(f"Folder path: ({cfg.lollms_personal_path}):") + if cfg.lollms_personal_path=="": + cfg.lollms_personal_path = str(Path.home()/"Documents/lollms") - print(f"Selected: {cfg.lollms_personal_path}") - pp= Path(cfg.lollms_personal_path) - if not pp.exists(): - try: - pp.mkdir(parents=True) - except: - print(f"{ASCIIColors.color_red}It seams there is an error in the path you rovided{ASCIIColors.color_reset}") - return None - if force_local: - global_paths_cfg = Path("./global_paths_cfg.yaml") - else: - global_paths_cfg = lollms_path/"global_paths_cfg.yaml" - cfg.save_config(global_paths_cfg) - + print(f"Selected: {cfg.lollms_personal_path}") + pp= Path(cfg.lollms_personal_path) + if not pp.exists(): + try: + pp.mkdir(parents=True) + except: + print(f"{ASCIIColors.color_red}It seams there is an error in the path you rovided{ASCIIColors.color_reset}") + continue + if force_local: + global_paths_cfg = Path("./global_paths_cfg.yaml") + else: + global_paths_cfg = lollms_path/"global_paths_cfg.yaml" + cfg.save_config(global_paths_cfg) + found = True + return LollmsPaths(cfg.lollms_path, cfg.lollms_personal_path, custom_default_cfg_path=custom_default_cfg_path)