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/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: