Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

Update config to include `memgpt_version` and re-run configuration for old versions on `memgpt run` (#450)

Sarah Woodersa23ba80ac838
diff --git a/memgpt/cli/cli.py b/memgpt/cli/cli.py
index 407ae2e75..abcf31188 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 6a57bf8d7..34073da85 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()