fix:添加hfc调试功能,一键999

This commit is contained in:
SengokuCola
2025-04-23 23:55:35 +08:00
parent 2bf72d9e58
commit 58305c3dd1
4 changed files with 29 additions and 16 deletions

View File

@@ -214,7 +214,8 @@ class InterestMonitorApp:
interest_level = subflow_entry.get("interest_level") interest_level = subflow_entry.get("interest_level")
# 获取 group_name如果不存在则回退到 stream_id # 获取 group_name如果不存在则回退到 stream_id
group_name = subflow_entry.get("group_name", stream_id) group_name = subflow_entry.get("group_name", stream_id)
reply_probability = subflow_entry.get("reply_probability") # 获取概率值 # reply_probability = subflow_entry.get("reply_probability") # 获取概率值 # <-- 注释掉旧行
start_hfc_probability = subflow_entry.get("start_hfc_probability") # <-- 添加新行,读取新字段
# *** 检查必要的字段 *** # *** 检查必要的字段 ***
# 注意:时间戳已在顶层检查过 # 注意:时间戳已在顶层检查过
@@ -252,10 +253,12 @@ class InterestMonitorApp:
new_stream_history[stream_id].append((entry_timestamp, interest_level_float)) new_stream_history[stream_id].append((entry_timestamp, interest_level_float))
# 添加概率数据点 (如果存在且有效) # 添加概率数据点 (如果存在且有效)
if reply_probability is not None: # if reply_probability is not None: # <-- 注释掉旧判断
if start_hfc_probability is not None: # <-- 修改判断条件
try: try:
# 尝试将概率转换为浮点数 # 尝试将概率转换为浮点数
probability_float = float(reply_probability) # probability_float = float(reply_probability) # <-- 注释掉旧转换
probability_float = float(start_hfc_probability) # <-- 使用新变量
new_probability_history[stream_id].append((entry_timestamp, probability_float)) new_probability_history[stream_id].append((entry_timestamp, probability_float))
except (TypeError, ValueError): except (TypeError, ValueError):
# 如果概率值无效,可以跳过或记录一个默认值,这里跳过 # 如果概率值无效,可以跳过或记录一个默认值,这里跳过
@@ -410,13 +413,13 @@ class InterestMonitorApp:
# 设置子图标题和标签 # 设置子图标题和标签
self.ax_single_interest.set_title("兴趣度") self.ax_single_interest.set_title("兴趣度")
self.ax_single_interest.set_ylabel("兴趣度")
self.ax_single_interest.grid(True)
self.ax_single_interest.set_ylim(0, 10) # 固定 Y 轴范围 0-10 self.ax_single_interest.set_ylim(0, 10) # 固定 Y 轴范围 0-10
self.ax_single_probability.set_title("回复评估概率") # self.ax_single_probability.set_title("回复评估概率") # <-- 注释掉旧标题
self.ax_single_probability.set_title("HFC 启动概率") # <-- 修改标题
self.ax_single_probability.set_xlabel("时间") self.ax_single_probability.set_xlabel("时间")
self.ax_single_probability.set_ylabel("概率") # self.ax_single_probability.set_ylabel("概率") # <-- 注释掉旧标签
self.ax_single_probability.set_ylabel("HFC 概率") # <-- 修改 Y 轴标签
self.ax_single_probability.grid(True) self.ax_single_probability.grid(True)
self.ax_single_probability.set_ylim(0, 1.05) # 固定 Y 轴范围 0-1 self.ax_single_probability.set_ylim(0, 1.05) # 固定 Y 轴范围 0-1
self.ax_single_probability.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M:%S")) self.ax_single_probability.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M:%S"))

View File

@@ -136,10 +136,8 @@ class InterestLogger:
"sub_mind": state.get("current_mind", "未知"), "sub_mind": state.get("current_mind", "未知"),
"sub_chat_state": state.get("chat_state", "未知"), "sub_chat_state": state.get("chat_state", "未知"),
"interest_level": interest_state.get("interest_level", 0.0), "interest_level": interest_state.get("interest_level", 0.0),
"reply_probability": interest_state.get("current_reply_probability", 0.0), "start_hfc_probability": interest_state.get("start_hfc_probability", 0.0),
"is_above_threshold": interest_state.get("is_above_threshold", False), "is_above_threshold": interest_state.get("is_above_threshold", False),
"last_active_time": state.get("last_active_time", 0.0),
"last_interaction_time": interest_state.get("last_interaction_time", 0.0),
} }
subflow_details.append(subflow_entry) subflow_details.append(subflow_entry)

View File

@@ -13,6 +13,11 @@ mai_state_config = LogConfig(
logger = get_module_logger("mai_state_manager", config=mai_state_config) logger = get_module_logger("mai_state_manager", config=mai_state_config)
enable_unlimited_hfc_chat = False
class MaiState(enum.Enum): class MaiState(enum.Enum):
""" """
聊天状态: 聊天状态:
@@ -28,6 +33,11 @@ class MaiState(enum.Enum):
FOCUSED_CHAT = "专心聊天" FOCUSED_CHAT = "专心聊天"
def get_normal_chat_max_num(self): def get_normal_chat_max_num(self):
# 调试用
if enable_unlimited_hfc_chat:
return 1000
if self == MaiState.OFFLINE: if self == MaiState.OFFLINE:
return 0 return 0
elif self == MaiState.PEEKING: elif self == MaiState.PEEKING:
@@ -38,6 +48,10 @@ class MaiState(enum.Enum):
return 2 return 2
def get_focused_chat_max_num(self): def get_focused_chat_max_num(self):
# 调试用
if enable_unlimited_hfc_chat:
return 1000
if self == MaiState.OFFLINE: if self == MaiState.OFFLINE:
return 0 return 0
elif self == MaiState.PEEKING: elif self == MaiState.PEEKING:
@@ -125,11 +139,11 @@ class MaiStateManager:
if current_status == MaiState.OFFLINE: if current_status == MaiState.OFFLINE:
logger.info("当前[离线],没看手机,思考要不要上线看看......") logger.info("当前[离线],没看手机,思考要不要上线看看......")
elif current_status == MaiState.PEEKING: elif current_status == MaiState.PEEKING:
logger.info("当前[在窥屏],思考要不要继续聊下去......") logger.info("当前[看一眼],思考要不要继续聊下去......")
elif current_status == MaiState.NORMAL_CHAT: elif current_status == MaiState.NORMAL_CHAT:
logger.info("当前在[随便看]思考要不要继续聊下去......") logger.info("当前在[正常聊天]思考要不要继续聊下去......")
elif current_status == MaiState.FOCUSED_CHAT: elif current_status == MaiState.FOCUSED_CHAT:
logger.info("当前在[专心]思考要不要继续聊下去......") logger.info("当前在[专心聊天]思考要不要继续聊下去......")
# 1. 麦麦每分钟都有概率离线 # 1. 麦麦每分钟都有概率离线
if time_since_last_min_check >= 60: if time_since_last_min_check >= 60:

View File

@@ -176,10 +176,8 @@ class InterestChatting:
interest = self.interest_level # 直接使用属性值 interest = self.interest_level # 直接使用属性值
return { return {
"interest_level": round(interest, 2), "interest_level": round(interest, 2),
"last_update_time": self.last_update_time, "start_hfc_probability": round(self.start_hfc_probability, 4),
"current_reply_probability": round(self.current_reply_probability, 4),
"is_above_threshold": self.is_above_threshold, "is_above_threshold": self.is_above_threshold,
"last_interaction_time": self.last_interaction_time,
} }
async def should_evaluate_reply(self) -> bool: async def should_evaluate_reply(self) -> bool: