diff --git a/src/plugins/PFC/chat_observer.py b/src/plugins/PFC/chat_observer.py index 395b14043..93618cf2d 100644 --- a/src/plugins/PFC/chat_observer.py +++ b/src/plugins/PFC/chat_observer.py @@ -421,15 +421,15 @@ class ChatObserver: logger.error(f"更新消息历史时出错: {str(e)}") return False - def get_message_history(self, limit: int = 50) -> List[Dict[str, Any]]: - """获取消息历史 + def get_cached_messages(self, limit: int = 50) -> List[Dict[str, Any]]: + """获取缓存的消息历史 Args: - limit: 获取的最大消息数量 + limit: 获取的最大消息数量,默认50 Returns: - List[Dict[str, Any]]: 消息历史列表 - """ + List[Dict[str, Any]]: 缓存的消息历史列表 + """ return self.message_cache[:limit] def get_last_message(self) -> Optional[Dict[str, Any]]: diff --git a/src/plugins/PFC/conversation.py b/src/plugins/PFC/conversation.py index fecac1523..dda380491 100644 --- a/src/plugins/PFC/conversation.py +++ b/src/plugins/PFC/conversation.py @@ -204,7 +204,7 @@ class Conversation: async def _send_timeout_message(self): """发送超时结束消息""" try: - messages = self.chat_observer.get_message_history(limit=1) + messages = self.chat_observer.get_cached_messages(limit=1) if not messages: return @@ -223,7 +223,7 @@ class Conversation: logger.warning("没有生成回复") return - messages = self.chat_observer.get_message_history(limit=1) + messages = self.chat_observer.get_cached_messages(limit=1) if not messages: logger.warning("没有最近的消息可以回复") return diff --git a/src/plugins/PFC/pfc.py b/src/plugins/PFC/pfc.py index 25c4728e0..62b28acb4 100644 --- a/src/plugins/PFC/pfc.py +++ b/src/plugins/PFC/pfc.py @@ -195,7 +195,7 @@ class GoalAnalyzer: return self.goals[1:].copy() async def analyze_conversation(self, goal, reasoning): - messages = self.chat_observer.get_message_history() + messages = self.chat_observer.get_cached_messages() chat_history_text = "" for msg in messages: time_str = datetime.datetime.fromtimestamp(msg["time"]).strftime("%H:%M:%S") diff --git a/src/plugins/PFC/reply_checker.py b/src/plugins/PFC/reply_checker.py index c53feba9b..6889f7ca8 100644 --- a/src/plugins/PFC/reply_checker.py +++ b/src/plugins/PFC/reply_checker.py @@ -33,7 +33,7 @@ class ReplyChecker: Tuple[bool, str, bool]: (是否合适, 原因, 是否需要重新规划) """ # 获取最新的消息记录 - messages = self.chat_observer.get_message_history(limit=5) + messages = self.chat_observer.get_cached_messages(limit=5) chat_history_text = "" for msg in messages: time_str = datetime.datetime.fromtimestamp(msg["time"]).strftime("%H:%M:%S")