mirror of https://github.com/Mai-with-u/MaiBot.git
planner思考现在加入replyer
parent
0123d68578
commit
22dca15f0a
|
|
@ -764,7 +764,9 @@ class HeartFChatting:
|
||||||
# 重置连续 no_reply 计数
|
# 重置连续 no_reply 计数
|
||||||
self.consecutive_no_reply_count = 0
|
self.consecutive_no_reply_count = 0
|
||||||
|
|
||||||
reason = action_planner_info.reasoning or "选择回复"
|
reason = action_planner_info.reasoning or ""
|
||||||
|
# 使用 action_reasoning(planner 的整体思考理由)作为 reply_reason
|
||||||
|
planner_reasoning = action_planner_info.action_reasoning or reason
|
||||||
await database_api.store_action_info(
|
await database_api.store_action_info(
|
||||||
chat_stream=self.chat_stream,
|
chat_stream=self.chat_stream,
|
||||||
action_build_into_prompt=False,
|
action_build_into_prompt=False,
|
||||||
|
|
@ -781,7 +783,7 @@ class HeartFChatting:
|
||||||
reply_message=action_planner_info.action_message,
|
reply_message=action_planner_info.action_message,
|
||||||
available_actions=available_actions,
|
available_actions=available_actions,
|
||||||
chosen_actions=chosen_action_plan_infos,
|
chosen_actions=chosen_action_plan_infos,
|
||||||
reply_reason=reason,
|
reply_reason=planner_reasoning,
|
||||||
enable_tool=global_config.tool.enable_tool,
|
enable_tool=global_config.tool.enable_tool,
|
||||||
request_type="replyer",
|
request_type="replyer",
|
||||||
from_plugin=False,
|
from_plugin=False,
|
||||||
|
|
|
||||||
|
|
@ -845,6 +845,12 @@ class DefaultReplyer:
|
||||||
keywords_reaction_prompt = await self.build_keywords_reaction_prompt(target)
|
keywords_reaction_prompt = await self.build_keywords_reaction_prompt(target)
|
||||||
mood_state_prompt: str = results_dict["mood_state_prompt"]
|
mood_state_prompt: str = results_dict["mood_state_prompt"]
|
||||||
|
|
||||||
|
# 从 chosen_actions 中提取 planner 的整体思考理由
|
||||||
|
planner_reasoning = ""
|
||||||
|
if reply_reason:
|
||||||
|
# 如果没有 chosen_actions,使用 reply_reason 作为备选
|
||||||
|
planner_reasoning = f"你的想法是:{reply_reason}"
|
||||||
|
|
||||||
if extra_info:
|
if extra_info:
|
||||||
extra_info_block = f"以下是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策\n{extra_info}\n以上是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策"
|
extra_info_block = f"以下是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策\n{extra_info}\n以上是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策"
|
||||||
else:
|
else:
|
||||||
|
|
@ -899,6 +905,7 @@ class DefaultReplyer:
|
||||||
moderation_prompt=moderation_prompt_block,
|
moderation_prompt=moderation_prompt_block,
|
||||||
memory_retrieval=memory_retrieval,
|
memory_retrieval=memory_retrieval,
|
||||||
chat_prompt=chat_prompt_block,
|
chat_prompt=chat_prompt_block,
|
||||||
|
planner_reasoning=planner_reasoning,
|
||||||
), selected_expressions
|
), selected_expressions
|
||||||
|
|
||||||
async def build_prompt_rewrite_context(
|
async def build_prompt_rewrite_context(
|
||||||
|
|
|
||||||
|
|
@ -765,6 +765,12 @@ class PrivateReplyer:
|
||||||
memory_retrieval: str = results_dict["memory_retrieval"]
|
memory_retrieval: str = results_dict["memory_retrieval"]
|
||||||
keywords_reaction_prompt = await self.build_keywords_reaction_prompt(target)
|
keywords_reaction_prompt = await self.build_keywords_reaction_prompt(target)
|
||||||
|
|
||||||
|
# 从 chosen_actions 中提取 planner 的整体思考理由
|
||||||
|
planner_reasoning = ""
|
||||||
|
if reply_reason:
|
||||||
|
# 如果没有 chosen_actions,使用 reply_reason 作为备选
|
||||||
|
planner_reasoning = f"你的想法是:{reply_reason}"
|
||||||
|
|
||||||
if extra_info:
|
if extra_info:
|
||||||
extra_info_block = f"以下是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策\n{extra_info}\n以上是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策"
|
extra_info_block = f"以下是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策\n{extra_info}\n以上是你在回复时需要参考的信息,现在请你阅读以下内容,进行决策"
|
||||||
else:
|
else:
|
||||||
|
|
@ -834,6 +840,7 @@ class PrivateReplyer:
|
||||||
sender_name=sender,
|
sender_name=sender,
|
||||||
memory_retrieval=memory_retrieval,
|
memory_retrieval=memory_retrieval,
|
||||||
chat_prompt=chat_prompt_block,
|
chat_prompt=chat_prompt_block,
|
||||||
|
planner_reasoning=planner_reasoning,
|
||||||
), selected_expressions
|
), selected_expressions
|
||||||
|
|
||||||
async def build_prompt_rewrite_context(
|
async def build_prompt_rewrite_context(
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,13 @@ def init_replyer_prompt():
|
||||||
{dialogue_prompt}
|
{dialogue_prompt}
|
||||||
|
|
||||||
{reply_target_block}。
|
{reply_target_block}。
|
||||||
|
{planner_reasoning}
|
||||||
{identity}
|
{identity}
|
||||||
{chat_prompt}你正在群里聊天,现在请你读读之前的聊天记录,然后给出日常且口语化的回复,平淡一些,{mood_state}
|
{chat_prompt}你正在群里聊天,现在请你读读之前的聊天记录,然后给出日常且口语化的回复,平淡一些,{mood_state}
|
||||||
尽量简短一些。{keywords_reaction_prompt}请注意把握聊天内容,不要回复的太有条理,可以有个性。
|
尽量简短一些。{keywords_reaction_prompt}请注意把握聊天内容,不要回复的太有条理,可以有个性。
|
||||||
{reply_style}
|
{reply_style}
|
||||||
请注意不要输出多余内容(包括前后缀,冒号和引号,括号,表情等),只输出一句回复内容就好。
|
请注意不要输出多余内容(包括前后缀,冒号和引号,括号,表情等),只输出一句回复内容就好。
|
||||||
不要输出多余内容(包括前后缀,冒号和引号,括号,表情包,at或 @等 )。请不要思考太长
|
不要输出多余内容(包括前后缀,冒号和引号,括号,表情包,at或 @等 )。
|
||||||
现在,你说:""",
|
现在,你说:""",
|
||||||
"replyer_prompt",
|
"replyer_prompt",
|
||||||
)
|
)
|
||||||
|
|
@ -35,6 +36,7 @@ def init_replyer_prompt():
|
||||||
{dialogue_prompt}
|
{dialogue_prompt}
|
||||||
|
|
||||||
{reply_target_block}。
|
{reply_target_block}。
|
||||||
|
{planner_reasoning}
|
||||||
{identity}
|
{identity}
|
||||||
{chat_prompt}你正在和{sender_name}聊天,现在请你读读之前的聊天记录,然后给出日常且口语化的回复,平淡一些,{mood_state}
|
{chat_prompt}你正在和{sender_name}聊天,现在请你读读之前的聊天记录,然后给出日常且口语化的回复,平淡一些,{mood_state}
|
||||||
尽量简短一些。{keywords_reaction_prompt}请注意把握聊天内容,不要回复的太有条理,可以有个性。
|
尽量简短一些。{keywords_reaction_prompt}请注意把握聊天内容,不要回复的太有条理,可以有个性。
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,8 @@ class Jargon(BaseModel):
|
||||||
is_jargon = BooleanField(null=True) # None表示未判定,True表示是黑话,False表示不是黑话
|
is_jargon = BooleanField(null=True) # None表示未判定,True表示是黑话,False表示不是黑话
|
||||||
last_inference_count = IntegerField(null=True) # 最后一次判定的count值,用于避免重启后重复判定
|
last_inference_count = IntegerField(null=True) # 最后一次判定的count值,用于避免重启后重复判定
|
||||||
is_complete = BooleanField(default=False) # 是否已完成所有推断(count>=100后不再推断)
|
is_complete = BooleanField(default=False) # 是否已完成所有推断(count>=100后不再推断)
|
||||||
|
inference_with_context = TextField(null=True) # 基于上下文的推断结果(JSON格式)
|
||||||
|
inference_content_only = TextField(null=True) # 仅基于词条的推断结果(JSON格式)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
table_name = "jargon"
|
table_name = "jargon"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue