Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
This commit is contained in:
@@ -660,7 +660,6 @@ class HeartFChatting:
|
||||
}
|
||||
|
||||
with Timer("执行动作", cycle_timers):
|
||||
|
||||
action_type, action_data, reasoning = (
|
||||
plan_result.get("action_result", {}).get("action_type", "error"),
|
||||
plan_result.get("action_result", {}).get("action_data", {}),
|
||||
|
||||
@@ -62,19 +62,19 @@ def init_prompt():
|
||||
"simple_planner_prompt_private",
|
||||
)
|
||||
|
||||
# Prompt(
|
||||
# """
|
||||
# 动作:{action_name}
|
||||
# 该动作的描述:{action_description}
|
||||
# 使用该动作的场景:
|
||||
# {action_require}
|
||||
# 输出要求:
|
||||
# {{
|
||||
# "action": "{action_name}",{action_parameters}
|
||||
# }}
|
||||
# """,
|
||||
# "action_prompt",
|
||||
# )
|
||||
# Prompt(
|
||||
# """
|
||||
# 动作:{action_name}
|
||||
# 该动作的描述:{action_description}
|
||||
# 使用该动作的场景:
|
||||
# {action_require}
|
||||
# 输出要求:
|
||||
# {{
|
||||
# "action": "{action_name}",{action_parameters}
|
||||
# }}
|
||||
# """,
|
||||
# "action_prompt",
|
||||
# )
|
||||
Prompt(
|
||||
"""
|
||||
{action_require}
|
||||
@@ -96,7 +96,6 @@ def init_prompt():
|
||||
)
|
||||
|
||||
|
||||
|
||||
class ActionPlanner(BasePlanner):
|
||||
def __init__(self, log_prefix: str, action_manager: ActionManager):
|
||||
super().__init__(log_prefix, action_manager)
|
||||
@@ -170,7 +169,9 @@ class ActionPlanner(BasePlanner):
|
||||
# 如果获取成功,更新is_group_chat
|
||||
if is_group_chat_updated is not None:
|
||||
is_group_chat = is_group_chat_updated
|
||||
logger.debug(f"{self.log_prefix}获取到聊天信息 - 群聊: {is_group_chat}, 目标信息: {chat_target_info}")
|
||||
logger.debug(
|
||||
f"{self.log_prefix}获取到聊天信息 - 群聊: {is_group_chat}, 目标信息: {chat_target_info}"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"{self.log_prefix}获取聊天目标信息失败: {e}")
|
||||
chat_target_info = None
|
||||
|
||||
@@ -59,8 +59,6 @@ class ReplyAction(BaseAction):
|
||||
|
||||
start_time = self.action_data.get("loop_start_time", time.time())
|
||||
|
||||
|
||||
|
||||
try:
|
||||
success, reply_set = await generator_api.generate_reply(
|
||||
chat_stream=self.chat_stream,
|
||||
@@ -70,7 +68,6 @@ class ReplyAction(BaseAction):
|
||||
is_group=self.is_group,
|
||||
)
|
||||
|
||||
|
||||
# 检查从start_time以来的新消息数量
|
||||
# 获取动作触发时间或使用默认值
|
||||
current_time = time.time()
|
||||
@@ -91,16 +88,15 @@ class ReplyAction(BaseAction):
|
||||
data = reply_seg[1]
|
||||
if not first_replyed:
|
||||
if need_reply:
|
||||
await self.send_text(content=data, reply_to=self.action_data.get("reply_to", ""),typing=False)
|
||||
await self.send_text(content=data, reply_to=self.action_data.get("reply_to", ""), typing=False)
|
||||
first_replyed = True
|
||||
else:
|
||||
await self.send_text(content=data,typing=False)
|
||||
await self.send_text(content=data, typing=False)
|
||||
first_replyed = True
|
||||
else:
|
||||
await self.send_text(content=data,typing=True)
|
||||
await self.send_text(content=data, typing=True)
|
||||
reply_text += data
|
||||
|
||||
|
||||
# 存储动作记录
|
||||
await self.store_action_info(
|
||||
action_build_into_prompt=False,
|
||||
@@ -181,17 +177,14 @@ class NoReplyAction(BaseAction):
|
||||
start_time=start_time - 300, # 获取开始前5分钟内的消息
|
||||
end_time=start_time,
|
||||
limit=5,
|
||||
limit_mode="latest"
|
||||
limit_mode="latest",
|
||||
)
|
||||
|
||||
# 构建上下文字符串
|
||||
context_str = ""
|
||||
if context_messages:
|
||||
context_str = message_api.build_readable_messages(
|
||||
messages=context_messages,
|
||||
timestamp_mode="normal_no_YMD",
|
||||
truncate=False,
|
||||
show_actions=False
|
||||
messages=context_messages, timestamp_mode="normal_no_YMD", truncate=False, show_actions=False
|
||||
)
|
||||
context_str = f"当时选择no_reply前的聊天上下文:\n{context_str}\n"
|
||||
|
||||
@@ -242,10 +235,7 @@ class NoReplyAction(BaseAction):
|
||||
if recent_messages:
|
||||
# 使用message_api构建可读的消息字符串
|
||||
messages_text = message_api.build_readable_messages(
|
||||
messages=recent_messages,
|
||||
timestamp_mode="normal_no_YMD",
|
||||
truncate=False,
|
||||
show_actions=False
|
||||
messages=recent_messages, timestamp_mode="normal_no_YMD", truncate=False, show_actions=False
|
||||
)
|
||||
|
||||
# 参考simple_planner构建更完整的判断信息
|
||||
@@ -290,7 +280,7 @@ class NoReplyAction(BaseAction):
|
||||
available_models = llm_api.get_available_models()
|
||||
|
||||
# 使用 utils_small 模型
|
||||
small_model = getattr(available_models, 'utils_small', None)
|
||||
small_model = getattr(available_models, "utils_small", None)
|
||||
|
||||
if small_model:
|
||||
# 使用小模型进行判断
|
||||
@@ -488,7 +478,6 @@ class EmojiAction(BaseAction):
|
||||
return False, f"表情发送失败: {str(e)}"
|
||||
|
||||
|
||||
|
||||
class ExitFocusChatAction(BaseAction):
|
||||
"""退出专注聊天动作 - 从专注模式切换到普通模式"""
|
||||
|
||||
@@ -590,8 +579,12 @@ class CoreActionsPlugin(BasePlugin):
|
||||
},
|
||||
"no_reply": {
|
||||
"max_timeout": ConfigField(type=int, default=1200, description="最大等待超时时间(秒)"),
|
||||
"min_judge_interval": ConfigField(type=float, default=1.0, description="LLM判断的最小间隔时间(秒),防止过于频繁"),
|
||||
"auto_exit_message_count": ConfigField(type=int, default=20, description="累计消息数量达到此阈值时自动结束等待"),
|
||||
"min_judge_interval": ConfigField(
|
||||
type=float, default=1.0, description="LLM判断的最小间隔时间(秒),防止过于频繁"
|
||||
),
|
||||
"auto_exit_message_count": ConfigField(
|
||||
type=int, default=20, description="累计消息数量达到此阈值时自动结束等待"
|
||||
),
|
||||
"random_probability": ConfigField(
|
||||
type=float, default=0.8, description="Focus模式下,随机选择不回复的概率(0.0到1.0)", example=0.8
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user