ref分离plannerprompt与人格解耦
This commit is contained in:
@@ -78,8 +78,12 @@ async def _calculate_interest(message: MessageRecv) -> Tuple[float, bool, list[s
|
|||||||
interested_rate += base_interest
|
interested_rate += base_interest
|
||||||
|
|
||||||
if is_mentioned:
|
if is_mentioned:
|
||||||
interest_increase_on_mention = 1
|
interest_increase_on_mention = 2
|
||||||
interested_rate += interest_increase_on_mention
|
interested_rate += interest_increase_on_mention
|
||||||
|
|
||||||
|
|
||||||
|
message.interest_value = interested_rate
|
||||||
|
message.is_mentioned = is_mentioned
|
||||||
|
|
||||||
return interested_rate, is_mentioned, keywords
|
return interested_rate, is_mentioned, keywords
|
||||||
|
|
||||||
@@ -110,9 +114,8 @@ class HeartFCMessageReceiver:
|
|||||||
chat = message.chat_stream
|
chat = message.chat_stream
|
||||||
|
|
||||||
# 2. 兴趣度计算与更新
|
# 2. 兴趣度计算与更新
|
||||||
interested_rate, is_mentioned, keywords = await _calculate_interest(message)
|
interested_rate, keywords = await _calculate_interest(message)
|
||||||
message.interest_value = interested_rate
|
|
||||||
message.is_mentioned = is_mentioned
|
|
||||||
|
|
||||||
await self.storage.store_message(message, chat)
|
await self.storage.store_message(message, chat)
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def init_prompt():
|
|||||||
Prompt(
|
Prompt(
|
||||||
"""
|
"""
|
||||||
{time_block}
|
{time_block}
|
||||||
{identity_block}
|
{name_block}
|
||||||
你现在需要根据聊天内容,选择的合适的action来参与聊天。
|
你现在需要根据聊天内容,选择的合适的action来参与聊天。
|
||||||
请你根据以下行事风格来决定action:
|
请你根据以下行事风格来决定action:
|
||||||
{plan_style}
|
{plan_style}
|
||||||
@@ -298,7 +298,7 @@ class ActionPlanner:
|
|||||||
|
|
||||||
actions_before_now = get_actions_by_timestamp_with_chat(
|
actions_before_now = get_actions_by_timestamp_with_chat(
|
||||||
chat_id=self.chat_id,
|
chat_id=self.chat_id,
|
||||||
timestamp_start=time.time() - 3600,
|
timestamp_start=time.time() - 600,
|
||||||
timestamp_end=time.time(),
|
timestamp_end=time.time(),
|
||||||
limit=5,
|
limit=5,
|
||||||
)
|
)
|
||||||
@@ -306,8 +306,12 @@ class ActionPlanner:
|
|||||||
actions_before_now_block = build_readable_actions(
|
actions_before_now_block = build_readable_actions(
|
||||||
actions=actions_before_now,
|
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:
|
if refresh_time:
|
||||||
self.last_obs_time_mark = time.time()
|
self.last_obs_time_mark = time.time()
|
||||||
|
|
||||||
@@ -322,8 +326,7 @@ class ActionPlanner:
|
|||||||
动作:no_action
|
动作:no_action
|
||||||
动作描述:不进行动作,等待合适的时机
|
动作描述:不进行动作,等待合适的时机
|
||||||
- 当你刚刚发送了消息,没有人回复时,选择no_action
|
- 当你刚刚发送了消息,没有人回复时,选择no_action
|
||||||
- 如果有别的动作(非回复)满足条件,可以不用no_action
|
- 当你一次发送了太多消息,为了避免过于烦人,可以不回复
|
||||||
- 当你一次发送了太多消息,为了避免打扰聊天节奏,选择no_action
|
|
||||||
{
|
{
|
||||||
"action": "no_action",
|
"action": "no_action",
|
||||||
"reason":"不动作的原因"
|
"reason":"不动作的原因"
|
||||||
@@ -378,8 +381,7 @@ class ActionPlanner:
|
|||||||
bot_nickname = f",也有人叫你{','.join(global_config.bot.alias_names)}"
|
bot_nickname = f",也有人叫你{','.join(global_config.bot.alias_names)}"
|
||||||
else:
|
else:
|
||||||
bot_nickname = ""
|
bot_nickname = ""
|
||||||
bot_core_personality = global_config.personality.personality_core
|
name_block = f"你的名字是{bot_name}{bot_nickname},请注意哪些是你自己的发言。"
|
||||||
identity_block = f"你的名字是{bot_name}{bot_nickname},你{bot_core_personality}:"
|
|
||||||
|
|
||||||
planner_prompt_template = await global_prompt_manager.get_prompt_async("planner_prompt")
|
planner_prompt_template = await global_prompt_manager.get_prompt_async("planner_prompt")
|
||||||
prompt = planner_prompt_template.format(
|
prompt = planner_prompt_template.format(
|
||||||
@@ -391,7 +393,7 @@ class ActionPlanner:
|
|||||||
mentioned_bonus=mentioned_bonus,
|
mentioned_bonus=mentioned_bonus,
|
||||||
action_options_text=action_options_block,
|
action_options_text=action_options_block,
|
||||||
moderation_prompt=moderation_prompt_block,
|
moderation_prompt=moderation_prompt_block,
|
||||||
identity_block=identity_block,
|
name_block=name_block,
|
||||||
plan_style=global_config.personality.plan_style,
|
plan_style=global_config.personality.plan_style,
|
||||||
)
|
)
|
||||||
return prompt, message_id_list
|
return prompt, message_id_list
|
||||||
|
|||||||
@@ -1015,7 +1015,7 @@ class DefaultReplyer:
|
|||||||
async def llm_generate_content(self, prompt: str):
|
async def llm_generate_content(self, prompt: str):
|
||||||
with Timer("LLM生成", {}): # 内部计时器,可选保留
|
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:
|
if global_config.debug.show_prompt:
|
||||||
logger.info(f"\n{prompt}\n")
|
logger.info(f"\n{prompt}\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user