refactor(chat): 优化异步任务处理和消息管理逻辑

- 使用asyncio.create_task替代await调用,提升并发性能
- 简化流管理器的槽位获取逻辑,移除回退方案
- 重构上下文管理器的消息添加和更新机制
- 移除StreamContext中的冗余方法,保持数据模型的简洁性
- 优化兴趣度评分系统的更新流程,减少阻塞操作

这些改动主要关注性能优化和代码结构简化,不涉及功能变更。
This commit is contained in:
Windpicker-owo
2025-10-05 15:17:30 +08:00
parent 5edf50705c
commit 23e523c7b9
9 changed files with 92 additions and 255 deletions

View File

@@ -287,13 +287,13 @@ class DefaultReplyer:
try:
# 构建 Prompt
with Timer("构建Prompt", {}): # 内部计时器,可选保留
prompt = await asyncio.create_task(self.build_prompt_reply_context(
prompt = await self.build_prompt_reply_context(
reply_to=reply_to,
extra_info=extra_info,
available_actions=available_actions,
enable_tool=enable_tool,
reply_message=reply_message,
))
)
if not prompt:
logger.warning("构建prompt失败跳过回复生成")