From f554ae86ac4b1e4aeb91dcb56edf5017cf347fac Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Wed, 14 Dec 2022 21:49:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=97=B6=E4=B8=8D=E5=8A=A0=E5=89=8D=E7=BC=80?= =?UTF-8?q?=20#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config-template.py | 3 +++ pkg/qqbot/manager.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config-template.py b/config-template.py index 5985dc3..3820459 100644 --- a/config-template.py +++ b/config-template.py @@ -23,6 +23,9 @@ openai_config = { # 管理员QQ号,用于接收报错等通知,为0时不发送通知 admin_qq = 0 +# 回复消息时是否显示[GPT]前缀 +show_prefix = False + # 敏感词过滤开关,以同样数量的*代替敏感词回复 # 请在sensitive.json中添加敏感词 sensitive_word_filter = True diff --git a/pkg/qqbot/manager.py b/pkg/qqbot/manager.py index 2e20e31..830cf0e 100644 --- a/pkg/qqbot/manager.py +++ b/pkg/qqbot/manager.py @@ -175,7 +175,8 @@ class QQBotManager: session = pkg.openai.session.get_session(session_name) try: - reply = "[GPT]" + session.append(text_message) + prefix = "[GPT]" if hasattr(config, "show_prefix") and config.show_prefix else "" + reply = prefix + session.append(text_message) except openai.error.APIConnectionError as e: self.notify_admin("{}会话调用API失败:{}".format(session_name, e)) reply = "[bot]err:调用API失败,请联系作者,或等待修复"