feat:可以自定义连续回复次数

This commit is contained in:
SengokuCola
2025-05-29 22:45:07 +08:00
parent a23ca3c43d
commit 75416a7a6a
6 changed files with 56 additions and 11 deletions

View File

@@ -143,20 +143,32 @@ class ActionModifier:
result["remove"].append("no_reply")
result["remove"].append("reply")
# 获取最近次的reply状态
last_three = reply_sequence[-3:] if len(reply_sequence) >= 3 else reply_sequence
# 获取最近max_reply_num次的reply状态
max_reply_num = int(global_config.focus_chat.consecutive_replies * 3)
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
# 根据最近的reply情况决定是否移除reply动作
if len(last_three) >= 3 and all(last_three):
# 如果最近次都是reply直接移除
if len(last_max_reply_num) >= max_reply_num and all(last_max_reply_num):
# 如果最近max_reply_num次都是reply直接移除
result["remove"].append("reply")
elif len(last_three) >= 2 and all(last_three[-2:]):
# 如果最近两次都是reply40%概率移除
if random.random() < 0.4:
logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply{len(last_max_reply_num) - no_reply_count}次reply直接移除")
elif len(last_max_reply_num) >= sec_thres_reply_num and all(last_max_reply_num[-sec_thres_reply_num:]):
# 如果最近sec_thres_reply_num次都是reply40%概率移除
if random.random() < 0.4 / global_config.focus_chat.consecutive_replies:
result["remove"].append("reply")
elif last_three and last_three[-1]:
# 如果最近一次是reply20%概率移除
if random.random() < 0.2:
logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply{len(last_max_reply_num) - no_reply_count}次reply{0.4 / global_config.focus_chat.consecutive_replies}概率移除,移除")
else:
logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply{len(last_max_reply_num) - no_reply_count}次reply{0.4 / global_config.focus_chat.consecutive_replies}概率移除,不移除")
elif len(last_max_reply_num) >= one_thres_reply_num and all(last_max_reply_num[-one_thres_reply_num:]):
# 如果最近one_thres_reply_num次都是reply20%概率移除
if random.random() < 0.2 / global_config.focus_chat.consecutive_replies:
result["remove"].append("reply")
logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply{len(last_max_reply_num) - no_reply_count}次reply{0.2 / global_config.focus_chat.consecutive_replies}概率移除,移除")
else:
logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply{len(last_max_reply_num) - no_reply_count}次reply{0.2 / global_config.focus_chat.consecutive_replies}概率移除,不移除")
else:
logger.debug(f"最近{len(last_max_reply_num)}次回复中,有{no_reply_count}次no_reply{len(last_max_reply_num) - no_reply_count}次reply无需移除")
return result

View File

@@ -885,6 +885,17 @@ API_SERVER_STYLE_CONFIG = {
},
}
ACTION_MANAGER_STYLE_CONFIG = {
"advanced": {
"console_format": "<level>{time:HH:mm:ss}</level> | <fg #AFA04F>动作选择</fg #AFA04F> | <fg #AFA04F>{message}</fg #AFA04F>",
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 动作选择 | {message}",
},
"simple": {
"console_format": "<level>{time:HH:mm:ss}</level> | <fg #AFA04F>动作选择</fg #AFA04F> | <fg #AFA04F>{message}</fg #AFA04F>",
"file_format": "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {extra[module]: <15} | 动作选择 | {message}",
},
}
# maim_message 消息服务样式配置
MAIM_MESSAGE_STYLE_CONFIG = {
"advanced": {
@@ -909,6 +920,9 @@ EMOJI_STYLE_CONFIG = EMOJI_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else EMOJI_ST
PFC_ACTION_PLANNER_STYLE_CONFIG = (
PFC_ACTION_PLANNER_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else PFC_ACTION_PLANNER_STYLE_CONFIG["advanced"]
)
ACTION_MANAGER_STYLE_CONFIG = (
ACTION_MANAGER_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else ACTION_MANAGER_STYLE_CONFIG["advanced"]
)
REMOTE_STYLE_CONFIG = REMOTE_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else REMOTE_STYLE_CONFIG["advanced"]
BASE_TOOL_STYLE_CONFIG = BASE_TOOL_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else BASE_TOOL_STYLE_CONFIG["advanced"]
PERSON_INFO_STYLE_CONFIG = PERSON_INFO_STYLE_CONFIG["simple"] if SIMPLE_OUTPUT else PERSON_INFO_STYLE_CONFIG["advanced"]

View File

@@ -48,6 +48,7 @@ from src.common.logger import (
API_SERVER_STYLE_CONFIG,
NORMAL_CHAT_RESPONSE_STYLE_CONFIG,
EXPRESS_STYLE_CONFIG,
ACTION_MANAGER_STYLE_CONFIG,
)
# 可根据实际需要补充更多模块配置
@@ -100,6 +101,7 @@ MODULE_LOGGER_CONFIGS = {
"normal_chat": NORMAL_CHAT_STYLE_CONFIG, # 一般水群
"focus_chat": FOCUS_CHAT_STYLE_CONFIG, # 专注水群
"expressor": EXPRESS_STYLE_CONFIG, # 麦麦表达
"action_manager": ACTION_MANAGER_STYLE_CONFIG, # 动作选择
# ...如有更多模块,继续添加...
}

View File

@@ -143,6 +143,9 @@ class FocusChatConfig(ConfigBase):
think_interval: int = 1
"""思考间隔(秒)"""
consecutive_replies: int = 1
"""连续回复能力,值越高,麦麦连续回复的概率越高"""
@dataclass