__author__ = "ParisNeo" __github__ = "https://github.com/ParisNeo/lollms" __copyright__ = "Copyright 2023, " __license__ = "Apache 2.0" from ascii_colors import ASCIIColors from lollms.paths import LollmsPaths from lollms.config import BaseConfig #from lollms.binding import LLMBinding import shutil import urllib.request as rq from tqdm import tqdm from pathlib import Path import sys DEFAULT_CONFIG = { # =================== Lord Of Large Language Models Configuration file =========================== "version": 5, "binding_name": "llama_cpp_official", "model_name": "Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin", # Host information "host": "localhost", "port": 9600, # Genreration parameters "seed": -1, "n_predict": 1024, "ctx_size": 2048, "temperature": 0.9, "top_k": 50, "top_p": 0.95, "repeat_last_n": 40, "repeat_penalty": 1.2, "n_threads": 8, #Personality parameters "personalities": ["generic/lollms"], "active_personality_id": 0, "override_personality_model_parameters": False, #if true the personality parameters are overriden by those of the configuration (may affect personality behaviour) "user_name": "user", } class LOLLMSConfig(BaseConfig): def __init__(self, file_path=None, lollms_paths:LollmsPaths = None): super().__init__(["file_path", "config", "lollms_paths"]) if file_path: self.file_path = Path(file_path) else: self.file_path = None if file_path is not None: self.load_config(file_path) else: self.config = DEFAULT_CONFIG.copy() if lollms_paths is None: self.lollms_paths = LollmsPaths() else: self.lollms_paths = lollms_paths def copy(self): cfg = LOLLMSConfig(self.file_path, self.lollms_paths) cfg.config = self.config.copy() return cfg @staticmethod def autoload(lollms_paths:LollmsPaths, config_path:str=None): # Configuration loading part original_cfg_path = lollms_paths.default_cfg_path if config_path is None: local = lollms_paths.personal_configuration_path / f"{lollms_paths.tool_prefix}local_config.yaml" if not local.exists(): shutil.copy(original_cfg_path, local) cfg_path = local else: cfg_path = config_path if cfg_path.exists(): original_config = LOLLMSConfig(original_cfg_path, lollms_paths) config = LOLLMSConfig(cfg_path, lollms_paths) if "version" not in config or int(config["version"])