Improve update context condition checking rule (#2883)

Co-authored-by: Chi Wang <wang.chi@microsoft.com>
This commit is contained in:
Li Jiang 2024-06-12 22:26:19 +08:00 committed by GitHub
parent a0787aced3
commit 11b8c767ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,6 +81,7 @@ Context is: {input_context}
""" """
HASH_LENGTH = int(os.environ.get("HASH_LENGTH", 8)) HASH_LENGTH = int(os.environ.get("HASH_LENGTH", 8))
UPDATE_CONTEXT_IN_PROMPT = "you should reply exactly `UPDATE CONTEXT`"
class RetrieveUserProxyAgent(UserProxyAgent): class RetrieveUserProxyAgent(UserProxyAgent):
@ -471,7 +472,7 @@ class RetrieveUserProxyAgent(UserProxyAgent):
message = message.get("content", "") message = message.get("content", "")
elif not isinstance(message, str): elif not isinstance(message, str):
message = "" 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() update_context_case2 = self.customized_answer_prefix and self.customized_answer_prefix not in message.upper()
return update_context_case1, update_context_case2 return update_context_case1, update_context_case2