refactor(chat): 统一异步调用模式并修复循环依赖

- 将 chat_manager.get_stream() 调用改为异步
- 将 replyer_manager.get_replyer() 方法改为异步
- 在 generator_api 中使用动态导入避免循环依赖
- 在 action_manager 中添加待处理动作队列清理
- 更新所有相关调用点以支持异步模式
This commit is contained in:
Windpicker-owo
2025-10-05 18:30:16 +08:00
parent 4cdc5fc89d
commit 3e37b7cef5
6 changed files with 18 additions and 14 deletions

View File

@@ -9,7 +9,7 @@ class ReplyerManager:
def __init__(self):
self._repliers: dict[str, DefaultReplyer] = {}
def get_replyer(
async def get_replyer(
self,
chat_stream: ChatStream | None = None,
chat_id: str | None = None,
@@ -37,7 +37,7 @@ class ReplyerManager:
target_stream = chat_stream
if not target_stream:
if chat_manager := get_chat_manager():
target_stream = chat_manager.get_stream(stream_id)
target_stream = await chat_manager.get_stream(stream_id)
if not target_stream:
logger.warning(f"[ReplyerManager] 未找到 stream_id='{stream_id}' 的聊天流,无法创建回复器。")