diff --git a/lollms/config.py b/lollms/config.py index 22be9d2..eeebb39 100644 --- a/lollms/config.py +++ b/lollms/config.py @@ -446,8 +446,6 @@ class TypedConfig: Raises: ValueError: If no configuration is loaded. """ - if key == "exceptional_keys": - return super().__getattribute__(key) if key in ["config","config_template"] or key.startswith("__"): return super().__getattribute__(key) else: @@ -455,6 +453,27 @@ class TypedConfig: raise ValueError("No configuration loaded.") return self.config[key] + def __setattr__(self, key, value): + """ + Retrieves the configuration entry with the specified key as an attribute. + + Args: + key (str): The name of the configuration entry. + + Returns: + dict: The configuration entry with the specified key, or None if not found. + + Raises: + ValueError: If no configuration is loaded. + """ + if key in ["config","config_template"] or key.startswith("__"): + super().__setattr__(key, value) + else: + if self.config is None: + raise ValueError("No configuration loaded.") + self.config[key] = value + self.sync() + def __getitem__(self, key): """ @@ -472,6 +491,24 @@ class TypedConfig: if self.config is None: raise ValueError("No configuration loaded.") return self.config[key] + + def __setitem__(self, key, value): + """ + Retrieves the configuration entry with the specified key as an attribute. + + Args: + key (str): The name of the configuration entry. + + Returns: + dict: The configuration entry with the specified key, or None if not found. + + Raises: + ValueError: If no configuration is loaded. + """ + if self.config is None: + raise ValueError("No configuration loaded.") + self.config[key] = value + self.sync() def sync(self): """ @@ -535,7 +572,8 @@ class TypedConfig: self.config = config self.sync() - + def save(self, file_path:str|Path|None=None): + self.config.save_config(file_path=file_path) def to_dict(self, use_template=False): if not use_template: return self.config diff --git a/lollms/types.py b/lollms/types.py index 3e05a8e..5e873d2 100644 --- a/lollms/types.py +++ b/lollms/types.py @@ -1,11 +1,12 @@ from enum import Enum class MSG_TYPE(Enum): - MSG_TYPE_CHUNK=0 - MSG_TYPE_FULL=1 - MSG_TYPE_EXCEPTION=2 - MSG_TYPE_STEP=3 - MSG_TYPE_META=4 - MSG_TYPE_REF=5 - MSG_TYPE_CODE=6 - MSG_TYPE_UI=7 + MSG_TYPE_CHUNK=0 # A chunk of a message (used for classical chat) + MSG_TYPE_FULL=1 # A full message (for some personality the answer is sent in bulk) + MSG_TYPE_EXCEPTION=2 # An exception occured + MSG_TYPE_STEP=3 # A step has been done (the text contains an explanation of the step done by he personality) + MSG_TYPE_PROGRESS=4 # The progress value (the text contains a percentage and can be parsed by the reception) + MSG_TYPE_META=5 # Generic metadata + MSG_TYPE_REF=6 # References (in form of []() ) + MSG_TYPE_CODE=7 # A HTML code to be embedded in the answer + MSG_TYPE_UI=8 # A vue.js component to show diff --git a/setup.py b/setup.py index 9145425..e50ef15 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.0.10", + version="2.0.15", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition",