mirror of https://github.com/Mai-with-u/MaiBot.git
feat:根据回复力度,启用不同的prompt
parent
b03e245817
commit
d2a4abc33f
|
|
@ -886,9 +886,19 @@ class DefaultReplyer:
|
||||||
chat_prompt_content = self.get_chat_prompt_for_chat(chat_id)
|
chat_prompt_content = self.get_chat_prompt_for_chat(chat_id)
|
||||||
chat_prompt_block = f"{chat_prompt_content}\n" if chat_prompt_content else ""
|
chat_prompt_block = f"{chat_prompt_content}\n" if chat_prompt_content else ""
|
||||||
|
|
||||||
# 固定使用群聊回复模板
|
# 根据think_level选择不同的回复模板
|
||||||
|
# think_level=0: 轻量回复(简短平淡)
|
||||||
|
# think_level=1: 中等回复(日常口语化)
|
||||||
|
# think_level=2: 深度回复(仔细思考,把握话题)
|
||||||
|
if think_level == 0:
|
||||||
|
prompt_name = "replyer_prompt_0"
|
||||||
|
elif think_level == 2:
|
||||||
|
prompt_name = "replyer_prompt_2"
|
||||||
|
else: # think_level == 1 或默认
|
||||||
|
prompt_name = "replyer_prompt"
|
||||||
|
|
||||||
return await global_prompt_manager.format_prompt(
|
return await global_prompt_manager.format_prompt(
|
||||||
"replyer_prompt",
|
prompt_name,
|
||||||
expression_habits_block=expression_habits_block,
|
expression_habits_block=expression_habits_block,
|
||||||
tool_info_block=tool_info,
|
tool_info_block=tool_info,
|
||||||
bot_name=global_config.bot.nickname,
|
bot_name=global_config.bot.nickname,
|
||||||
|
|
@ -959,58 +969,30 @@ class DefaultReplyer:
|
||||||
|
|
||||||
if sender and target:
|
if sender and target:
|
||||||
# 使用预先分析的内容类型结果
|
# 使用预先分析的内容类型结果
|
||||||
if is_group_chat:
|
if sender:
|
||||||
if sender:
|
if has_only_pics and not has_text:
|
||||||
if has_only_pics and not has_text:
|
# 只包含图片
|
||||||
# 只包含图片
|
reply_target_block = (
|
||||||
reply_target_block = (
|
f"现在{sender}发送的图片:{pic_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
f"现在{sender}发送的图片:{pic_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
)
|
||||||
)
|
elif has_text and pic_part:
|
||||||
elif has_text and pic_part:
|
# 既有图片又有文字
|
||||||
# 既有图片又有文字
|
reply_target_block = f"现在{sender}发送了图片:{pic_part},并说:{text_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
reply_target_block = f"现在{sender}发送了图片:{pic_part},并说:{text_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
|
||||||
else:
|
|
||||||
# 只包含文字
|
|
||||||
reply_target_block = (
|
|
||||||
f"现在{sender}说的:{text_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
|
||||||
)
|
|
||||||
elif target:
|
|
||||||
reply_target_block = f"现在{target}引起了你的注意,你想要在群里发言或者回复这条消息。"
|
|
||||||
else:
|
else:
|
||||||
reply_target_block = "现在,你想要在群里发言或者回复消息。"
|
# 只包含文字
|
||||||
else: # private chat
|
reply_target_block = (
|
||||||
if sender:
|
f"现在{sender}说的:{text_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
if has_only_pics and not has_text:
|
)
|
||||||
# 只包含图片
|
elif target:
|
||||||
reply_target_block = f"现在{sender}发送的图片:{pic_part}。引起了你的注意,针对这条消息回复。"
|
reply_target_block = f"现在{target}引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
elif has_text and pic_part:
|
else:
|
||||||
# 既有图片又有文字
|
reply_target_block = "现在,你想要在群里发言或者回复消息。"
|
||||||
reply_target_block = (
|
|
||||||
f"现在{sender}发送了图片:{pic_part},并说:{text_part}。引起了你的注意,针对这条消息回复。"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# 只包含文字
|
|
||||||
reply_target_block = f"现在{sender}说的:{text_part}。引起了你的注意,针对这条消息回复。"
|
|
||||||
elif target:
|
|
||||||
reply_target_block = f"现在{target}引起了你的注意,针对这条消息回复。"
|
|
||||||
else:
|
|
||||||
reply_target_block = "现在,你想要回复。"
|
|
||||||
else:
|
else:
|
||||||
reply_target_block = ""
|
reply_target_block = ""
|
||||||
|
|
||||||
if is_group_chat:
|
|
||||||
chat_target_1 = await global_prompt_manager.get_prompt_async("chat_target_group1")
|
chat_target_1 = await global_prompt_manager.get_prompt_async("chat_target_group1")
|
||||||
chat_target_2 = await global_prompt_manager.get_prompt_async("chat_target_group2")
|
chat_target_2 = await global_prompt_manager.get_prompt_async("chat_target_group2")
|
||||||
else:
|
|
||||||
chat_target_name = "对方"
|
|
||||||
if self.chat_target_info:
|
|
||||||
chat_target_name = self.chat_target_info.person_name or self.chat_target_info.user_nickname or "对方"
|
|
||||||
chat_target_1 = await global_prompt_manager.format_prompt(
|
|
||||||
"chat_target_private1", sender_name=chat_target_name
|
|
||||||
)
|
|
||||||
chat_target_2 = await global_prompt_manager.format_prompt(
|
|
||||||
"chat_target_private2", sender_name=chat_target_name
|
|
||||||
)
|
|
||||||
|
|
||||||
template_name = "default_expressor_prompt"
|
template_name = "default_expressor_prompt"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -893,59 +893,35 @@ class PrivateReplyer:
|
||||||
)
|
)
|
||||||
|
|
||||||
if sender and target:
|
if sender and target:
|
||||||
# 使用预先分析的内容类型结果
|
if sender:
|
||||||
if is_group_chat:
|
if has_only_pics and not has_text:
|
||||||
if sender:
|
# 只包含图片
|
||||||
if has_only_pics and not has_text:
|
reply_target_block = f"现在{sender}发送的图片:{pic_part}。引起了你的注意,针对这条消息回复。"
|
||||||
# 只包含图片
|
elif has_text and pic_part:
|
||||||
reply_target_block = (
|
# 既有图片又有文字
|
||||||
f"现在{sender}发送的图片:{pic_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
reply_target_block = (
|
||||||
)
|
f"现在{sender}发送了图片:{pic_part},并说:{text_part}。引起了你的注意,针对这条消息回复。"
|
||||||
elif has_text and pic_part:
|
)
|
||||||
# 既有图片又有文字
|
|
||||||
reply_target_block = f"现在{sender}发送了图片:{pic_part},并说:{text_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
|
||||||
else:
|
|
||||||
# 只包含文字
|
|
||||||
reply_target_block = (
|
|
||||||
f"现在{sender}说的:{text_part}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
|
||||||
)
|
|
||||||
elif target:
|
|
||||||
reply_target_block = f"现在{target}引起了你的注意,你想要在群里发言或者回复这条消息。"
|
|
||||||
else:
|
else:
|
||||||
reply_target_block = "现在,你想要在群里发言或者回复消息。"
|
# 只包含文字
|
||||||
else: # private chat
|
reply_target_block = f"现在{sender}说的:{text_part}。引起了你的注意,针对这条消息回复。"
|
||||||
if sender:
|
elif target:
|
||||||
if has_only_pics and not has_text:
|
reply_target_block = f"现在{target}引起了你的注意,针对这条消息回复。"
|
||||||
# 只包含图片
|
else:
|
||||||
reply_target_block = f"现在{sender}发送的图片:{pic_part}。引起了你的注意,针对这条消息回复。"
|
reply_target_block = "现在,你想要回复。"
|
||||||
elif has_text and pic_part:
|
|
||||||
# 既有图片又有文字
|
|
||||||
reply_target_block = (
|
|
||||||
f"现在{sender}发送了图片:{pic_part},并说:{text_part}。引起了你的注意,针对这条消息回复。"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# 只包含文字
|
|
||||||
reply_target_block = f"现在{sender}说的:{text_part}。引起了你的注意,针对这条消息回复。"
|
|
||||||
elif target:
|
|
||||||
reply_target_block = f"现在{target}引起了你的注意,针对这条消息回复。"
|
|
||||||
else:
|
|
||||||
reply_target_block = "现在,你想要回复。"
|
|
||||||
else:
|
else:
|
||||||
reply_target_block = ""
|
reply_target_block = ""
|
||||||
|
|
||||||
if is_group_chat:
|
|
||||||
chat_target_1 = await global_prompt_manager.get_prompt_async("chat_target_group1")
|
chat_target_name = "对方"
|
||||||
chat_target_2 = await global_prompt_manager.get_prompt_async("chat_target_group2")
|
if self.chat_target_info:
|
||||||
else:
|
chat_target_name = self.chat_target_info.person_name or self.chat_target_info.user_nickname or "对方"
|
||||||
chat_target_name = "对方"
|
chat_target_1 = await global_prompt_manager.format_prompt(
|
||||||
if self.chat_target_info:
|
"chat_target_private1", sender_name=chat_target_name
|
||||||
chat_target_name = self.chat_target_info.person_name or self.chat_target_info.user_nickname or "对方"
|
)
|
||||||
chat_target_1 = await global_prompt_manager.format_prompt(
|
chat_target_2 = await global_prompt_manager.format_prompt(
|
||||||
"chat_target_private1", sender_name=chat_target_name
|
"chat_target_private2", sender_name=chat_target_name
|
||||||
)
|
)
|
||||||
chat_target_2 = await global_prompt_manager.format_prompt(
|
|
||||||
"chat_target_private2", sender_name=chat_target_name
|
|
||||||
)
|
|
||||||
|
|
||||||
template_name = "default_expressor_prompt"
|
template_name = "default_expressor_prompt"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@ from src.chat.utils.prompt_builder import Prompt
|
||||||
|
|
||||||
|
|
||||||
def init_replyer_prompt():
|
def init_replyer_prompt():
|
||||||
Prompt("正在群里聊天", "chat_target_group2")
|
|
||||||
Prompt("和{sender_name}聊天", "chat_target_private2")
|
|
||||||
|
|
||||||
Prompt(
|
Prompt(
|
||||||
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||||
{expression_habits_block}{memory_retrieval}{jargon_explanation}
|
{expression_habits_block}{memory_retrieval}{jargon_explanation}
|
||||||
|
|
@ -22,6 +19,26 @@ def init_replyer_prompt():
|
||||||
尽量简短一些。{keywords_reaction_prompt}请注意把握聊天内容,不要回复的太有条理。
|
尽量简短一些。{keywords_reaction_prompt}请注意把握聊天内容,不要回复的太有条理。
|
||||||
{reply_style}
|
{reply_style}
|
||||||
请注意不要输出多余内容(包括不必要的前后缀,冒号,括号,表情包,at或 @等 ),只输出发言内容就好。
|
请注意不要输出多余内容(包括不必要的前后缀,冒号,括号,表情包,at或 @等 ),只输出发言内容就好。
|
||||||
|
现在,你说:""",
|
||||||
|
"replyer_prompt_0",
|
||||||
|
)
|
||||||
|
|
||||||
|
Prompt(
|
||||||
|
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||||
|
{expression_habits_block}{memory_retrieval}{jargon_explanation}
|
||||||
|
|
||||||
|
你正在qq群里聊天,下面是群里正在聊的内容,其中包含聊天记录和聊天中的图片
|
||||||
|
其中标注 {bot_name}(你) 的发言是你自己的发言,请注意区分:
|
||||||
|
{time_block}
|
||||||
|
{dialogue_prompt}
|
||||||
|
|
||||||
|
{reply_target_block}。
|
||||||
|
{planner_reasoning}
|
||||||
|
{identity}
|
||||||
|
{chat_prompt}你正在群里聊天,现在请你读读之前的聊天记录,然后给出日常且口语化的回复,
|
||||||
|
{keywords_reaction_prompt}请注意把握聊天内容。
|
||||||
|
{reply_style}
|
||||||
|
请注意不要输出多余内容(包括不必要的前后缀,冒号,括号,表情包,at或 @等 ),只输出发言内容就好。
|
||||||
现在,你说:""",
|
现在,你说:""",
|
||||||
"replyer_prompt",
|
"replyer_prompt",
|
||||||
)
|
)
|
||||||
|
|
@ -30,6 +47,26 @@ def init_replyer_prompt():
|
||||||
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||||
{expression_habits_block}{memory_retrieval}{jargon_explanation}
|
{expression_habits_block}{memory_retrieval}{jargon_explanation}
|
||||||
|
|
||||||
|
你正在qq群里聊天,下面是群里正在聊的内容,其中包含聊天记录和聊天中的图片
|
||||||
|
其中标注 {bot_name}(你) 的发言是你自己的发言,请注意区分:
|
||||||
|
{time_block}
|
||||||
|
{dialogue_prompt}
|
||||||
|
|
||||||
|
{reply_target_block}。
|
||||||
|
{planner_reasoning}
|
||||||
|
{identity}
|
||||||
|
{chat_prompt}你正在群里聊天,现在请你仔细阅读之前的聊天记录,把握当前的话题,然后给出回复,
|
||||||
|
{keywords_reaction_prompt}请注意把握聊天内容。
|
||||||
|
{reply_style}
|
||||||
|
请注意不要输出多余内容(包括不必要的前后缀,冒号,括号,at或 @等 ),只输出发言内容就好。
|
||||||
|
现在,你说:""",
|
||||||
|
"replyer_prompt_2",
|
||||||
|
)
|
||||||
|
|
||||||
|
Prompt(
|
||||||
|
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||||
|
{expression_habits_block}{memory_retrieval}{jargon_explanation}
|
||||||
|
|
||||||
你正在和{sender_name}聊天,这是你们之前聊的内容:
|
你正在和{sender_name}聊天,这是你们之前聊的内容:
|
||||||
{time_block}
|
{time_block}
|
||||||
{dialogue_prompt}
|
{dialogue_prompt}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue