Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
I added a "/retry" command to retry for getting another answer. (#188)
Hans Raaf71d696dc9ea6
diff --git a/README.md b/README.mdindex 82cd1192c..da0677dab 100644--- a/README.md+++ b/README.md@@ -295,8 +295,10 @@ While using MemGPT via the CLI (not Discord!) you can run various commands:view the last <count> messages (all if <count> is omitted)/memoryprint the current contents of agent memory-/pop- undo the last message in the conversation+/pop <count>+ undo the last messages in the conversation. It defaults to 3, which usually is one turn around in the conversation+/retry+ pops the last answer and tries to get another one/rethink <text>will replace the inner dialog of the last assistant message with the <text> to help shaping the conversation/rewritediff --git a/memgpt/main.py b/memgpt/main.pyindex fda6155df..e93ed085e 100644--- a/memgpt/main.py+++ b/memgpt/main.py@@ -504,12 +504,23 @@ async def run_agent_loop(memgpt_agent, first, no_verify=False, cfg=None, strip_uelif user_input.lower() == "/pop" or user_input.lower().startswith("/pop "):# Check if there's an additional argument that's an integercommand = user_input.strip().split()- amount = int(command[1]) if len(command) > 1 and command[1].isdigit() else 2+ amount = int(command[1]) if len(command) > 1 and command[1].isdigit() else 3print(f"Popping last {amount} messages from stack")for _ in range(min(amount, len(memgpt_agent.messages))):memgpt_agent.messages.pop()continue+ elif user_input.lower() == "/retry":+ # TODO this needs to also modify the persistence manager+ print(f"Retrying for another answer")+ while len(memgpt_agent.messages) > 0:+ if memgpt_agent.messages[-1].get("role") == "user":+ # we want to pop up to the last user message and send it again+ user_message = memgpt_agent.messages[-1].get("content")+ memgpt_agent.messages.pop()+ break+ memgpt_agent.messages.pop()+elif user_input.lower() == "/rethink" or user_input.lower().startswith("/rethink "):# TODO this needs to also modify the persistence managerif len(user_input) < len("/rethink "):@@ -615,7 +626,8 @@ USER_COMMANDS = [("/load", "load a saved checkpoint"),("/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"),+ ("/pop <count>", "undo <count> messages in the conversation (default is 3)"),+ ("/retry", "pops the last answer and tries to get another one"),("/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"),