From 18c8f8c169dc0189d05aec5435442e7cb4d01220 Mon Sep 17 00:00:00 2001 From: cpacker Date: Thu, 21 Dec 2023 00:31:37 -0800 Subject: [PATCH 1/2] added /summarize command --- memgpt/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/memgpt/main.py b/memgpt/main.py index af2033b143..de641f9f1e 100644 --- a/memgpt/main.py +++ b/memgpt/main.py @@ -205,6 +205,9 @@ def run_agent_loop(memgpt_agent, first, no_verify=False, cfg=None, strip_ui=Fals break continue + elif user_input.lower() == "/summarize": + memgpt_agent.summarize_messages_inplace() + # No skip options elif user_input.lower() == "/wipe": memgpt_agent = agent.Agent(interface) From a30b95b19ea55ccf7f5b0764256a3a8c26b74a5b Mon Sep 17 00:00:00 2001 From: cpacker Date: Thu, 21 Dec 2023 00:53:05 -0800 Subject: [PATCH 2/2] patch and test --- memgpt/main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/memgpt/main.py b/memgpt/main.py index de641f9f1e..d456bf925d 100644 --- a/memgpt/main.py +++ b/memgpt/main.py @@ -21,6 +21,7 @@ import memgpt.agent as agent import memgpt.system as system import memgpt.constants as constants +import memgpt.errors as errors from memgpt.cli.cli import run, attach, version, server, open_folder, quickstart from memgpt.cli.cli_config import configure, list, add from memgpt.cli.cli_load import app as load_app @@ -206,7 +207,20 @@ def run_agent_loop(memgpt_agent, first, no_verify=False, cfg=None, strip_ui=Fals continue elif user_input.lower() == "/summarize": - memgpt_agent.summarize_messages_inplace() + try: + memgpt_agent.summarize_messages_inplace() + typer.secho( + f"/summarize succeeded", + fg=typer.colors.GREEN, + bold=True, + ) + except errors.LLMError as e: + typer.secho( + f"/summarize failed:\n{e}", + fg=typer.colors.RED, + bold=True, + ) + continue # No skip options elif user_input.lower() == "/wipe":