diff --git a/lollms/console.py b/lollms/console.py index 9a823ac..69e66c6 100644 --- a/lollms/console.py +++ b/lollms/console.py @@ -52,6 +52,12 @@ class MainMenu: print(f" {ASCIIColors.color_red}├{ASCIIColors.color_reset} stop_log: stops logging the discussion to a text file") print(f" {ASCIIColors.color_red}├{ASCIIColors.color_reset} send_file: uploads a file to the AI") print(f" {ASCIIColors.color_red}└{ASCIIColors.color_reset} exit: exists the console") + + if self.conversation.personality.help !="": + print(f"Personality help:") + print(f"{self.conversation.personality.help}") + + def show_menu(self, options): print("Menu:") @@ -204,7 +210,8 @@ class MainMenu: print(f"{ASCIIColors.color_green}5 -{ASCIIColors.color_reset} Reinstall current Personality") print(f"{ASCIIColors.color_green}6 -{ASCIIColors.color_reset} Reset all installs") print(f"{ASCIIColors.color_green}0 -{ASCIIColors.color_reset} Back to app") - print(f"{ASCIIColors.color_green}-1 -{ASCIIColors.color_reset} Exit app") + print(f"{ASCIIColors.color_green}-1 -{ASCIIColors.color_reset} Help") + print(f"{ASCIIColors.color_green}-2 -{ASCIIColors.color_reset} Exit app") choice = input("Enter your choice: ").strip() if choice == "1": self.select_binding() @@ -223,9 +230,10 @@ class MainMenu: print("Back to main app...") break elif choice == "-1": - sys.exit(0) + self.show_commands_list() + elif choice == "-2": print("Bye") - break + sys.exit(0) else: print("Invalid choice! Try again.") @@ -301,7 +309,7 @@ class Conversation: print(f"{ASCIIColors.color_reset}") if show_welcome_message and self.personality.welcome_message: - print(self.personality.name+": ", end="") + ASCIIColors.red(self.personality.name+": ", end="") print(self.personality.welcome_message) def ask_override_file(self): diff --git a/lollms/helpers.py b/lollms/helpers.py index b5819b0..93fd47d 100644 --- a/lollms/helpers.py +++ b/lollms/helpers.py @@ -30,24 +30,49 @@ class ASCIIColors: color_bright_orange = '\u001b[38;5;208m' @staticmethod - def print(text, color=color_bright_red): - print(f"{color}{text}{ASCIIColors.color_reset}") + def print(text, color=color_bright_red, end="\n", flush=False): + print(f"{color}{text}{ASCIIColors.color_reset}", end=end, flush=flush) @staticmethod - def warning(text): - print(f"{ASCIIColors.color_bright_orange}{text}{ASCIIColors.color_reset}") + def warning(text, end="\n", flush=False): + print(f"{ASCIIColors.color_bright_orange}{text}{ASCIIColors.color_reset}", end=end, flush=flush) @staticmethod - def error(text): - print(f"{ASCIIColors.color_bright_red}{text}{ASCIIColors.color_reset}") + def error(text, end="\n", flush=False): + print(f"{ASCIIColors.color_bright_red}{text}{ASCIIColors.color_reset}", end=end, flush=flush) @staticmethod - def success(text): - print(f"{ASCIIColors.color_green}{text}{ASCIIColors.color_reset}") + def success(text, end="\n", flush=False): + print(f"{ASCIIColors.color_green}{text}{ASCIIColors.color_reset}", end=end, flush=flush) @staticmethod - def info(text): - print(f"{ASCIIColors.color_blue}{text}{ASCIIColors.color_reset}") + def info(text, end="\n", flush=False): + print(f"{ASCIIColors.color_blue}{text}{ASCIIColors.color_reset}", end=end, flush=flush) + + @staticmethod + def red(text, end="\n", flush=False): + print(f"{ASCIIColors.color_red}{text}{ASCIIColors.color_reset}", end=end, flush=flush) + @staticmethod + def green(text, end="\n", flush=False): + print(f"{ASCIIColors.color_green}{text}{ASCIIColors.color_reset}", end=end, flush=flush) + + @staticmethod + def blue(text, end="\n", flush=False): + print(f"{ASCIIColors.color_blue}{text}{ASCIIColors.color_reset}", end=end, flush=flush) + + @staticmethod + def yellow(text, end="\n", flush=False): + print(f"{ASCIIColors.color_yellow}{text}{ASCIIColors.color_reset}", end=end, flush=flush) + + @staticmethod + def magenta(text, end="\n", flush=False): + print(f"{ASCIIColors.color_magenta}{text}{ASCIIColors.color_reset}", end=end, flush=flush) + + @staticmethod + def cyan(text, end="\n", flush=False): + print(f"{ASCIIColors.color_cyan}{text}{ASCIIColors.color_reset}", end=end, flush=flush) + + class BaseConfig(): def __init__(self, exceptional_keys=[], config = None): diff --git a/lollms/personality.py b/lollms/personality.py index 2dcfd13..a26f315 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -329,7 +329,7 @@ Date: {{date}} # Disclaimer self._disclaimer: str = "" - + self._help: str = "" # Default model parameters self._model_temperature: float = 0.8 # higher: more creative, lower more deterministic @@ -421,6 +421,7 @@ Date: {{date}} self._anti_prompts = config.get("anti_prompts", self._anti_prompts) self._dependencies = config.get("dependencies", self._dependencies) self._disclaimer = config.get("disclaimer", self._disclaimer) + self._help = config.get("help", self._help) self._model_temperature = config.get("model_temperature", self._model_temperature) self._model_n_predicts = config.get("model_n_predicts", self._model_n_predicts) self._model_top_k = config.get("model_top_k", self._model_top_k) @@ -529,6 +530,7 @@ Date: {{date}} "anti_prompts": self._anti_prompts, "dependencies": self._dependencies, "disclaimer": self._disclaimer, + "help": self._help, "model_temperature": self._model_temperature, "model_n_predicts": self._model_n_predicts, "model_top_k": self._model_top_k, @@ -567,6 +569,7 @@ Date: {{date}} "anti_prompts": self._anti_prompts, "dependencies": self._dependencies, "disclaimer": self._disclaimer, + "help": self._help, "model_temperature": self._model_temperature, "model_n_predicts": self._model_n_predicts, "model_top_k": self._model_top_k, @@ -846,6 +849,25 @@ Date: {{date}} """ self._disclaimer = disclaimer + @property + def help(self) -> str: + """Getter method for the help attribute. + + Returns: + str: The help text. + """ + return self._help + + @help.setter + def help(self, help: str): + """Setter method for the help attribute. + + Args: + help (str): The help text. + """ + self._help = help + + @property def model_temperature(self) -> float: """Get the model's temperature.""" diff --git a/setup.py b/setup.py index fa1067e..29d18a5 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="1.1.76", + version="1.1.78", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition",