From 8e4021ae9c714238c201d7848beb317f49e6dbe7 Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Fri, 7 Jun 2024 04:18:53 +0000 Subject: [PATCH] Improve update context condition checking rule --- autogen/agentchat/contrib/retrieve_user_proxy_agent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autogen/agentchat/contrib/retrieve_user_proxy_agent.py b/autogen/agentchat/contrib/retrieve_user_proxy_agent.py index 8d4dbc0d50a..e45f58c0656 100644 --- a/autogen/agentchat/contrib/retrieve_user_proxy_agent.py +++ b/autogen/agentchat/contrib/retrieve_user_proxy_agent.py @@ -81,6 +81,7 @@ """ HASH_LENGTH = int(os.environ.get("HASH_LENGTH", 8)) +UPDATE_CONTEXT_IN_PROMPT = "you should reply exactly `UPDATE CONTEXT`" class RetrieveUserProxyAgent(UserProxyAgent): @@ -471,7 +472,7 @@ def _check_update_context(self, message): message = message.get("content", "") elif not isinstance(message, str): message = "" - update_context_case1 = "UPDATE CONTEXT" in message[-20:].upper() or "UPDATE CONTEXT" in message[:20].upper() + update_context_case1 = "UPDATE CONTEXT" in message.upper() and UPDATE_CONTEXT_IN_PROMPT not in message update_context_case2 = self.customized_answer_prefix and self.customized_answer_prefix not in message.upper() return update_context_case1, update_context_case2