From b879a7032511e1326d91ef15bec12409fd834016 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Thu, 20 Nov 2025 14:31:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E6=95=B4AI=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=8D2.=E5=B0=86AI=E6=8F=92=E4=BB=B6=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA=E9=BB=98=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plugins/Others/ChatAI.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Plugins/Others/ChatAI.py b/Plugins/Others/ChatAI.py index 733b3a0..568cd2b 100644 --- a/Plugins/Others/ChatAI.py +++ b/Plugins/Others/ChatAI.py @@ -40,11 +40,11 @@ class ChatAIAgent: - 注意区分不同群聊和不同用户的对话上下文 示例对话: -[2025-11-20 10:00:00] [群聊#12345] [用户#67890]: 你好 -你的回复: 你好!有什么可以帮助你的吗? +[2025-11-20 10:00:00] [群聊#12345] [用户#11111]: 你好 +你的回复: 你好!有什么可以帮助你的吗? -[2025-11-20 10:01:00] [群聊#12345] [用户#11111]: 今天天气怎么样? -你的回复: 抱歉,我无法获取实时天气信息。""" +[2025-11-20 10:01:00] [群聊#67890] [用户#22222]: 刚刚谁在说话, 说了什么? +你的回复: 刚刚群聊12345的用户在说话, 他说了你好。""" logger.Log("Info", f"{ConsoleFrontColor.GREEN}ChatAIAgent 初始化完成{ConsoleFrontColor.RESET}") logger.Log("Info", f"模型: {OLLAMA_MODEL}, 最大历史: {max_history}") @@ -166,7 +166,7 @@ class ChatAIAgent: {current_msg} 请作为AI助手回复当前用户。记住: -1. 使用 格式来称呼该用户 +1. 使用 格式来提到任意你想提及的用户 2. 根据对话历史和当前消息,给出有意义的回复 3. 如果历史中有其他群聊或用户的信息,你可以引用它们""" @@ -281,6 +281,7 @@ class ChatAIPlugin(WPSAPI): def wake_up(self) -> None: logger.Log("Info", f"{ConsoleFrontColor.GREEN}ChatAIPlugin AI对话插件已加载{ConsoleFrontColor.RESET}") self.register_plugin("ai_chat") + self.register_plugin("default") @override async def callback(self, message: str, chat_id: int, user_id: int) -> str|None: @@ -314,12 +315,7 @@ class ChatAIPlugin(WPSAPI): answer = await self.ai_agent.chat(message, chat_id, user_id) # 格式化返回结果 - formatted_answer = f"""🤖 **AI 智能对话** - -{answer} - ---- -*由 LlamaIndex + Ollama 驱动*""" + formatted_answer = answer return await self.send_markdown_message(formatted_answer, chat_id, user_id)