diff --git a/lollms/apps/train/__init__.py b/lollms/apps/train/__init__.py new file mode 100644 index 0000000..7ee53cb --- /dev/null +++ b/lollms/apps/train/__init__.py @@ -0,0 +1,68 @@ +from lollms.config import InstallOption +from lollms.binding import BindingBuilder, ModelBuilder +from lollms.personality import MSG_TYPE, PersonalityBuilder +from lollms.main_config import LOLLMSConfig +from lollms.helpers import ASCIIColors +from lollms.paths import LollmsPaths +from lollms.app import LollmsApplication +from lollms.terminal import MainMenu + +from typing import Callable +from pathlib import Path +import argparse +import yaml +import time +import sys + + +class Trainer(LollmsApplication): + def __init__( + self, + configuration_path:str|Path=None, + show_logo:bool=True, + show_time_elapsed:bool = False + ): + # Fore it to be a path + self.configuration_path = configuration_path + self.is_logging = False + self.log_file_path = "" + self.show_time_elapsed = show_time_elapsed + self.bot_says = "" + + # get paths + lollms_paths = LollmsPaths.find_paths(force_local=False, tool_prefix="lollms_server_") + + # Configuration loading part + config = LOLLMSConfig.autoload(lollms_paths, configuration_path) + + super().__init__("lollms-console",config, lollms_paths) + + if show_logo: + self.menu.show_logo() + + def start_training(self): + print(self.model) + +def main(): + # Create the argument parser + parser = argparse.ArgumentParser(description='App Description') + + # Add the configuration path argument + parser.add_argument('--configuration_path', default=None, + help='Path to the configuration file') + + # Parse the command-line arguments + args = parser.parse_args() + + + # Parse the command-line arguments + args = parser.parse_args() + + configuration_path = args.configuration_path + + lollms_app = Trainer(configuration_path=configuration_path) + lollms_app.start_training() + + +if __name__ == "__main__": + main() diff --git a/lollms/terminal.py b/lollms/terminal.py index 6fcb2ef..c894891 100644 --- a/lollms/terminal.py +++ b/lollms/terminal.py @@ -226,20 +226,21 @@ class MainMenu(Menu): print(f"{ASCIIColors.color_green}Current binding: {ASCIIColors.color_reset}{self.lollms_app.config['binding_name']}") for p in self.lollms_app.lollms_paths.bindings_zoo_path.iterdir(): if p.is_dir() and not p.stem.startswith("."): - with open(p/"binding_card.yaml", "r") as f: - card = yaml.safe_load(f) - with open(p/"models.yaml", "r") as f: - models = yaml.safe_load(f) - is_installed = (self.lollms_app.lollms_paths.personal_configuration_path/f"binding_{p.name}.yaml").exists() - entry=f"{ASCIIColors.color_green if is_installed else ''}{'*' if self.lollms_app.config['binding_name']==card['name'] else ''} {card['name']} (by {card['author']})" - bindings_list.append(entry) - entry={ - "name":p.name, - "card":card, - "models":models, - "installed": is_installed - } - self.binding_infs.append(entry) + if (p/"binding_card.yaml").exists(): + with open(p/"binding_card.yaml", "r") as f: + card = yaml.safe_load(f) + with open(p/"models.yaml", "r") as f: + models = yaml.safe_load(f) + is_installed = (self.lollms_app.lollms_paths.personal_configuration_path/f"binding_{p.name}.yaml").exists() + entry=f"{ASCIIColors.color_green if is_installed else ''}{'*' if self.lollms_app.config['binding_name']==card['name'] else ''} {card['name']} (by {card['author']})" + bindings_list.append(entry) + entry={ + "name":p.name, + "card":card, + "models":models, + "installed": is_installed + } + self.binding_infs.append(entry) bindings_list += ["Back"] choice = self.show_menu(bindings_list) if 1 <= choice <= len(bindings_list)-1: