mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-04-08 11:24:14 +00:00
updated
This commit is contained in:
parent
d0ec9c08b6
commit
f6f85874f1
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user