From 68114993ea6d54d1f87a12299f52b969e51d2f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E6=B2=B3=E6=99=B4?= Date: Thu, 17 Apr 2025 15:03:42 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=92=8C=E4=BB=A3=E7=A0=81=E4=B8=AD=E7=9A=84LLM=5Frequest?= =?UTF-8?q?=E4=B8=BALLMRequest=EF=BC=8C=E4=BC=98=E5=8C=96dockerignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 1 - CONTRIBUTE.md | 1 - README.md | 22 ++--- src/plugins/message/test.py | 95 ------------------- .../topic_identify/topic_identifier.py | 2 +- src/plugins/willing/mode_llmcheck.py | 4 +- 6 files changed, 14 insertions(+), 111 deletions(-) delete mode 100644 src/plugins/message/test.py diff --git a/.dockerignore b/.dockerignore index 6c2d07736..fac1bf99a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,5 @@ .git __pycache__ -*.pyc *.pyo *.pyd .DS_Store diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 440a8202d..c372aebe8 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -19,7 +19,6 @@ ● [我有问题](#我有问题) ● [我想做贡献](#我想做贡献) -● [我想报告BUG](#报告BUG) ● [我想提出建议](#提出建议) ## 我有问题 diff --git a/README.md b/README.md index 325e3ad22..e5a3d1306 100644 --- a/README.md +++ b/README.md @@ -113,17 +113,17 @@ ## 🎯 功能介绍 -| 模块 | 主要功能 | 特点 | -|------|---------|------| -| 💬 聊天系统 | • 心流/推理聊天
• 关键词主动发言
• 多模型支持
• 动态prompt构建
• 私聊功能(PFC) | 拟人化交互 | -| 🧠 心流系统 | • 实时思考生成
• 自动启停机制
• 日程系统联动
• 工具调用能力 | 智能化决策 | -| 🧠 记忆系统 | • 优化记忆抽取
• 海马体记忆机制
• 聊天记录概括 | 持久化记忆 | -| 😊 表情系统 | • 情绪匹配发送
• GIF支持
• 自动收集与审查 | 丰富表达 | -| 📅 日程系统 | • 动态日程生成
• 自定义想象力
• 思维流联动 | 智能规划 | -| 👥 关系系统 | • 关系管理优化
• 丰富接口支持
• 个性化交互 | 深度社交 | -| 📊 统计系统 | • 使用数据统计
• LLM调用记录
• 实时控制台显示 | 数据可视 | -| 🔧 系统功能 | • 优雅关闭机制
• 自动数据保存
• 异常处理完善 | 稳定可靠 | -| 🛠️ 工具系统 | • 知识获取工具
• 自动注册机制
• 多工具支持 | 扩展功能 | +| 模块 | 主要功能 | 特点 | +|----------|------------------------------------------------------------------|-------| +| 💬 聊天系统 | • 心流/推理聊天
• 关键词主动发言
• 多模型支持
• 动态prompt构建
• 私聊功能(PFC) | 拟人化交互 | +| 🧠 心流系统 | • 实时思考生成
• 自动启停机制
• 日程系统联动
• 工具调用能力 | 智能化决策 | +| 🧠 记忆系统 | • 优化记忆抽取
• 海马体记忆机制
• 聊天记录概括 | 持久化记忆 | +| 😊 表情系统 | • 情绪匹配发送
• GIF支持
• 自动收集与审查 | 丰富表达 | +| 📅 日程系统 | • 动态日程生成
• 自定义想象力
• 思维流联动 | 智能规划 | +| 👥 关系系统 | • 关系管理优化
• 丰富接口支持
• 个性化交互 | 深度社交 | +| 📊 统计系统 | • 使用数据统计
• LLM调用记录
• 实时控制台显示 | 数据可视 | +| 🔧 系统功能 | • 优雅关闭机制
• 自动数据保存
• 异常处理完善 | 稳定可靠 | +| 🛠️ 工具系统 | • 知识获取工具
• 自动注册机制
• 多工具支持 | 扩展功能 | ## 📐 项目架构 diff --git a/src/plugins/message/test.py b/src/plugins/message/test.py deleted file mode 100644 index abb4c03b5..000000000 --- a/src/plugins/message/test.py +++ /dev/null @@ -1,95 +0,0 @@ -import unittest -import asyncio -import aiohttp -from api import BaseMessageAPI -from message_base import ( - BaseMessageInfo, - UserInfo, - GroupInfo, - FormatInfo, - MessageBase, - Seg, -) - - -send_url = "http://localhost" -receive_port = 18002 # 接收消息的端口 -send_port = 18000 # 发送消息的端口 -test_endpoint = "/api/message" - -# 创建并启动API实例 -api = BaseMessageAPI(host="0.0.0.0", port=receive_port) - - -class TestLiveAPI(unittest.IsolatedAsyncioTestCase): - async def asyncSetUp(self): - """测试前的设置""" - self.received_messages = [] - - async def message_handler(message): - self.received_messages.append(message) - - self.api = api - self.api.register_message_handler(message_handler) - self.server_task = asyncio.create_task(self.api.run()) - try: - await asyncio.wait_for(asyncio.sleep(1), timeout=5) - except asyncio.TimeoutError: - self.skipTest("服务器启动超时") - - async def asyncTearDown(self): - """测试后的清理""" - if hasattr(self, "server_task"): - await self.api.stop() # 先调用正常的停止流程 - if not self.server_task.done(): - self.server_task.cancel() - try: - await asyncio.wait_for(self.server_task, timeout=100) - except (asyncio.CancelledError, asyncio.TimeoutError): - pass - - async def test_send_and_receive_message(self): - """测试向运行中的API发送消息并接收响应""" - # 准备测试消息 - user_info = UserInfo(user_id=12345678, user_nickname="测试用户", platform="qq") - group_info = GroupInfo(group_id=12345678, group_name="测试群", platform="qq") - format_info = FormatInfo(content_format=["text"], accept_format=["text", "emoji", "reply"]) - template_info = None - message_info = BaseMessageInfo( - platform="qq", - message_id=12345678, - time=12345678, - group_info=group_info, - user_info=user_info, - format_info=format_info, - template_info=template_info, - ) - message = MessageBase( - message_info=message_info, - raw_message="测试消息", - message_segment=Seg(type="text", data="测试消息"), - ) - test_message = message.to_dict() - - # 发送测试消息到发送端口 - async with aiohttp.ClientSession() as session: - async with session.post( - f"{send_url}:{send_port}{test_endpoint}", - json=test_message, - ) as response: - response_data = await response.json() - self.assertEqual(response.status, 200) - self.assertEqual(response_data["status"], "success") - try: - async with asyncio.timeout(5): # 设置5秒超时 - while len(self.received_messages) == 0: - await asyncio.sleep(0.1) - received_message = self.received_messages[0] - print(received_message) - self.received_messages.clear() - except asyncio.TimeoutError: - self.fail("等待接收消息超时") - - -if __name__ == "__main__": - unittest.main() diff --git a/src/plugins/topic_identify/topic_identifier.py b/src/plugins/topic_identify/topic_identifier.py index bc81874c1..25c290a3a 100644 --- a/src/plugins/topic_identify/topic_identifier.py +++ b/src/plugins/topic_identify/topic_identifier.py @@ -28,7 +28,7 @@ class TopicIdentifier: 消息内容:{text}""" - # 使用 LLM_request 类进行请求 + # 使用 LLMRequest 类进行请求 try: topic, _, _ = await self.llm_topic_judge.generate_response(prompt) except Exception as e: diff --git a/src/plugins/willing/mode_llmcheck.py b/src/plugins/willing/mode_llmcheck.py index d6ac3dc6b..ec1cde295 100644 --- a/src/plugins/willing/mode_llmcheck.py +++ b/src/plugins/willing/mode_llmcheck.py @@ -13,7 +13,7 @@ llmcheck 模式: import time from loguru import logger -from ..models.utils_model import LLM_request +from ..models.utils_model import LLMRequest from ...config.config import global_config # from ..chat.chat_stream import ChatStream @@ -61,7 +61,7 @@ def llmcheck_decorator(trigger_condition_func): class LlmcheckWillingManager(MxpWillingManager): def __init__(self): super().__init__() - self.model_v3 = LLM_request(model=global_config.llm_normal, temperature=0.3) + self.model_v3 = LLMRequest(model=global_config.llm_normal, temperature=0.3) async def get_llmreply_probability(self, message_id: str): message_info = self.ongoing_messages[message_id]