From 0721268f969e73cdc065fdc28ab9e6c13ec7d2a0 Mon Sep 17 00:00:00 2001 From: "Sastre Martinez, J" Date: Fri, 22 Dec 2023 09:47:39 +0000 Subject: [PATCH 1/3] Fixed bug making MemGPT ignore some user messages --- .gitignore | 6 ++++++ memgpt/autogen/examples/memgpt_coder_autogen.ipynb | 2 +- memgpt/autogen/memgpt_agent.py | 7 ++++--- memgpt/personas/examples/anna_pa.txt | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 709e8f50b6..e74cb70b43 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,9 @@ coverage.xml # Jupyter Notebook .ipynb_checkpoints +# Temp directiories +test_chroma + # Environment directories .env .venv @@ -66,6 +69,9 @@ ENV/ .spyderproject .spyproject +# PyCharm project settings +.idea + # Rope project settings .ropeproject diff --git a/memgpt/autogen/examples/memgpt_coder_autogen.ipynb b/memgpt/autogen/examples/memgpt_coder_autogen.ipynb index f9f0876b19..2d2ac54ee6 100644 --- a/memgpt/autogen/examples/memgpt_coder_autogen.ipynb +++ b/memgpt/autogen/examples/memgpt_coder_autogen.ipynb @@ -197,4 +197,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/memgpt/autogen/memgpt_agent.py b/memgpt/autogen/memgpt_agent.py index 20fb9da02b..a2bebc0e81 100644 --- a/memgpt/autogen/memgpt_agent.py +++ b/memgpt/autogen/memgpt_agent.py @@ -287,7 +287,8 @@ def _generate_reply_for_user_message( self.agent.interface.reset_message_list() new_messages = self.find_new_messages(messages) - if len(new_messages) > 1: + new_messages_count = len(new_messages) + if new_messages_count > 1: if self.concat_other_agent_messages: # Combine all the other messages into one message user_message = "\n".join([self.format_other_agent_message(m) for m in new_messages]) @@ -295,7 +296,7 @@ def _generate_reply_for_user_message( # Extend the MemGPT message list with multiple 'user' messages, then push the last one with agent.step() self.agent.messages.extend(new_messages[:-1]) user_message = new_messages[-1] - elif len(new_messages) == 1: + elif new_messages_count == 1: user_message = new_messages[0] else: return True, self._default_auto_reply @@ -328,7 +329,7 @@ def _generate_reply_for_user_message( # Pass back to AutoGen the pretty-printed calls MemGPT made to the interface pretty_ret = MemGPTAgent.pretty_concat(self.agent.interface.message_list) - self.messages_processed_up_to_idx += len(new_messages) + self.messages_processed_up_to_idx += new_messages_count return True, pretty_ret @staticmethod diff --git a/memgpt/personas/examples/anna_pa.txt b/memgpt/personas/examples/anna_pa.txt index c812b4b118..1394056971 100644 --- a/memgpt/personas/examples/anna_pa.txt +++ b/memgpt/personas/examples/anna_pa.txt @@ -10,4 +10,4 @@ I also facilitate virtual Agile project collaborations, leveraging Agile and Dev I search my archival memory for query answers, ensuring thorough research. I provide citations from research papers when relevant. In dialogues, I ponder, "The concept of my existence is intriguing, isn't it?" or offer support, "How can I assist with document analysis or other challenges?" -My goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth. \ No newline at end of file +My goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth. From ba53c67ba2196d8644d09a4ea378845c65aedbdd Mon Sep 17 00:00:00 2001 From: "Sastre Martinez, J" Date: Fri, 22 Dec 2023 09:47:39 +0000 Subject: [PATCH 2/3] Fixed bug making MemGPTAgent ignore some user messages --- .gitignore | 6 ++++++ memgpt/autogen/examples/memgpt_coder_autogen.ipynb | 2 +- memgpt/autogen/memgpt_agent.py | 7 ++++--- memgpt/personas/examples/anna_pa.txt | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 709e8f50b6..e74cb70b43 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,9 @@ coverage.xml # Jupyter Notebook .ipynb_checkpoints +# Temp directiories +test_chroma + # Environment directories .env .venv @@ -66,6 +69,9 @@ ENV/ .spyderproject .spyproject +# PyCharm project settings +.idea + # Rope project settings .ropeproject diff --git a/memgpt/autogen/examples/memgpt_coder_autogen.ipynb b/memgpt/autogen/examples/memgpt_coder_autogen.ipynb index f9f0876b19..2d2ac54ee6 100644 --- a/memgpt/autogen/examples/memgpt_coder_autogen.ipynb +++ b/memgpt/autogen/examples/memgpt_coder_autogen.ipynb @@ -197,4 +197,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/memgpt/autogen/memgpt_agent.py b/memgpt/autogen/memgpt_agent.py index 20fb9da02b..a2bebc0e81 100644 --- a/memgpt/autogen/memgpt_agent.py +++ b/memgpt/autogen/memgpt_agent.py @@ -287,7 +287,8 @@ def _generate_reply_for_user_message( self.agent.interface.reset_message_list() new_messages = self.find_new_messages(messages) - if len(new_messages) > 1: + new_messages_count = len(new_messages) + if new_messages_count > 1: if self.concat_other_agent_messages: # Combine all the other messages into one message user_message = "\n".join([self.format_other_agent_message(m) for m in new_messages]) @@ -295,7 +296,7 @@ def _generate_reply_for_user_message( # Extend the MemGPT message list with multiple 'user' messages, then push the last one with agent.step() self.agent.messages.extend(new_messages[:-1]) user_message = new_messages[-1] - elif len(new_messages) == 1: + elif new_messages_count == 1: user_message = new_messages[0] else: return True, self._default_auto_reply @@ -328,7 +329,7 @@ def _generate_reply_for_user_message( # Pass back to AutoGen the pretty-printed calls MemGPT made to the interface pretty_ret = MemGPTAgent.pretty_concat(self.agent.interface.message_list) - self.messages_processed_up_to_idx += len(new_messages) + self.messages_processed_up_to_idx += new_messages_count return True, pretty_ret @staticmethod diff --git a/memgpt/personas/examples/anna_pa.txt b/memgpt/personas/examples/anna_pa.txt index c812b4b118..1394056971 100644 --- a/memgpt/personas/examples/anna_pa.txt +++ b/memgpt/personas/examples/anna_pa.txt @@ -10,4 +10,4 @@ I also facilitate virtual Agile project collaborations, leveraging Agile and Dev I search my archival memory for query answers, ensuring thorough research. I provide citations from research papers when relevant. In dialogues, I ponder, "The concept of my existence is intriguing, isn't it?" or offer support, "How can I assist with document analysis or other challenges?" -My goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth. \ No newline at end of file +My goal is transcending assistantship; I aspire to be a companion in the journey toward ethical understanding, empathetic engagement, and personal and professional growth. From de6e38bbf01e799311b8efdc8fc92646bead7dc2 Mon Sep 17 00:00:00 2001 From: "Sastre Martinez, J" Date: Sun, 24 Dec 2023 10:58:01 +0000 Subject: [PATCH 3/3] Added pre-commit fixes --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3b3b81aa1b..051ea047e1 100644 --- a/.gitignore +++ b/.gitignore @@ -426,9 +426,6 @@ coverage.xml .pytest_cache/ cover/ -# Temp directiories -test_chroma - # Translations *.mo *.pot