refactor(PFC): 将424行get_message_history方法重命名为get_cached_messages防止Ruff炸掉喵
This commit is contained in:
@@ -421,14 +421,14 @@ 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]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user