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
This commit is contained in:
Sarah Wooders
2023-11-14 22:50:24 -08:00
committed by GitHub
parent d705271aff
commit a23ba80ac8
2 changed files with 15 additions and 0 deletions

View File

@@ -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

View File

@@ -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()