feat: 更新对话内容处理逻辑及新增用户回忆整理脚本
- 修改 get_narrative_prompt 函数,优化对话内容的叙述生成逻辑,确保新内容与已有内容自然衔接。 - 在 api/scripts 中新增 reprocess_user_memoir.py 脚本,用于整理用户历史对话为回忆录章节,支持远程预览和确认写入。 - 更新 .gitignore,添加对 certs/ 和 scripts/output/ 目录的忽略规则,确保不必要的文件不被跟踪。 - 在 memoir_tasks.py 中添加章节锁机制,防止并发写入同一章节,提升数据一致性和安全性。
This commit is contained in:
@@ -200,24 +200,31 @@ def get_creative_title_prompt(stage: str, emotion: str, slots: dict) -> str:
|
||||
|
||||
|
||||
def get_narrative_prompt(stage: str, slots: dict, new_content: str, existing_content: str = "") -> str:
|
||||
"""将对话改写为叙述,并增量更新"""
|
||||
existing_section = f"\n\n已有内容:\n{existing_content}" if existing_content else ""
|
||||
"""将新对话改写为叙述(只输出新内容的改写,不重复已有内容)"""
|
||||
# 只取已有内容的末尾作为衔接上下文
|
||||
context_tail = ""
|
||||
if existing_content:
|
||||
context_tail = existing_content[-300:] if len(existing_content) > 300 else existing_content
|
||||
|
||||
context_section = f"\n\n【衔接上下文(已有内容的末尾,仅供参考衔接,不要重复)】:\n{context_tail}" if context_tail else ""
|
||||
|
||||
return f"""{get_system_prompt()}
|
||||
|
||||
请将以下对话内容整理为第一人称叙述,并与已有内容自然融合。
|
||||
请将以下新的对话内容改写为第一人称文学叙述。
|
||||
阶段:{stage}
|
||||
可用信息:{slots}
|
||||
|
||||
新的对话内容:
|
||||
{new_content}
|
||||
{existing_section}
|
||||
{context_section}
|
||||
|
||||
要求:
|
||||
1. 使用第一人称叙述
|
||||
2. 保留少量原话(引用)
|
||||
3. 增量追加,不重写全文
|
||||
4. 语气自然,有情绪
|
||||
5. 在适合配图的地方插入图片占位符
|
||||
3. **只输出新内容的改写结果**,不要重复已有内容
|
||||
4. 如果有衔接上下文,确保新内容与之自然衔接(语气、时间线连贯)
|
||||
5. 语气自然,有情绪
|
||||
6. 在适合配图的地方插入图片占位符
|
||||
|
||||
## 图片占位符格式
|
||||
在描述场景、人物、重要时刻的段落后,插入图片占位符,格式为:
|
||||
@@ -235,6 +242,6 @@ def get_narrative_prompt(stage: str, slots: dict, new_content: str, existing_con
|
||||
- 单独占一行,不要嵌入段落中
|
||||
- 不要使用括号或星号等其他格式
|
||||
|
||||
只输出最终叙述文本(包含图片占位符)。
|
||||
只输出新对话内容的改写结果(包含图片占位符)。
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user