Merge pull request #1 from Dax233/PFC-fix

先规范个空格(
This commit is contained in:
SmartMita
2025-04-27 21:01:03 +09:00
committed by GitHub
10 changed files with 105 additions and 109 deletions

View File

@@ -279,7 +279,7 @@ class ActionPlanner:
final_reason = action_data.get("final_reason", "") final_reason = action_data.get("final_reason", "")
action_time = action_data.get("time", "") action_time = action_data.get("time", "")
elif isinstance(action_data, tuple): elif isinstance(action_data, tuple):
# 假设旧格式兼容 # 假设旧格式兼容
if len(action_data) > 0: action_type = action_data[0] if len(action_data) > 0: action_type = action_data[0]
if len(action_data) > 1: plan_reason = action_data[1] # 可能是规划原因或最终原因 if len(action_data) > 1: plan_reason = action_data[1] # 可能是规划原因或最终原因
if len(action_data) > 2: status = action_data[2] if len(action_data) > 2: status = action_data[2]
@@ -311,10 +311,10 @@ class ActionPlanner:
# --- 选择 Prompt --- # --- 选择 Prompt ---
if last_successful_reply_action in ['direct_reply', 'send_new_message']: if last_successful_reply_action in ['direct_reply', 'send_new_message']:
prompt_template = PROMPT_FOLLOW_UP prompt_template = PROMPT_FOLLOW_UP
logger.info("使用 PROMPT_FOLLOW_UP (追问决策)") logger.debug(f"使用 PROMPT_FOLLOW_UP (追问决策)")
else: else:
prompt_template = PROMPT_INITIAL_REPLY prompt_template = PROMPT_INITIAL_REPLY
logger.info("使用 PROMPT_INITIAL_REPLY (首次/非连续回复决策)") logger.debug("使用 PROMPT_INITIAL_REPLY (首次/非连续回复决策)")
# --- 格式化最终的 Prompt --- # --- 格式化最终的 Prompt ---
prompt = prompt_template.format( prompt = prompt_template.format(

View File

@@ -94,11 +94,9 @@ class ChatObserver:
""" """
try: try:
# 发送新消息通知 # 发送新消息通知
# logger.info(f"发送新ccchandleer消息通知: {message}")
notification = create_new_message_notification( notification = create_new_message_notification(
sender="chat_observer", target="observation_info", message=message sender="chat_observer", target="observation_info", message=message
) )
# logger.info(f"发送新消ddddd息通知: {notification}")
# print(self.notification_manager) # print(self.notification_manager)
await self.notification_manager.send_notification(notification) await self.notification_manager.send_notification(notification)
except Exception as e: except Exception as e:
@@ -289,7 +287,7 @@ class ChatObserver:
self._running = True self._running = True
self._task = asyncio.create_task(self._update_loop()) self._task = asyncio.create_task(self._update_loop())
logger.info(f"ChatObserver for {self.stream_id} started") logger.debug(f"ChatObserver for {self.stream_id} started")
def stop(self): def stop(self):
"""停止观察器""" """停止观察器"""
@@ -298,7 +296,7 @@ class ChatObserver:
self._update_complete.set() # 设置完成事件以解除等待 self._update_complete.set() # 设置完成事件以解除等待
if self._task: if self._task:
self._task.cancel() self._task.cancel()
logger.info(f"ChatObserver for {self.stream_id} stopped") logger.debug(f"ChatObserver for {self.stream_id} stopped")
async def process_chat_history(self, messages: list): async def process_chat_history(self, messages: list):
"""处理聊天历史 """处理聊天历史

View File

@@ -98,15 +98,11 @@ class NotificationManager:
notification_type: 要处理的通知类型 notification_type: 要处理的通知类型
handler: 处理器实例 handler: 处理器实例
""" """
# print(1145145511114445551111444)
if target not in self._handlers: if target not in self._handlers:
# print("没11有target")
self._handlers[target] = {} self._handlers[target] = {}
if notification_type not in self._handlers[target]: if notification_type not in self._handlers[target]:
# print("没11有notification_type")
self._handlers[target][notification_type] = [] self._handlers[target][notification_type] = []
# print(self._handlers[target][notification_type]) # print(self._handlers[target][notification_type])
# print(f"注册1111111111111111111111处理器: {target} {notification_type} {handler}")
self._handlers[target][notification_type].append(handler) self._handlers[target][notification_type].append(handler)
# print(self._handlers[target][notification_type]) # print(self._handlers[target][notification_type])
@@ -132,7 +128,6 @@ class NotificationManager:
async def send_notification(self, notification: Notification): async def send_notification(self, notification: Notification):
"""发送通知""" """发送通知"""
self._notification_history.append(notification) self._notification_history.append(notification)
# print("kaishichul-----------------------------------i")
# 如果是状态通知,更新活跃状态 # 如果是状态通知,更新活跃状态
if isinstance(notification, StateNotification): if isinstance(notification, StateNotification):
@@ -145,7 +140,6 @@ class NotificationManager:
target = notification.target target = notification.target
if target in self._handlers: if target in self._handlers:
handlers = self._handlers[target].get(notification.type, []) handlers = self._handlers[target].get(notification.type, [])
# print(1111111)
# print(handlers) # print(handlers)
for handler in handlers: for handler in handlers:
# print(f"调用处理器: {handler}") # print(f"调用处理器: {handler}")

View File

@@ -1,8 +1,10 @@
import time import time
import asyncio import asyncio
import datetime import datetime
# from .message_storage import MongoDBMessageStorage # from .message_storage import MongoDBMessageStorage
from src.plugins.utils.chat_message_builder import build_readable_messages, get_raw_msg_before_timestamp_with_chat from src.plugins.utils.chat_message_builder import build_readable_messages, get_raw_msg_before_timestamp_with_chat
# from ...config.config import global_config # from ...config.config import global_config
from typing import Dict, Any, Optional from typing import Dict, Any, Optional
from ..chat.message import Message from ..chat.message import Message
@@ -133,18 +135,18 @@ class Conversation:
while self.should_continue: while self.should_continue:
# 忽略逻辑 # 忽略逻辑
if self.ignore_until_timestamp and time.time() < self.ignore_until_timestamp: if self.ignore_until_timestamp and time.time() < self.ignore_until_timestamp:
await asyncio.sleep(30) await asyncio.sleep(30)
continue continue
elif self.ignore_until_timestamp and time.time() >= self.ignore_until_timestamp: elif self.ignore_until_timestamp and time.time() >= self.ignore_until_timestamp:
logger.info(f"忽略时间已到 {self.stream_id},准备结束对话。") logger.info(f"忽略时间已到 {self.stream_id},准备结束对话。")
self.ignore_until_timestamp = None self.ignore_until_timestamp = None
self.should_continue = False self.should_continue = False
continue continue
try: try:
# --- 在规划前记录当前新消息数量 --- # --- 在规划前记录当前新消息数量 ---
initial_new_message_count = 0 initial_new_message_count = 0
if hasattr(self.observation_info, "new_messages_count"): if hasattr(self.observation_info, "new_messages_count"):
initial_new_message_count = self.observation_info.new_messages_count initial_new_message_count = self.observation_info.new_messages_count + 1 # 算上麦麦自己发的那一条
else: else:
logger.warning("ObservationInfo missing 'new_messages_count' before planning.") logger.warning("ObservationInfo missing 'new_messages_count' before planning.")
@@ -237,13 +239,13 @@ class Conversation:
# 尝试从 msg_dict 直接获取 chat_stream如果失败则从全局 chat_manager 获取 # 尝试从 msg_dict 直接获取 chat_stream如果失败则从全局 chat_manager 获取
chat_info = msg_dict.get("chat_info") chat_info = msg_dict.get("chat_info")
if chat_info and isinstance(chat_info, dict): if chat_info and isinstance(chat_info, dict):
chat_stream = ChatStream.from_dict(chat_info) chat_stream = ChatStream.from_dict(chat_info)
elif self.chat_stream: # 使用实例变量中的 chat_stream elif self.chat_stream: # 使用实例变量中的 chat_stream
chat_stream = self.chat_stream chat_stream = self.chat_stream
else: # Fallback: 尝试从 manager 获取 (可能需要 stream_id) else: # Fallback: 尝试从 manager 获取 (可能需要 stream_id)
chat_stream = chat_manager.get_stream(self.stream_id) chat_stream = chat_manager.get_stream(self.stream_id)
if not chat_stream: if not chat_stream:
raise ValueError(f"无法确定 ChatStream for stream_id {self.stream_id}") raise ValueError(f"无法确定 ChatStream for stream_id {self.stream_id}")
user_info = UserInfo.from_dict(msg_dict.get("user_info", {})) user_info = UserInfo.from_dict(msg_dict.get("user_info", {}))
@@ -265,7 +267,7 @@ class Conversation:
): ):
"""处理规划的行动""" """处理规划的行动"""
logger.info(f"执行行动: {action}, 原因: {reason}") logger.debug(f"执行行动: {action}, 原因: {reason}")
# 记录action历史 (逻辑不变) # 记录action历史 (逻辑不变)
current_action_record = { current_action_record = {
@@ -306,7 +308,7 @@ class Conversation:
# 2. 检查回复 (逻辑不变) # 2. 检查回复 (逻辑不变)
self.state = ConversationState.CHECKING self.state = ConversationState.CHECKING
try: try:
current_goal_str = conversation_info.goal_list[0][0] if conversation_info.goal_list else "" current_goal_str = conversation_info.goal_list[0]["goal"] if conversation_info.goal_list else ""
is_suitable, check_reason, need_replan = await self.reply_generator.check_reply( is_suitable, check_reason, need_replan = await self.reply_generator.check_reply(
reply=self.generated_reply, reply=self.generated_reply,
goal=current_goal_str, goal=current_goal_str,
@@ -390,7 +392,7 @@ class Conversation:
# 2. 检查回复 # 2. 检查回复
self.state = ConversationState.CHECKING self.state = ConversationState.CHECKING
try: try:
current_goal_str = conversation_info.goal_list[0][0] if conversation_info.goal_list else "" current_goal_str = conversation_info.goal_list[0]["goal"] if conversation_info.goal_list else ""
is_suitable, check_reason, need_replan = await self.reply_generator.check_reply( is_suitable, check_reason, need_replan = await self.reply_generator.check_reply(
reply=self.generated_reply, reply=self.generated_reply,
goal=current_goal_str, goal=current_goal_str,
@@ -414,7 +416,7 @@ class Conversation:
# 循环结束,处理最终结果 # 循环结束,处理最终结果
if is_suitable: if is_suitable:
# 检查是否有新消息 # 检查是否有新消息
if self._check_new_messages_after_planning(): if self._check_new_messages_after_planning():
logger.info("生成首次回复期间收到新消息,取消发送,重新规划行动") logger.info("生成首次回复期间收到新消息,取消发送,重新规划行动")
conversation_info.done_action[action_index].update( conversation_info.done_action[action_index].update(
@@ -459,58 +461,58 @@ class Conversation:
try: try:
# 检查 knowledge_fetcher 是否存在 # 检查 knowledge_fetcher 是否存在
if not hasattr(self, 'knowledge_fetcher'): if not hasattr(self, 'knowledge_fetcher'):
logger.error("KnowledgeFetcher 未初始化,无法获取知识。") logger.error("KnowledgeFetcher 未初始化,无法获取知识。")
raise AttributeError("KnowledgeFetcher not initialized") raise AttributeError("KnowledgeFetcher not initialized")
knowledge, source = await self.knowledge_fetcher.fetch(knowledge_query, observation_info.chat_history) knowledge, source = await self.knowledge_fetcher.fetch(knowledge_query, observation_info.chat_history)
logger.info(f"获取到知识: {knowledge[:100]}..., 来源: {source}") logger.info(f"获取到知识: {knowledge[:100]}..., 来源: {source}")
if knowledge: if knowledge:
# 确保 knowledge_list 存在 # 确保 knowledge_list 存在
if not hasattr(conversation_info, 'knowledge_list'): if not hasattr(conversation_info, 'knowledge_list'):
conversation_info.knowledge_list = [] conversation_info.knowledge_list = []
conversation_info.knowledge_list.append({"query": knowledge_query, "knowledge": knowledge, "source": source}) conversation_info.knowledge_list.append({"query": knowledge_query, "knowledge": knowledge, "source": source})
action_successful = True action_successful = True
except Exception as fetch_err: except Exception as fetch_err:
logger.error(f"获取知识时出错: {fetch_err}") logger.error(f"获取知识时出错: {fetch_err}")
conversation_info.done_action[action_index].update( conversation_info.done_action[action_index].update(
{"status": "recall", "final_reason": f"获取知识失败: {fetch_err}"} {"status": "recall", "final_reason": f"获取知识失败: {fetch_err}"}
) )
self.conversation_info.last_successful_reply_action = None # 重置状态 self.conversation_info.last_successful_reply_action = None # 重置状态
elif action == "rethink_goal": elif action == "rethink_goal":
self.state = ConversationState.RETHINKING self.state = ConversationState.RETHINKING
try: try:
# 检查 goal_analyzer 是否存在 # 检查 goal_analyzer 是否存在
if not hasattr(self, 'goal_analyzer'): if not hasattr(self, 'goal_analyzer'):
logger.error("GoalAnalyzer 未初始化,无法重新思考目标。") logger.error("GoalAnalyzer 未初始化,无法重新思考目标。")
raise AttributeError("GoalAnalyzer not initialized") raise AttributeError("GoalAnalyzer not initialized")
await self.goal_analyzer.analyze_goal(conversation_info, observation_info) await self.goal_analyzer.analyze_goal(conversation_info, observation_info)
action_successful = True action_successful = True
except Exception as rethink_err: except Exception as rethink_err:
logger.error(f"重新思考目标时出错: {rethink_err}") logger.error(f"重新思考目标时出错: {rethink_err}")
conversation_info.done_action[action_index].update( conversation_info.done_action[action_index].update(
{"status": "recall", "final_reason": f"重新思考目标失败: {rethink_err}"} {"status": "recall", "final_reason": f"重新思考目标失败: {rethink_err}"}
) )
self.conversation_info.last_successful_reply_action = None # 重置状态 self.conversation_info.last_successful_reply_action = None # 重置状态
elif action == "listening": elif action == "listening":
self.state = ConversationState.LISTENING self.state = ConversationState.LISTENING
logger.info("倾听对方发言...") logger.info("倾听对方发言...")
try: try:
# 检查 waiter 是否存在 # 检查 waiter 是否存在
if not hasattr(self, 'waiter'): if not hasattr(self, 'waiter'):
logger.error("Waiter 未初始化,无法倾听。") logger.error("Waiter 未初始化,无法倾听。")
raise AttributeError("Waiter not initialized") raise AttributeError("Waiter not initialized")
timeout_occurred = await self.waiter.wait_listening(conversation_info) timeout_occurred = await self.waiter.wait_listening(conversation_info)
action_successful = True # Listening 完成就算成功 action_successful = True # Listening 完成就算成功
except Exception as listen_err: except Exception as listen_err:
logger.error(f"倾听时出错: {listen_err}") logger.error(f"倾听时出错: {listen_err}")
conversation_info.done_action[action_index].update( conversation_info.done_action[action_index].update(
{"status": "recall", "final_reason": f"倾听失败: {listen_err}"} {"status": "recall", "final_reason": f"倾听失败: {listen_err}"}
) )
self.conversation_info.last_successful_reply_action = None # 重置状态 self.conversation_info.last_successful_reply_action = None # 重置状态
elif action == "end_conversation": elif action == "end_conversation":
@@ -519,29 +521,29 @@ class Conversation:
action_successful = True # 标记动作成功 action_successful = True # 标记动作成功
elif action == "block_and_ignore": elif action == "block_and_ignore":
logger.info("不想再理你了...") logger.info("不想再理你了...")
ignore_duration_seconds = 10 * 60 ignore_duration_seconds = 10 * 60
self.ignore_until_timestamp = time.time() + ignore_duration_seconds self.ignore_until_timestamp = time.time() + ignore_duration_seconds
logger.info(f"将忽略此对话直到: {datetime.datetime.fromtimestamp(self.ignore_until_timestamp)}") logger.info(f"将忽略此对话直到: {datetime.datetime.fromtimestamp(self.ignore_until_timestamp)}")
self.state = ConversationState.IGNORED self.state = ConversationState.IGNORED
action_successful = True # 标记动作成功 action_successful = True # 标记动作成功
else: # 对应 'wait' 动作 else: # 对应 'wait' 动作
self.state = ConversationState.WAITING self.state = ConversationState.WAITING
logger.info("等待更多信息...") logger.info("等待更多信息...")
try: try:
# 检查 waiter 是否存在 # 检查 waiter 是否存在
if not hasattr(self, 'waiter'): if not hasattr(self, 'waiter'):
logger.error("Waiter 未初始化,无法等待。") logger.error("Waiter 未初始化,无法等待。")
raise AttributeError("Waiter not initialized") raise AttributeError("Waiter not initialized")
timeout_occurred = await self.waiter.wait(self.conversation_info) timeout_occurred = await self.waiter.wait(self.conversation_info)
action_successful = True # Wait 完成就算成功 action_successful = True # Wait 完成就算成功
except Exception as wait_err: except Exception as wait_err:
logger.error(f"等待时出错: {wait_err}") logger.error(f"等待时出错: {wait_err}")
conversation_info.done_action[action_index].update( conversation_info.done_action[action_index].update(
{"status": "recall", "final_reason": f"等待失败: {wait_err}"} {"status": "recall", "final_reason": f"等待失败: {wait_err}"}
) )
self.conversation_info.last_successful_reply_action = None # 重置状态 self.conversation_info.last_successful_reply_action = None # 重置状态
# --- 更新 Action History 状态 --- # --- 更新 Action History 状态 ---
# 只有当动作本身成功时,才更新状态为 done # 只有当动作本身成功时,才更新状态为 done
@@ -570,11 +572,11 @@ class Conversation:
# 发送消息 (确保 direct_sender 和 chat_stream 有效) # 发送消息 (确保 direct_sender 和 chat_stream 有效)
if not hasattr(self, 'direct_sender') or not self.direct_sender: if not hasattr(self, 'direct_sender') or not self.direct_sender:
logger.error("DirectMessageSender 未初始化,无法发送回复。") logger.error("DirectMessageSender 未初始化,无法发送回复。")
return return
if not self.chat_stream: if not self.chat_stream:
logger.error("ChatStream 未初始化,无法发送回复。") logger.error("ChatStream 未初始化,无法发送回复。")
return return
await self.direct_sender.send_message(chat_stream=self.chat_stream, content=reply_content) await self.direct_sender.send_message(chat_stream=self.chat_stream, content=reply_content)

View File

@@ -140,7 +140,6 @@ class ObservationInfo:
self.chat_observer.notification_manager.register_handler( self.chat_observer.notification_manager.register_handler(
target="observation_info", notification_type=NotificationType.COLD_CHAT, handler=self.handler target="observation_info", notification_type=NotificationType.COLD_CHAT, handler=self.handler
) )
print("1919810------------------------绑定-----------------------------")
def unbind_from_chat_observer(self): def unbind_from_chat_observer(self):
"""解除与chat_observer的绑定""" """解除与chat_observer的绑定"""
@@ -159,7 +158,6 @@ class ObservationInfo:
Args: Args:
message: 消息数据 message: 消息数据
""" """
# print("1919810-----------------------------------------------------")
# logger.debug(f"更新信息from_message: {message}") # logger.debug(f"更新信息from_message: {message}")
self.last_message_time = message["time"] self.last_message_time = message["time"]
self.last_message_id = message["message_id"] self.last_message_id = message["message_id"]

View File

@@ -250,15 +250,13 @@ class GoalAnalyzer:
async def analyze_conversation(self, goal, reasoning): async def analyze_conversation(self, goal, reasoning):
messages = self.chat_observer.get_cached_messages() messages = self.chat_observer.get_cached_messages()
chat_history_text = "" chat_history_text = await build_readable_messages(
for msg in messages: messages,
time_str = datetime.datetime.fromtimestamp(msg["time"]).strftime("%H:%M:%S") replace_bot_name=True,
user_info = UserInfo.from_dict(msg.get("user_info", {})) merge_messages=False,
sender = user_info.user_nickname or f"用户{user_info.user_id}" timestamp_mode="relative",
if sender == self.name: read_mark=0.0,
sender = "你说" )
chat_history_text += f"{time_str},{sender}:{msg.get('processed_plain_text', '')}\n"
identity_details_only = self.identity_detail_info identity_details_only = self.identity_detail_info
identity_addon = "" identity_addon = ""
if isinstance(identity_details_only, str): if isinstance(identity_details_only, str):

View File

@@ -5,6 +5,7 @@ from ..models.utils_model import LLMRequest
from ...config.config import global_config from ...config.config import global_config
from ..chat.message import Message from ..chat.message import Message
from ..knowledge.knowledge_lib import qa_manager from ..knowledge.knowledge_lib import qa_manager
from ..utils.chat_message_builder import build_readable_messages
logger = get_module_logger("knowledge_fetcher") logger = get_module_logger("knowledge_fetcher")
@@ -50,10 +51,13 @@ class KnowledgeFetcher:
Tuple[str, str]: (获取的知识, 知识来源) Tuple[str, str]: (获取的知识, 知识来源)
""" """
# 构建查询上下文 # 构建查询上下文
chat_history_text = "" chat_history_text = await build_readable_messages(
for msg in chat_history: chat_history,
# sender = msg.message_info.user_info.user_nickname or f"用户{msg.message_info.user_info.user_id}" replace_bot_name=True,
chat_history_text += f"{msg.detailed_plain_text}\n" merge_messages=False,
timestamp_mode="relative",
read_mark=0.0,
)
# 从记忆中获取相关知识 # 从记忆中获取相关知识
related_memory = await HippocampusManager.get_instance().get_memory_from_text( related_memory = await HippocampusManager.get_instance().get_memory_from_text(

View File

@@ -47,18 +47,20 @@ class PFCManager:
return self._instances[stream_id] return self._instances[stream_id]
if stream_id in self._instances: if stream_id in self._instances:
instance = self._instances[stream_id] instance = self._instances[stream_id]
if hasattr(instance, 'ignore_until_timestamp') and \ if (
instance.ignore_until_timestamp and \ hasattr(instance, "ignore_until_timestamp")
time.time() < instance.ignore_until_timestamp: and instance.ignore_until_timestamp
and time.time() < instance.ignore_until_timestamp
):
logger.debug(f"会话实例当前处于忽略状态: {stream_id}") logger.debug(f"会话实例当前处于忽略状态: {stream_id}")
# 返回 None 阻止交互。或者可以返回实例但标记它被忽略了喵? # 返回 None 阻止交互。或者可以返回实例但标记它被忽略了喵?
# 还是返回 None 吧喵。 # 还是返回 None 吧喵。
return None return None
# 检查 should_continue 状态 # 检查 should_continue 状态
if instance.should_continue: if instance.should_continue:
logger.debug(f"使用现有会话实例: {stream_id}") logger.debug(f"使用现有会话实例: {stream_id}")
return instance return instance
# else: 实例存在但不应继续 # else: 实例存在但不应继续
try: try:
# 创建新实例 # 创建新实例

View File

@@ -114,15 +114,15 @@ class ReplyGenerator:
# 获取聊天历史记录 (chat_history_text) # 获取聊天历史记录 (chat_history_text)
chat_history_text = observation_info.chat_history_str chat_history_text = observation_info.chat_history_str
if observation_info.new_messages_count > 0 and observation_info.unprocessed_messages: if observation_info.new_messages_count > 0 and observation_info.unprocessed_messages:
new_messages_list = observation_info.unprocessed_messages new_messages_list = observation_info.unprocessed_messages
new_messages_str = await build_readable_messages( new_messages_str = await build_readable_messages(
new_messages_list, new_messages_list,
replace_bot_name=True, replace_bot_name=True,
merge_messages=False, merge_messages=False,
timestamp_mode="relative", timestamp_mode="relative",
read_mark=0.0, read_mark=0.0,
) )
chat_history_text += f"\n--- 以下是 {observation_info.new_messages_count} 条新消息 ---\n{new_messages_str}" chat_history_text += f"\n--- 以下是 {observation_info.new_messages_count} 条新消息 ---\n{new_messages_str}"
elif not chat_history_text: elif not chat_history_text:
chat_history_text = "还没有聊天记录。" chat_history_text = "还没有聊天记录。"
@@ -162,7 +162,7 @@ class ReplyGenerator:
logger.debug(f"发送到LLM的生成提示词:\n------\n{prompt}\n------") logger.debug(f"发送到LLM的生成提示词:\n------\n{prompt}\n------")
try: try:
content, _ = await self.llm.generate_response_async(prompt) content, _ = await self.llm.generate_response_async(prompt)
logger.info(f"生成的回复: {content}") logger.debug(f"生成的回复: {content}")
# 移除旧的检查新消息逻辑,这应该由 conversation 控制流处理 # 移除旧的检查新消息逻辑,这应该由 conversation 控制流处理
return content return content

View File

@@ -46,7 +46,7 @@ class Waiter:
return True # 返回 True 表示超时 return True # 返回 True 表示超时
await asyncio.sleep(5) # 每 5 秒检查一次 await asyncio.sleep(5) # 每 5 秒检查一次
logger.info("等待中...") # 可以考虑把这个频繁日志注释掉,只在超时或收到消息时输出 logger.debug("等待中...") # 可以考虑把这个频繁日志注释掉,只在超时或收到消息时输出
async def wait_listening(self, conversation_info: ConversationInfo) -> bool: async def wait_listening(self, conversation_info: ConversationInfo) -> bool:
"""倾听用户发言或超时""" """倾听用户发言或超时"""
@@ -73,4 +73,4 @@ class Waiter:
return True # 返回 True 表示超时 return True # 返回 True 表示超时
await asyncio.sleep(5) # 每 5 秒检查一次 await asyncio.sleep(5) # 每 5 秒检查一次
logger.info("倾听等待中...") # 同上,可以考虑注释掉 logger.debug("倾听等待中...") # 同上,可以考虑注释掉