refactor(chat): 重构关系系统并优化消息打断处理机制

- 移除独立的RelationshipConfig,将关系追踪参数整合到AffinityFlowConfig
- 实现消息打断后立即重新处理流程,提升交互响应性
- 优化关系追踪系统,添加概率筛选和超时保护机制
- 改进机器人自引用处理,确保消息内容正确显示
- 增强用户信息提取逻辑,兼容多种消息格式
- 添加异步后台任务处理,避免阻塞主回复流程
- 调整兴趣评分阈值和权重参数,优化消息匹配精度
This commit is contained in:
Windpicker-owo
2025-10-08 22:33:10 +08:00
parent b3ae8e4f1a
commit dd1444cc41
13 changed files with 368 additions and 107 deletions

View File

@@ -42,7 +42,6 @@ class StreamContext(BaseDataModel):
processing_task: asyncio.Task | None = None
interruption_count: int = 0 # 打断计数器
last_interruption_time: float = 0.0 # 上次打断时间
afc_threshold_adjustment: float = 0.0 # afc阈值调整量
# 独立分发周期字段
next_check_time: float = field(default_factory=time.time) # 下次检查时间
@@ -140,23 +139,14 @@ class StreamContext(BaseDataModel):
await self._sync_interruption_count_to_stream()
async def reset_interruption_count(self):
"""重置打断计数和afc阈值调整"""
"""重置打断计数"""
self.interruption_count = 0
self.last_interruption_time = 0.0
self.afc_threshold_adjustment = 0.0
# 同步打断计数到ChatStream
await self._sync_interruption_count_to_stream()
def apply_interruption_afc_reduction(self, reduction_value: float):
"""应用打断导致的afc阈值降低"""
self.afc_threshold_adjustment += reduction_value
logger.debug(f"应用afc阈值降低: {reduction_value}, 总调整量: {self.afc_threshold_adjustment}")
def get_afc_threshold_adjustment(self) -> float:
"""获取当前的afc阈值调整量"""
return self.afc_threshold_adjustment
async def _sync_interruption_count_to_stream(self):
"""同步打断计数到ChatStream"""
try: