From a23ba80ac838fa09608e5aebdf43de12772e7060 Mon Sep 17 00:00:00 2001 From: Sarah Wooders Date: Tue, 14 Nov 2023 22:50:24 -0800 Subject: [PATCH] Update config to include `memgpt_version` and re-run configuration for old versions on `memgpt run` (#450) * mark depricated API section * add readme * add readme * add readme * add readme * add readme * add readme * add readme * add readme * add readme * CLI bug fixes for azure * check azure before running * Update README.md * Update README.md * bug fix with persona loading * remove print * make errors for cli flags more clear * format * fix imports * fix imports * add prints * update lock * remove asserts * store config versions and force update in some cases --- memgpt/cli/cli.py | 6 ++++++ memgpt/config.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/memgpt/cli/cli.py b/memgpt/cli/cli.py index 407ae2e7..abcf3118 100644 --- a/memgpt/cli/cli.py +++ b/memgpt/cli/cli.py @@ -80,6 +80,12 @@ def run( else: # load config config = MemGPTConfig.load() + # force re-configuration is config is from old version + if config.memgpt_version is None: # TODO: eventually add checks for older versions, if config changes again + typer.secho("MemGPT has been updated to a newer version, so re-running configuration.", fg=typer.colors.YELLOW) + configure() + config = MemGPTConfig.load() + # override with command line arguments if debug: config.debug = debug diff --git a/memgpt/config.py b/memgpt/config.py index 6a57bf8d..34073da8 100644 --- a/memgpt/config.py +++ b/memgpt/config.py @@ -110,6 +110,9 @@ class MemGPTConfig: persistence_manager_save_file: str = None # local file persistence_manager_uri: str = None # db URI + # version (for backcompat) + memgpt_version: str = None + def __post_init__(self): # ensure types self.embedding_chunk_size = int(self.embedding_chunk_size) @@ -158,6 +161,7 @@ class MemGPTConfig: "archival_storage_uri": get_field(config, "archival_storage", "uri"), "anon_clientid": get_field(config, "client", "anon_clientid"), "config_path": config_path, + "memgpt_version": get_field(config, "version", "memgpt_version"), } config_dict = {k: v for k, v in config_dict.items() if v is not None} return cls(**config_dict) @@ -169,6 +173,8 @@ class MemGPTConfig: return config def save(self): + import memgpt + config = configparser.ConfigParser() # CLI defaults @@ -205,6 +211,9 @@ class MemGPTConfig: set_field(config, "archival_storage", "path", self.archival_storage_path) set_field(config, "archival_storage", "uri", self.archival_storage_uri) + # set version + set_field(config, "version", "memgpt_version", memgpt.__version__) + # client if not self.anon_clientid: self.anon_clientid = self.generate_uuid()