🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -595,12 +595,12 @@ class HeartFChatting:
|
|||||||
self, observed_messages_str: str, current_mind: Optional[str], structured_info: Dict[str, Any]
|
self, observed_messages_str: str, current_mind: Optional[str], structured_info: Dict[str, Any]
|
||||||
) -> str:
|
) -> str:
|
||||||
"""构建 Planner LLM 的提示词"""
|
"""构建 Planner LLM 的提示词"""
|
||||||
|
|
||||||
# 准备结构化信息块
|
# 准备结构化信息块
|
||||||
structured_info_block = ""
|
structured_info_block = ""
|
||||||
if structured_info:
|
if structured_info:
|
||||||
structured_info_block = f"以下是一些额外的信息:\n{structured_info}\n"
|
structured_info_block = f"以下是一些额外的信息:\n{structured_info}\n"
|
||||||
|
|
||||||
# 准备聊天内容块
|
# 准备聊天内容块
|
||||||
chat_content_block = ""
|
chat_content_block = ""
|
||||||
if observed_messages_str:
|
if observed_messages_str:
|
||||||
@@ -609,14 +609,14 @@ class HeartFChatting:
|
|||||||
chat_content_block += "\n---"
|
chat_content_block += "\n---"
|
||||||
else:
|
else:
|
||||||
chat_content_block = "当前没有观察到新的聊天内容。\n"
|
chat_content_block = "当前没有观察到新的聊天内容。\n"
|
||||||
|
|
||||||
# 准备当前思维块
|
# 准备当前思维块
|
||||||
current_mind_block = ""
|
current_mind_block = ""
|
||||||
if current_mind:
|
if current_mind:
|
||||||
current_mind_block = f"\n---\n{current_mind}\n---\n\n"
|
current_mind_block = f"\n---\n{current_mind}\n---\n\n"
|
||||||
else:
|
else:
|
||||||
current_mind_block = " [没有特别的想法] \n\n"
|
current_mind_block = " [没有特别的想法] \n\n"
|
||||||
|
|
||||||
# 获取提示词模板并填充数据
|
# 获取提示词模板并填充数据
|
||||||
prompt = (await global_prompt_manager.get_prompt_async("planner_prompt")).format(
|
prompt = (await global_prompt_manager.get_prompt_async("planner_prompt")).format(
|
||||||
bot_name=global_config.BOT_NICKNAME,
|
bot_name=global_config.BOT_NICKNAME,
|
||||||
@@ -624,7 +624,7 @@ class HeartFChatting:
|
|||||||
chat_content_block=chat_content_block,
|
chat_content_block=chat_content_block,
|
||||||
current_mind_block=current_mind_block,
|
current_mind_block=current_mind_block,
|
||||||
)
|
)
|
||||||
|
|
||||||
return prompt
|
return prompt
|
||||||
|
|
||||||
# --- 回复器 (Replier) 的定义 --- #
|
# --- 回复器 (Replier) 的定义 --- #
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ def init_prompt():
|
|||||||
{moderation_prompt}。注意:不要输出多余内容(包括前后缀,冒号和引号,括号,表情包,at或 @等 )。""",
|
{moderation_prompt}。注意:不要输出多余内容(包括前后缀,冒号和引号,括号,表情包,at或 @等 )。""",
|
||||||
"heart_flow_prompt",
|
"heart_flow_prompt",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Planner提示词
|
# Planner提示词
|
||||||
Prompt(
|
Prompt(
|
||||||
"""你的名字是 {bot_name}。是一个女大二学生,正在QQ聊天,正在决定是否以及如何回应当前的聊天。
|
"""你的名字是 {bot_name}。是一个女大二学生,正在QQ聊天,正在决定是否以及如何回应当前的聊天。
|
||||||
@@ -56,7 +56,7 @@ def init_prompt():
|
|||||||
必须调用 'decide_reply_action' 工具并提供 'action' 和 'reasoning'。如果选择了 'emoji_reply' 或者选择了 'text_reply' 并想追加表情,则必须提供 'emoji_query'。""",
|
必须调用 'decide_reply_action' 工具并提供 'action' 和 'reasoning'。如果选择了 'emoji_reply' 或者选择了 'text_reply' 并想追加表情,则必须提供 'emoji_query'。""",
|
||||||
"planner_prompt",
|
"planner_prompt",
|
||||||
)
|
)
|
||||||
|
|
||||||
Prompt("你正在qq群里聊天,下面是群里在聊的内容:", "chat_target_group1")
|
Prompt("你正在qq群里聊天,下面是群里在聊的内容:", "chat_target_group1")
|
||||||
Prompt("和群里聊天", "chat_target_group2")
|
Prompt("和群里聊天", "chat_target_group2")
|
||||||
Prompt("你正在和{sender_name}聊天,这是你们之前聊的内容:", "chat_target_private1")
|
Prompt("你正在和{sender_name}聊天,这是你们之前聊的内容:", "chat_target_private1")
|
||||||
@@ -116,13 +116,14 @@ class PromptBuilder:
|
|||||||
|
|
||||||
elif build_mode == "focus":
|
elif build_mode == "focus":
|
||||||
return await self._build_prompt_focus(
|
return await self._build_prompt_focus(
|
||||||
reason, current_mind_info, structured_info, chat_stream,
|
reason,
|
||||||
|
current_mind_info,
|
||||||
|
structured_info,
|
||||||
|
chat_stream,
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def _build_prompt_focus(
|
async def _build_prompt_focus(self, reason, current_mind_info, structured_info, chat_stream) -> tuple[str, str]:
|
||||||
self, reason, current_mind_info, structured_info, chat_stream
|
|
||||||
) -> tuple[str, str]:
|
|
||||||
individuality = Individuality.get_instance()
|
individuality = Individuality.get_instance()
|
||||||
prompt_personality = individuality.get_prompt(type="personality", x_person=2, level=1)
|
prompt_personality = individuality.get_prompt(type="personality", x_person=2, level=1)
|
||||||
prompt_identity = individuality.get_prompt(type="identity", x_person=2, level=1)
|
prompt_identity = individuality.get_prompt(type="identity", x_person=2, level=1)
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ class NormalChat:
|
|||||||
# 确保任务状态更新,即使等待出错 (回调函数也会尝试更新)
|
# 确保任务状态更新,即使等待出错 (回调函数也会尝试更新)
|
||||||
if self._chat_task is task:
|
if self._chat_task is task:
|
||||||
self._chat_task = None
|
self._chat_task = None
|
||||||
|
|
||||||
# 清理所有未处理的思考消息
|
# 清理所有未处理的思考消息
|
||||||
try:
|
try:
|
||||||
container = await message_manager.get_container(self.stream_id)
|
container = await message_manager.get_container(self.stream_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user