fix: 更新文档和代码中的LLM_request为LLMRequest,优化dockerignore

This commit is contained in:
春河晴
2025-04-17 15:03:42 +09:00
parent ab35f1cdfd
commit 68114993ea
6 changed files with 14 additions and 111 deletions

View File

@@ -1,6 +1,5 @@
.git
__pycache__
*.pyc
*.pyo
*.pyd
.DS_Store

View File

@@ -19,7 +19,6 @@
● [我有问题](#我有问题)
● [我想做贡献](#我想做贡献)
● [我想报告BUG](#报告BUG)
● [我想提出建议](#提出建议)
## 我有问题

View File

@@ -113,17 +113,17 @@
## 🎯 功能介绍
| 模块 | 主要功能 | 特点 |
|------|---------|------|
| 💬 聊天系统 | • 心流/推理聊天<br>• 关键词主动发言<br>• 多模型支持<br>• 动态prompt构建<br>• 私聊功能(PFC) | 拟人化交互 |
| 🧠 心流系统 | • 实时思考生成<br>• 自动启停机制<br>• 日程系统联动<br>• 工具调用能力 | 智能化决策 |
| 🧠 记忆系统 | • 优化记忆抽取<br>• 海马体记忆机制<br>• 聊天记录概括 | 持久化记忆 |
| 😊 表情系统 | • 情绪匹配发送<br>• GIF支持<br>• 自动收集与审查 | 丰富表达 |
| 📅 日程系统 | • 动态日程生成<br>• 自定义想象力<br>• 思维流联动 | 智能规划 |
| 👥 关系系统 | • 关系管理优化<br>• 丰富接口支持<br>• 个性化交互 | 深度社交 |
| 📊 统计系统 | • 使用数据统计<br>• LLM调用记录<br>• 实时控制台显示 | 数据可视 |
| 🔧 系统功能 | • 优雅关闭机制<br>• 自动数据保存<br>• 异常处理完善 | 稳定可靠 |
| 🛠️ 工具系统 | • 知识获取工具<br>• 自动注册机制<br>• 多工具支持 | 扩展功能 |
| 模块 | 主要功能 | 特点 |
|----------|------------------------------------------------------------------|-------|
| 💬 聊天系统 | • 心流/推理聊天<br>• 关键词主动发言<br>• 多模型支持<br>• 动态prompt构建<br>• 私聊功能(PFC) | 拟人化交互 |
| 🧠 心流系统 | • 实时思考生成<br>• 自动启停机制<br>• 日程系统联动<br>• 工具调用能力 | 智能化决策 |
| 🧠 记忆系统 | • 优化记忆抽取<br>• 海马体记忆机制<br>• 聊天记录概括 | 持久化记忆 |
| 😊 表情系统 | • 情绪匹配发送<br>• GIF支持<br>• 自动收集与审查 | 丰富表达 |
| 📅 日程系统 | • 动态日程生成<br>• 自定义想象力<br>• 思维流联动 | 智能规划 |
| 👥 关系系统 | • 关系管理优化<br>• 丰富接口支持<br>• 个性化交互 | 深度社交 |
| 📊 统计系统 | • 使用数据统计<br>• LLM调用记录<br>• 实时控制台显示 | 数据可视 |
| 🔧 系统功能 | • 优雅关闭机制<br>• 自动数据保存<br>• 异常处理完善 | 稳定可靠 |
| 🛠️ 工具系统 | • 知识获取工具<br>• 自动注册机制<br>• 多工具支持 | 扩展功能 |
## 📐 项目架构

View File

@@ -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()

View File

@@ -28,7 +28,7 @@ class TopicIdentifier:
消息内容:{text}"""
# 使用 LLM_request 类进行请求
# 使用 LLMRequest 类进行请求
try:
topic, _, _ = await self.llm_topic_judge.generate_response(prompt)
except Exception as e:

View File

@@ -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]