ref分离plannerprompt与人格解耦

This commit is contained in:
SengokuCola
2025-08-22 17:22:33 +08:00
parent cb3d26d6f6
commit 1a9bee542e
3 changed files with 18 additions and 13 deletions

View File

@@ -33,7 +33,7 @@ def init_prompt():
Prompt(
"""
{time_block}
{identity_block}
{name_block}
你现在需要根据聊天内容选择的合适的action来参与聊天。
请你根据以下行事风格来决定action:
{plan_style}
@@ -298,7 +298,7 @@ class ActionPlanner:
actions_before_now = get_actions_by_timestamp_with_chat(
chat_id=self.chat_id,
timestamp_start=time.time() - 3600,
timestamp_start=time.time() - 600,
timestamp_end=time.time(),
limit=5,
)
@@ -306,8 +306,12 @@ class ActionPlanner:
actions_before_now_block = build_readable_actions(
actions=actions_before_now,
)
if actions_before_now:
actions_before_now_block = f"你刚刚选择并执行过的action是\n{actions_before_now_block}"
else:
actions_before_now_block = ""
actions_before_now_block = f"你刚刚选择并执行过的action是\n{actions_before_now_block}"
if refresh_time:
self.last_obs_time_mark = time.time()
@@ -322,8 +326,7 @@ class ActionPlanner:
动作no_action
动作描述:不进行动作,等待合适的时机
- 当你刚刚发送了消息没有人回复时选择no_action
- 如果有别的动作非回复满足条件可以不用no_action
- 当你一次发送了太多消息为了避免打扰聊天节奏选择no_action
- 当你一次发送了太多消息,为了避免过于烦人,可以不回复
{
"action": "no_action",
"reason":"不动作的原因"
@@ -378,8 +381,7 @@ class ActionPlanner:
bot_nickname = f",也有人叫你{','.join(global_config.bot.alias_names)}"
else:
bot_nickname = ""
bot_core_personality = global_config.personality.personality_core
identity_block = f"你的名字是{bot_name}{bot_nickname},你{bot_core_personality}"
name_block = f"你的名字是{bot_name}{bot_nickname},请注意哪些是你自己的发言。"
planner_prompt_template = await global_prompt_manager.get_prompt_async("planner_prompt")
prompt = planner_prompt_template.format(
@@ -391,7 +393,7 @@ class ActionPlanner:
mentioned_bonus=mentioned_bonus,
action_options_text=action_options_block,
moderation_prompt=moderation_prompt_block,
identity_block=identity_block,
name_block=name_block,
plan_style=global_config.personality.plan_style,
)
return prompt, message_id_list