ref分离plannerprompt与人格解耦

pull/1217/head
SengokuCola 2025-08-22 17:22:33 +08:00
parent cb3d26d6f6
commit 1a9bee542e
3 changed files with 18 additions and 13 deletions

View File

@ -78,8 +78,12 @@ async def _calculate_interest(message: MessageRecv) -> Tuple[float, bool, list[s
interested_rate += base_interest
if is_mentioned:
interest_increase_on_mention = 1
interest_increase_on_mention = 2
interested_rate += interest_increase_on_mention
message.interest_value = interested_rate
message.is_mentioned = is_mentioned
return interested_rate, is_mentioned, keywords
@ -110,9 +114,8 @@ class HeartFCMessageReceiver:
chat = message.chat_stream
# 2. 兴趣度计算与更新
interested_rate, is_mentioned, keywords = await _calculate_interest(message)
message.interest_value = interested_rate
message.is_mentioned = is_mentioned
interested_rate, keywords = await _calculate_interest(message)
await self.storage.store_message(message, chat)

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

View File

@ -1015,7 +1015,7 @@ class DefaultReplyer:
async def llm_generate_content(self, prompt: str):
with Timer("LLM生成", {}): # 内部计时器,可选保留
# 直接使用已初始化的模型实例
logger.info(f"使用模型集生成回复: {self.express_model.model_for_task}")
logger.info(f"使用模型集生成回复: {', '.join(map(str, self.express_model.model_for_task.model_list))}")
if global_config.debug.show_prompt:
logger.info(f"\n{prompt}\n")