From 5d4882dee9d77010c6727d5e1f2664c4ffceead5 Mon Sep 17 00:00:00 2001 From: lumenmai Date: Sat, 5 Oct 2024 00:28:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=AF=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E7=BE=A4=E5=91=98=E8=BA=AB=E4=BB=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .idea/.gitignore | 8 ++++++++ .idea/AstrBot.iml | 15 +++++++++++++++ .idea/deployment.xml | 14 ++++++++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ astrbot/message/handler.py | 8 ++++++++ type/config.py | 2 ++ util/cmd_config.py | 1 + 10 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/AstrBot.iml create mode 100644 .idea/deployment.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 91514b8d..0b0a993c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ __pycache__ botpy.log .vscode -data.db +data_v2.db configs/session configs/config.yaml **/.DS_Store diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..35410cac --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/AstrBot.iml b/.idea/AstrBot.iml new file mode 100644 index 00000000..5fdd65ba --- /dev/null +++ b/.idea/AstrBot.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 00000000..e3300099 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..57d7881b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/astrbot/message/handler.py b/astrbot/message/handler.py index b8c57f19..f16127f7 100644 --- a/astrbot/message/handler.py +++ b/astrbot/message/handler.py @@ -110,6 +110,7 @@ class MessageHandler(): self.rate_limit_helper = RateLimitHelper(context) self.content_safety_helper = ContentSafetyHelper(context) self.llm_wake_prefix = self.context.config_helper.llm_settings.wake_prefix + self.llm_identifier = self.context.config_helper.llm_settings.identifier if self.llm_wake_prefix: self.llm_wake_prefix = self.llm_wake_prefix.strip() self.provider = self.context.llms[0].llm_instance if len(self.context.llms) > 0 else None @@ -235,6 +236,13 @@ class MessageHandler(): else: # normal chat tool_use_flag = False + # add user info to the prompt + if self.llm_identifier: + user_id = message.message_obj.sender.user_id + user_nickname = message.message_obj.sender.nickname + user_info = f"[User ID: {user_id}, Nickname: {user_nickname}]\n" + msg_plain = user_info + msg_plain + llm_result = await provider.text_chat( prompt=msg_plain, session_id=message.session_id, diff --git a/type/config.py b/type/config.py index ed2c93b5..a5093f81 100644 --- a/type/config.py +++ b/type/config.py @@ -146,6 +146,7 @@ DEFAULT_CONFIG_VERSION_2 = { "llm_settings": { "wake_prefix": "", "web_search": False, + "identifier": False, }, "content_safety": { "baidu_aip": { @@ -312,6 +313,7 @@ CONFIG_METADATA_2 = { "items": { "wake_prefix": {"description": "LLM 聊天额外唤醒前缀", "type": "string"}, "web_search": {"description": "启用网页搜索(能访问 Google 时效果最佳)", "type": "bool"}, + "identifier": {"description": "启动识别群员(略微增加token开销)", "type": "bool"}, } }, "content_safety": { diff --git a/util/cmd_config.py b/util/cmd_config.py index 85285bc5..4eb60e9f 100644 --- a/util/cmd_config.py +++ b/util/cmd_config.py @@ -90,6 +90,7 @@ class LLMConfig: class LLMSettings: wake_prefix: str = "" web_search: bool = False + identifier: bool = False @dataclass class BaiduAIPConfig: From 526ba34d870ee46b9109e51f82e20a6460926289 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 5 Oct 2024 10:35:03 +0800 Subject: [PATCH 2/2] remove: .idea --- .idea/.gitignore | 8 -------- .idea/AstrBot.iml | 15 --------------- .idea/deployment.xml | 14 -------------- .idea/inspectionProfiles/profiles_settings.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 6 files changed, 57 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/AstrBot.iml delete mode 100644 .idea/deployment.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 35410cac..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml -# 基于编辑器的 HTTP 客户端请求 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/AstrBot.iml b/.idea/AstrBot.iml deleted file mode 100644 index 5fdd65ba..00000000 --- a/.idea/AstrBot.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml deleted file mode 100644 index e3300099..00000000 --- a/.idea/deployment.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da..00000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 57d7881b..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file