feat(affinity_flow_chatter): 增强动作思考过程在回复生成中的集成
添加了将动作思考过程集成到回复生成流程的功能: - 在 generator_api 中新增逻辑,将 action_data 中的 thinking 字段内容添加到 extra_info - 优化 plan_filter 中对 thinking 字段的处理逻辑,避免添加无意义的默认值 - 更新默认生成器提示词,移除冗余的关系信息块重复 - 在 planner 提示词中添加不对表情包消息回应的限制
This commit is contained in:
@@ -219,6 +219,7 @@ class ChatterActionManager:
|
||||
success, response_set, _ = await generator_api.generate_reply(
|
||||
chat_stream=chat_stream,
|
||||
reply_message=target_message,
|
||||
action_data=action_data or {},
|
||||
available_actions=self.get_using_actions(),
|
||||
enable_tool=global_config.tool.enable_tool,
|
||||
request_type="chat.replyer",
|
||||
|
||||
@@ -104,7 +104,9 @@ def init_prompt():
|
||||
## 其他信息
|
||||
{memory_block}
|
||||
{relation_info_block}
|
||||
|
||||
{extra_info_block}
|
||||
|
||||
{action_descriptions}
|
||||
|
||||
## 任务
|
||||
@@ -112,7 +114,7 @@ def init_prompt():
|
||||
*{chat_scene}*
|
||||
|
||||
### 核心任务
|
||||
- 你现在的主要任务是和 {sender_name} 聊天。{relation_info_block}同时,也有其他用户会参与聊天,你可以参考他们的回复内容,但是你现在想回复{sender_name}的发言。
|
||||
- 你现在的主要任务是和 {sender_name} 聊天。同时,也有其他用户会参与聊天,你可以参考他们的回复内容,但是你现在想回复{sender_name}的发言。
|
||||
|
||||
- {reply_target_block} 你需要生成一段紧密相关且能推动对话的回复。
|
||||
|
||||
|
||||
@@ -120,6 +120,13 @@ async def generate_reply(
|
||||
if not extra_info and action_data:
|
||||
extra_info = action_data.get("extra_info", "")
|
||||
|
||||
# 如果action_data中有thinking,添加到extra_info中
|
||||
if action_data and (thinking := action_data.get("thinking")):
|
||||
if extra_info:
|
||||
extra_info += f"\n\n思考过程:{thinking}"
|
||||
else:
|
||||
extra_info = f"思考过程:{thinking}"
|
||||
|
||||
# 调用回复器生成回复
|
||||
success, llm_response_dict, prompt = await replyer.generate_reply_with_context(
|
||||
reply_to=reply_to,
|
||||
|
||||
@@ -434,8 +434,8 @@ class ChatterPlanFilter:
|
||||
action_data = {k: v for k, v in single_action_obj.items() if k not in ["action_type", "reason"]}
|
||||
|
||||
# 保留原始的thinking字段(如果有)
|
||||
thinking = action_json.get("thinking")
|
||||
if thinking:
|
||||
thinking = action_json.get("thinking", "")
|
||||
if thinking and thinking != "未提供思考过程":
|
||||
action_data["thinking"] = thinking
|
||||
|
||||
target_message_obj = None
|
||||
|
||||
@@ -53,6 +53,7 @@ def init_prompts():
|
||||
- **回复消息时必须遵循对话的流程,不要重复已经说过的话。**
|
||||
- **确保回复与上下文紧密相关,回应要针对用户的消息内容。**
|
||||
- **保持角色设定的一致性,使用符合你性格的语言风格。**
|
||||
- **不要对表情包消息做出回应!**
|
||||
|
||||
**输出格式:**
|
||||
请严格按照以下 JSON 格式输出,包含 `thinking` 和 `actions` 字段:
|
||||
|
||||
Reference in New Issue
Block a user