feat(chat): 区分群聊和私聊生成不同场景提示
之前的 Prompt 模板硬编码了群聊场景,导致在私聊时机器人的角色认知和回应可能不恰当。
本次更新通过引入动态聊天场景提示来解决此问题:
- 在 Prompt 模板中使用 `{chat_scene}` 占位符代替了硬编码的场景描述。
- Replyer 会根据当前是群聊还是私聊,生成不同的场景提示文本(如“你正在一个QQ群里聊天”或“你正在和XX私下聊天”)。
- 通过 PromptParameters 将动态生成的场景提示传递给 Prompt 系统,使模型能够更好地理解上下文。
This commit is contained in:
@@ -109,7 +109,7 @@ def init_prompt():
|
||||
|
||||
## 任务
|
||||
|
||||
*你正在一个QQ群里聊天,你需要理解整个群的聊天动态和话题走向,并做出自然的回应。*
|
||||
*{chat_scene}*
|
||||
|
||||
### 核心任务
|
||||
- 你现在的主要任务是和 {sender_name} 聊天。{relation_info_block}同时,也有其他用户会参与聊天,你可以参考他们的回复内容,但是你现在想回复{sender_name}的发言。
|
||||
@@ -169,7 +169,7 @@ If you need to use the search tool, please directly call the function "lpmm_sear
|
||||
logger.debug("[Prompt模式调试] 正在注册normal_style_prompt模板")
|
||||
Prompt(
|
||||
"""
|
||||
你正在一个QQ群里聊天,你需要理解整个群的聊天动态和话题走向,并做出自然的回应。
|
||||
{chat_scene}
|
||||
|
||||
**重要:消息针对性判断**
|
||||
在回应之前,首先分析消息的针对性:
|
||||
@@ -1178,8 +1178,15 @@ class DefaultReplyer:
|
||||
# 根据配置选择模板
|
||||
current_prompt_mode = global_config.personality.prompt_mode
|
||||
|
||||
# 动态生成聊天场景提示
|
||||
if is_group_chat:
|
||||
chat_scene_prompt = "你正在一个QQ群里聊天,你需要理解整个群的聊天动态和话题走向,并做出自然的回应。"
|
||||
else:
|
||||
chat_scene_prompt = f"你正在和 {sender} 私下聊天,你需要理解你们的对话并做出自然的回应。"
|
||||
|
||||
# 使用新的统一Prompt系统 - 创建PromptParameters
|
||||
prompt_parameters = PromptParameters(
|
||||
chat_scene=chat_scene_prompt,
|
||||
chat_id=chat_id,
|
||||
is_group_chat=is_group_chat,
|
||||
sender=sender,
|
||||
|
||||
Reference in New Issue
Block a user