From d5e0f257bd29008cd55f512b953287838005d644 Mon Sep 17 00:00:00 2001 From: Rylynn Date: Thu, 8 Dec 2022 21:57:10 +0800 Subject: [PATCH] Update dialog.py --- dialog.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dialog.py b/dialog.py index 9aa20b8..ad34acc 100644 --- a/dialog.py +++ b/dialog.py @@ -49,7 +49,8 @@ def __init__(self): self.data = None self.hold = None self.persona = None - self.statement = "你好~在聊天前需要声明:\n1.当前对话不涉及任何隐私信息,双方共同确认对话的可公开性,\n" \ + self.statement = "你好~在使用此AI前需要声明: + "\n1.当前对话不涉及任何隐私信息,双方共同确认对话的可公开性,\n" \ "2.对话过程中请勿讨论敏感话题,否则需自行承担不当言论可能造成的法律风险。\n" \ "3.如不接受请即刻停止对话,继续对话将被视为完全理解并接受上述声明。" self.memory_len = 2 << 5 @@ -212,6 +213,12 @@ def dialog_core(self, text, usr_id) -> Any: f.write(reply + "\n") return reply + def combine_multi_dialog(self) -> boolean: + """ + 部分功能还在调试,暂不开源 + """ + return + async def on_message(self, msg: Message): """ Message Handler for the Bot @@ -245,6 +252,9 @@ async def on_message(self, msg: Message): if text in self.hold or text[1:] in self.hold: return + #根据时间窗口将多轮对话合并成一句 + self.combine_multi_dialog() + text = text.replace(r'\s', ",").replace("#", "号").replace("&", "和") # bad_detection_result = self.bad_detection.detection(texts=[text], use_gpu=True, batch_size=1) #