From 11b8c767ca9c039e545a8a42f88ce3f5b41221f3 Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Wed, 12 Jun 2024 22:26:19 +0800 Subject: [PATCH] Improve update context condition checking rule (#2883) Co-authored-by: Chi Wang --- 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 dd2ef0191270..261ab2062ef8 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