Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
[cpacker#319] run Black Reformat on files.
Max Blackmerf7df7d6d781f
diff --git a/memgpt/cli/cli.py b/memgpt/cli/cli.pyindex 10328bfe2..5f2463a65 100644--- a/memgpt/cli/cli.py+++ b/memgpt/cli/cli.py@@ -139,7 +139,7 @@ def run("""# setup logger- #TODO: remove Utils Debug after global logging is complete.+ # TODO: remove Utils Debug after global logging is complete.utils.DEBUG = debug# TODO: add logging command line options for runtime log leveldiff --git a/memgpt/cli/cli_config.py b/memgpt/cli/cli_config.pyindex 132cbd8f4..02eaf3519 100644--- a/memgpt/cli/cli_config.py+++ b/memgpt/cli/cli_config.py@@ -4,8 +4,10 @@ from prettytable import PrettyTableimport typerimport osimport shutil+# from global logging configurationfrom memgpt.memgptlog import logger+# from memgpt.cli import appfrom memgpt import utilsdiff --git a/memgpt/config.py b/memgpt/config.pyindex 4b40747ce..107586693 100644--- a/memgpt/config.py+++ b/memgpt/config.py@@ -1,6 +1,6 @@import loggingimport logging.config-from memgpt.memgptlog import logger,reload_logger+from memgpt.memgptlog import logger, reload_loggerimport inspectimport jsonimport os@@ -14,8 +14,6 @@ from memgpt.constants import MEMGPT_DIR, LLM_MAX_TOKENS, DEFAULT_HUMAN, DEFAULT_from memgpt.presets.presets import DEFAULT_PRESET--# helper functions for writing to configsdef get_field(config, section, field):if section not in config:@@ -150,8 +148,9 @@ class MemGPTConfig:"config_path": config_path,"memgpt_version": get_field(config, "version", "memgpt_version"),"logging_level": get_field(config, "logger_MemGPT", "level"),- "logging_enable_logfile": True if "consoleHandler,logfileHandler" == get_field(config, "logger_MemGPT",- "handlers") else False,+ "logging_enable_logfile": True+ if "consoleHandler,logfileHandler" == get_field(config, "logger_MemGPT", "handlers")+ else False,"logging_backup_count": get_field(config, "handler_logfileHandler", "backupcount"),"logging_max_file_bytes": get_field(config, "handler_logfileHandler", "maxBytes"),"logging_logdir": get_field(config, "logging_paths", "logdir"),@@ -159,9 +158,13 @@ class MemGPTConfig:}# ensure logging is config is set correctly support for upgradesforce_save = False- if config_dict["logging_level"] is None or config_dict["logging_backup_count"] is None or config_dict[- "logging_max_file_bytes"] is None or config_dict["logging_logdir"] is None or config_dict[- "logging_logpathname"] is None:+ if (+ config_dict["logging_level"] is None+ or config_dict["logging_backup_count"] is None+ or config_dict["logging_max_file_bytes"] is None+ or config_dict["logging_logdir"] is None+ or config_dict["logging_logpathname"] is None+ ):# load loggind defaults if noneconfig_dict["logging_enable_logfile"] = MemGPTConfig.logging_enable_logfileconfig_dict["logging_level"] = MemGPTConfig.logging_level@@ -176,7 +179,7 @@ class MemGPTConfig:temp_config = cls(**config_dict)temp_config.save()logger = logging.getLogger(LOGGER_NAME)- logger.debug(f'Updated Missing Logging Configuration: {config_path}')+ logger.debug(f"Updated Missing Logging Configuration: {config_path}")return cls(**config_dict)@@ -186,7 +189,7 @@ class MemGPTConfig:config.create_config_dir() # create dirsconfig.save() # save updated configlogger = logging.getLogger(LOGGER_NAME)- logger.debug(f'Created New Configuration: {config_path}')+ logger.debug(f"Created New Configuration: {config_path}")return configdef save(self):@@ -262,14 +265,17 @@ class MemGPTConfig:# console logging formatterset_field(config, "formatter_consoleFormatter", "format", "%(name)s - %(levelname)s - %(message)s")if self.logging_enable_logfile:- set_field(config, "formatter_logfileFormatter", "format",- "%(asctime)s - %(name)s - %(levelname)s - %(message)s")+ set_field(config, "formatter_logfileFormatter", "format", "%(asctime)s - %(name)s - %(levelname)s - %(message)s")# logfile logging handler Rotating File Handlerset_field(config, "handler_logfileHandler", "class", "handlers.RotatingFileHandler")set_field(config, "handler_logfileHandler", "level", self.logging_level)fixed_logpathname = utils.fix_file_path(self.logging_logpathname)- set_field(config, "handler_logfileHandler", "args",- f"('{fixed_logpathname}', {self.logging_max_file_bytes}, {self.logging_backup_count})")+ set_field(+ config,+ "handler_logfileHandler",+ "args",+ f"('{fixed_logpathname}', {self.logging_max_file_bytes}, {self.logging_backup_count})",+ )set_field(config, "handler_logfileHandler", "formatter", "logfileFormatter")# logging pathsset_field(config, "logging_paths", "logdir", self.logging_logdir)@@ -281,10 +287,10 @@ class MemGPTConfig:with open(self.config_path, "w") as f:config.write(f)# reload logging config after write.- logging.config.fileConfig(self.config_path,disable_existing_loggers=False)+ logging.config.fileConfig(self.config_path, disable_existing_loggers=False)# reset the logger (global) logger is defined as globalreload_logger()- logger.debug(f'Saved Config: {self.config_path}')+ logger.debug(f"Saved Config: {self.config_path}")@staticmethoddef exists():@@ -371,8 +377,7 @@ class AgentConfig:# save agent configself.agent_config_path = (- os.path.join(MEMGPT_DIR, "agents", self.name,- "config.json") if agent_config_path is None else agent_config_path+ os.path.join(MEMGPT_DIR, "agents", self.name, "config.json") if agent_config_path is None else agent_config_path)def generate_agent_id(self, length=6):diff --git a/memgpt/utils.py b/memgpt/utils.pyindex 27335cb5e..efb9e24ce 100644--- a/memgpt/utils.py+++ b/memgpt/utils.py@@ -260,9 +260,10 @@ def get_schema_diff(schema_a, schema_b):return "".join(difference)+def fix_file_path(path):"""Converts backslashes to forward slashes in a file path.This is useful for ensuring compatibility in file paths across different systems."""- return path.replace('\\', '/')\ No newline at end of file+ return path.replace("\\", "/")