修了点pyright错误喵~

This commit is contained in:
ikun-11451
2025-11-29 20:40:21 +08:00
parent 311a161941
commit f0b6a969d5
17 changed files with 194 additions and 37 deletions

View File

@@ -23,6 +23,9 @@ class StreamLoopManager:
"""流循环管理器 - 每个流一个独立的无限循环任务"""
def __init__(self, max_concurrent_streams: int | None = None):
if global_config is None:
raise RuntimeError("Global config is not initialized")
# 统计信息
self.stats: dict[str, Any] = {
"active_streams": 0,
@@ -246,6 +249,8 @@ class StreamLoopManager:
# 4. 激活chatter处理
try:
if global_config is None:
raise RuntimeError("Global config is not initialized")
success = await asyncio.wait_for(self._process_stream_messages(stream_id, context), global_config.chat.thinking_timeout)
except asyncio.TimeoutError:
logger.warning(f"⏱️ [流工作器] stream={stream_id[:8]}, 任务ID={task_id}, 处理超时")
@@ -444,7 +449,6 @@ class StreamLoopManager:
except Exception as e:
logger.warning(f"刷新StreamContext缓存失败: stream={stream_id}, error={e}")
return []
async def _update_stream_energy(self, stream_id: str, context: Any) -> None:
"""更新流的能量值
@@ -452,6 +456,9 @@ class StreamLoopManager:
stream_id: 流ID
context: 流上下文 (StreamContext)
"""
if global_config is None:
raise RuntimeError("Global config is not initialized")
try:
from src.chat.message_receive.chat_stream import get_chat_manager
@@ -509,6 +516,9 @@ class StreamLoopManager:
Returns:
float: 间隔时间(秒)
"""
if global_config is None:
raise RuntimeError("Global config is not initialized")
# 基础间隔
base_interval = getattr(global_config.chat, "distribution_interval", 5.0)