Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
I added commands to shape the conversation: (#218)
Hans Raafdcdfa04fc096
diff --git a/README.md b/README.mdindex 9b0e79de8..82cd1192c 100644--- a/README.md+++ b/README.md@@ -297,6 +297,10 @@ While using MemGPT via the CLI (not Discord!) you can run various commands:print the current contents of agent memory/popundo the last message in the conversation+/rethink <text>+ will replace the inner dialog of the last assistant message with the <text> to help shaping the conversation+/rewrite+ will replace the last assistant answer with the given text to correct or force the answer/heartbeatsend a heartbeat system message to the agent/memorywarningdiff --git a/memgpt/main.py b/memgpt/main.pyindex 0fb0b2279..fda6155df 100644--- a/memgpt/main.py+++ b/memgpt/main.py@@ -8,6 +8,7 @@ import osimport sysimport pickleimport traceback+import jsonimport questionaryimport typer@@ -509,6 +510,32 @@ async def run_agent_loop(memgpt_agent, first, no_verify=False, cfg=None, strip_umemgpt_agent.messages.pop()continue+ elif user_input.lower() == "/rethink" or user_input.lower().startswith("/rethink "):+ # TODO this needs to also modify the persistence manager+ if len(user_input) < len("/rethink "):+ print("Missing text after the command")+ continue+ for x in range(len(memgpt_agent.messages) - 1, 0, -1):+ if memgpt_agent.messages[x].get("role") == "assistant":+ text = user_input[len("/rethink ") :].strip()+ memgpt_agent.messages[x].update({"content": text})+ break+ continue++ elif user_input.lower() == "/rewrite" or user_input.lower().startswith("/rewrite "):+ # TODO this needs to also modify the persistence manager+ if len(user_input) < len("/rewrite "):+ print("Missing text after the command")+ continue+ for x in range(len(memgpt_agent.messages) - 1, 0, -1):+ if memgpt_agent.messages[x].get("role") == "assistant":+ text = user_input[len("/rewrite ") :].strip()+ args = json.loads(memgpt_agent.messages[x].get("function_call").get("arguments"))+ args["message"] = text+ memgpt_agent.messages[x].get("function_call").update({"arguments": json.dumps(args)})+ break+ continue+# No skip optionselif user_input.lower() == "/wipe":memgpt_agent = agent.AgentAsync(memgpt.interface)@@ -589,6 +616,8 @@ USER_COMMANDS = [("/dump <count>", "view the last <count> messages (all if <count> is omitted)"),("/memory", "print the current contents of agent memory"),("/pop", "undo the last message in the conversation"),+ ("/rethink <text>", "changes the inner thoughts of the last agent message"),+ ("/rewrite <text>", "changes the reply of the last agent message"),("/heartbeat", "send a heartbeat system message to the agent"),("/memorywarning", "send a memory warning system message to the agent"),("/attach", "attach data source to agent"),