refactor(chat): 将 get_chat_type_and_target_info 重构为异步函数
将 `get_chat_type_and_target_info` 函数从同步改为异步,以支持其内部对异步方法 `person_info_manager.get_values` 的调用。 此更改可防止在获取聊天对象信息时阻塞事件循环。所有调用此函数的代码(包括 `SubHeartflow`, `ActionModifier`, `PlanGenerator`, `DefaultReplyer`)都已相应更新为使用 `await`。 在 `DefaultReplyer` 中引入了延迟异步初始化模式 (`_async_init`),以适应其类生命周期。
This commit is contained in:
committed by
Windpicker-owo
parent
988bf7f7ab
commit
69c6829aed
@@ -24,7 +24,7 @@ class SubHeartflow:
|
||||
self.subheartflow_id = subheartflow_id
|
||||
self.chat_id = subheartflow_id
|
||||
|
||||
self.is_group_chat, self.chat_target_info = get_chat_type_and_target_info(self.chat_id)
|
||||
self.is_group_chat, self.chat_target_info = (None, None)
|
||||
self.log_prefix = get_chat_manager().get_stream_name(self.subheartflow_id) or self.subheartflow_id
|
||||
|
||||
# focus模式退出冷却时间管理
|
||||
@@ -38,4 +38,5 @@ class SubHeartflow:
|
||||
|
||||
async def initialize(self):
|
||||
"""异步初始化方法,创建兴趣流并确定聊天类型"""
|
||||
self.is_group_chat, self.chat_target_info = await get_chat_type_and_target_info(self.chat_id)
|
||||
await self.heart_fc_instance.start()
|
||||
|
||||
Reference in New Issue
Block a user