fix:更好的连续回复控制

This commit is contained in:
SengokuCola
2025-05-29 23:17:11 +08:00
parent 27c8389b36
commit 57f8afed1f
3 changed files with 21 additions and 8 deletions

View File

@@ -133,7 +133,7 @@ class ActionModifier:
reply_sequence.append(action_type == "reply")
# 检查no_reply比例
print(f"no_reply_count: {no_reply_count}, len(recent_cycles): {len(recent_cycles)}")
# print(f"no_reply_count: {no_reply_count}, len(recent_cycles): {len(recent_cycles)}")
# print(1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111)
if len(recent_cycles) >= (5 * global_config.chat.exit_focus_threshold) and (
no_reply_count / len(recent_cycles)
@@ -143,11 +143,24 @@ class ActionModifier:
result["remove"].append("no_reply")
result["remove"].append("reply")
# 获取最近max_reply_num次的reply状态
max_reply_num = int(global_config.focus_chat.consecutive_replies * 3)
# 计算连续回复的相关阈值
max_reply_num = int(global_config.focus_chat.consecutive_replies * 3.2)
sec_thres_reply_num = int(global_config.focus_chat.consecutive_replies * 2)
one_thres_reply_num = int(global_config.focus_chat.consecutive_replies * 1)
last_max_reply_num = reply_sequence[-max_reply_num:] if len(reply_sequence) >= max_reply_num else reply_sequence
one_thres_reply_num = int(global_config.focus_chat.consecutive_replies * 1.5)
# 获取最近max_reply_num次的reply状态
if len(reply_sequence) >= max_reply_num:
last_max_reply_num = reply_sequence[-max_reply_num:]
else:
last_max_reply_num = reply_sequence[:]
# 详细打印阈值和序列信息,便于调试
logger.debug(
f"连续回复阈值: max={max_reply_num}, sec={sec_thres_reply_num}, one={one_thres_reply_num}"
f"最近reply序列: {last_max_reply_num}"
)
# print(f"consecutive_replies: {consecutive_replies}")
# 根据最近的reply情况决定是否移除reply动作
if len(last_max_reply_num) >= max_reply_num and all(last_max_reply_num):

View File

@@ -239,7 +239,7 @@ class Hippocampus:
# 不再需要 time_info 参数
prompt = (
f'这是一段文字:\n{text}\n\n我想让你基于这段文字来概括"{topic}"这个概念,帮我总结成一句自然的话,'
f"要求包含对这个概念的定义,内容,知识,可以包含时间和人物。只输出这句话就好"
f"要求包含对这个概念的定义,内容,知识,但是这些信息必须来自这段文字,不能添加信息。\n,请包含时间和人物。只输出这句话就好"
)
return prompt

View File

@@ -141,10 +141,10 @@ class FocusChatConfig(ConfigBase):
compress_length_limit: int = 5
"""最多压缩份数,超过该数值的压缩上下文会被删除"""
think_interval: int = 1
think_interval: float = 1
"""思考间隔(秒)"""
consecutive_replies: int = 1
consecutive_replies: float = 1
"""连续回复能力,值越高,麦麦连续回复的概率越高"""