mirror of https://github.com/Mai-with-u/MaiBot.git
Merge branch 'G-Test' of https://github.com/smartmita/MaiBot into G-Test
commit
0eed0103c0
|
|
@ -3,6 +3,7 @@ from src.chat.knowledge.knowledge_lib import qa_manager
|
|||
from src.chat.models.utils_model import LLMRequest
|
||||
from src.config.config import global_config
|
||||
from src.chat.utils.chat_message_builder import get_raw_msg_before_timestamp_with_chat, build_readable_messages
|
||||
from src.plugins.group_nickname.nickname_manager import nickname_manager
|
||||
import time
|
||||
import re
|
||||
import traceback
|
||||
|
|
@ -32,6 +33,10 @@ def init_prompt():
|
|||
<personality_profile>{prompt_personality}</personality_profile>
|
||||
</identity>
|
||||
|
||||
<group_nicknames>
|
||||
{nickname_info}
|
||||
</group_nicknames>
|
||||
|
||||
<knowledge_base>
|
||||
<structured_information>{extra_info}</structured_information>
|
||||
<social_relationships>{relation_prompt}</social_relationships>
|
||||
|
|
@ -51,6 +56,7 @@ def init_prompt():
|
|||
|
||||
<thinking_guidance>
|
||||
请仔细阅读当前聊天内容,分析讨论话题和群成员关系,分析你刚刚发言和别人对你的发言的反应,思考你要不要回复或发言。然后思考你是否需要使用函数工具。
|
||||
请特别留意对话的节奏。如果你发送消息后没有得到回应,那么在考虑发言或追问时,请务必谨慎。优先考虑是否你的上一条信息已经结束了当前话题,或者对方暂时不方便回复。除非你有非常重要且有时效性的新事情,否则避免在对方无明显回应意愿时进行追问。
|
||||
思考并输出你真实的内心想法。
|
||||
</thinking_guidance>
|
||||
|
||||
|
|
@ -60,7 +66,7 @@ def init_prompt():
|
|||
2. 不要分点、不要使用表情符号
|
||||
3. 避免多余符号(冒号、引号、括号等)
|
||||
4. 语言简洁自然,不要浮夸
|
||||
5. 如果你刚发言,并且没有人回复你,请谨慎考虑要不要继续发消息
|
||||
5. 当你发送消息后没人理你,你的内心想法应倾向于“耐心等待对方回复”或“思考是否对方正在忙”,而不是立即产生追问的想法。只有当你认为追问确实必要且不会打扰对方时,才考虑生成追问的意图。
|
||||
6. 不要把注意力放在别人发的表情包上,它们只是一种辅助表达方式
|
||||
7. 注意分辨群里谁在跟谁说话,你不一定是当前聊天的主角,消息中的“你”不一定指的是你({bot_name}),也可能是别人
|
||||
8. 思考要不要回复或发言,如果要,必须**明确写出**你准备发送的消息的具体内容是什么
|
||||
|
|
@ -561,9 +567,25 @@ class SubMind:
|
|||
|
||||
# ---------- 5. 构建最终提示词 ----------
|
||||
# --- Choose template based on chat type ---
|
||||
logger.debug(f"is_group_chat: {is_group_chat}")
|
||||
nickname_injection_str = "" # 初始化为空字符串
|
||||
|
||||
if is_group_chat:
|
||||
template_name = "sub_heartflow_prompt_before"
|
||||
|
||||
chat_stream = await chat_manager.get_stream(self.subheartflow_id)
|
||||
if not chat_stream:
|
||||
logger.error(f"{self.log_prefix} 无法获取 chat_stream,无法生成绰号信息。")
|
||||
nickname_injection_str = "[获取群成员绰号信息失败]"
|
||||
else:
|
||||
message_list_for_nicknames = get_raw_msg_before_timestamp_with_chat(
|
||||
chat_id=self.subheartflow_id,
|
||||
timestamp=time.time(),
|
||||
limit=global_config.observation_context_size,
|
||||
)
|
||||
nickname_injection_str = await nickname_manager.get_nickname_prompt_injection(
|
||||
chat_stream, message_list_for_nicknames
|
||||
)
|
||||
|
||||
prompt = (await global_prompt_manager.get_prompt_async(template_name)).format(
|
||||
extra_info=self.structured_info_str,
|
||||
prompt_personality=prompt_personality,
|
||||
|
|
@ -575,6 +597,7 @@ class SubMind:
|
|||
hf_do_next=hf_do_next,
|
||||
last_loop_prompt=last_loop_prompt,
|
||||
cycle_info_block=cycle_info_block,
|
||||
nickname_info=nickname_injection_str,
|
||||
# chat_target_name is not used in group prompt
|
||||
)
|
||||
else: # Private chat
|
||||
|
|
|
|||
|
|
@ -84,10 +84,10 @@ def init_prompt():
|
|||
- {bot_name}的内心想法表达不想发言
|
||||
- 话题似乎对{bot_name}来说无关/无聊/不感兴趣
|
||||
- 现在说话不太合适了
|
||||
- 仔细观察聊天记录。如果{bot_name}的上一条或最近几条发言没有获得任何回应,那么此时更合适的做法是不发言,等待新的对话契机(例如其他人发言)。避免让{bot_name}显得过于急切或不顾他人反应。
|
||||
- 最后一条消息是{bot_name}自己发的且无人回应{bot_name},同时{bot_name}也没有别的想要回复的消息
|
||||
- 讨论不了解的专业话题,或你不知道的梗,且对{bot_name}来说似乎没那么重要
|
||||
- {bot_name}发送了太多消息,且无人回复
|
||||
- (特殊情况){bot_name}的内心想法返回错误/无返回
|
||||
- (特殊情况){bot_name}的内心想法返回错误/无返回/无想法
|
||||
</principle_no_reply>
|
||||
|
||||
<principle_text_reply>
|
||||
|
|
@ -109,8 +109,8 @@ def init_prompt():
|
|||
<principle_dialogue_management>
|
||||
4. 对话处理:
|
||||
- 如果最后一条消息是{bot_name}发的,而你还想操控{bot_name}继续发消息,请确保这是合适的(例如{bot_name}确实有合适的补充,或回应之前没回应的消息)
|
||||
- 评估{bot_name}内心想法中的潜在发言是否会造成“自言自语”或“强行延续已冷却话题”的印象。如果群聊中其他人没有对{bot_name}的上一话题进行回应,那么继续围绕该话题继续发言通常是不明智的,建议no_reply。
|
||||
- 注意话题的推进,如果没有必要,不要揪着一个话题不放。
|
||||
- 不要让{bot_name}自己和自己聊天
|
||||
</principle_dialogue_management>
|
||||
</decision_principles>
|
||||
|
||||
|
|
@ -254,15 +254,15 @@ async def _build_prompt_focus(reason, current_mind_info, structured_info, chat_s
|
|||
)
|
||||
|
||||
prompt_ger = ""
|
||||
if random.random() < 0.20:
|
||||
prompt_ger += "不用输出对方的网名或绰号"
|
||||
if random.random() < 0.60:
|
||||
prompt_ger += "**不用输出对方的网名或绰号**"
|
||||
if random.random() < 0.00:
|
||||
prompt_ger += "你喜欢用反问句"
|
||||
|
||||
reply_styles1 = [
|
||||
("给出日常且口语化的回复,平淡一些", 0.4),
|
||||
("给出非常简短的回复", 0.4),
|
||||
("**给出省略主语的回复,简短**", 0.15),
|
||||
("给出日常且口语化的回复,平淡一些", 0.40),
|
||||
("给出非常简短的回复", 0.30),
|
||||
("**给出省略主语的回复,简短**", 0.30),
|
||||
("给出带有语病的回复,朴实平淡", 0.00),
|
||||
]
|
||||
reply_style1_chosen = random.choices(
|
||||
|
|
@ -404,8 +404,8 @@ class PromptBuilder:
|
|||
reply_styles2 = [
|
||||
("不用回复的太有条理,可以有个性", 0.75), # 60%概率
|
||||
("不用回复的太有条理,可以复读", 0.0), # 15%概率
|
||||
("回复的认真一些", 0.2), # 20%概率
|
||||
("可以回复单个表情符号", 0.05), # 5%概率
|
||||
("回复的认真一些", 0.25), # 20%概率
|
||||
("可以回复单个表情符号", 0.00), # 5%概率
|
||||
]
|
||||
reply_style2_chosen = random.choices(
|
||||
[style[0] for style in reply_styles2], weights=[style[1] for style in reply_styles2], k=1
|
||||
|
|
|
|||
Loading…
Reference in New Issue