chore/ 删除无用文件

This commit is contained in:
Kevin
2026-03-19 14:36:14 +08:00
parent 2f60858c9c
commit c6e07ce5ca
135 changed files with 2111 additions and 4510 deletions

View File

@@ -1,6 +1,7 @@
"""
回忆录整理 Agent 提示词模板
"""
import json
import re
from typing import Optional
@@ -67,8 +68,13 @@ def inject_image_placeholder_template(content: str) -> str:
if not inner:
return match.group(0)
if inner.startswith(IMAGE_PLACEHOLDER_TEMPLATE):
desc = inner[len(IMAGE_PLACEHOLDER_TEMPLATE):].lstrip("").strip()
return "{{{{IMAGE:" + IMAGE_PLACEHOLDER_TEMPLATE + ("" + desc if desc else "") + "}}}}"
desc = inner[len(IMAGE_PLACEHOLDER_TEMPLATE) :].lstrip("").strip()
return (
"{{{{IMAGE:"
+ IMAGE_PLACEHOLDER_TEMPLATE
+ ("" + desc if desc else "")
+ "}}}}"
)
return "{{{{IMAGE:" + IMAGE_PLACEHOLDER_TEMPLATE + "" + inner + "}}}}"
content = _IMAGE_PLACEHOLDER_ANY_BRACES_RE.sub(replace_one, content)
@@ -146,10 +152,14 @@ def get_chapter_classification_prompt(segments_text: str) -> str:
如果对话内容中没有任何与人生经历相关的实质内容,返回 none。"""
def get_text_rewrite_prompt(segments_text: str, chapter_category: str, existing_content: str = "") -> str:
def get_text_rewrite_prompt(
segments_text: str, chapter_category: str, existing_content: str = ""
) -> str:
"""获取文本改写的提示词"""
chapter_name = CHAPTER_CATEGORIES.get(chapter_category, chapter_category)
existing_section = f"\n\n已有章节内容:\n{existing_content}" if existing_content else ""
existing_section = (
f"\n\n已有章节内容:\n{existing_content}" if existing_content else ""
)
return f"""{get_system_prompt()}
请将以下口语化的对话内容改写为书面语,归类到"{chapter_name}"章节。
@@ -181,7 +191,9 @@ def get_text_rewrite_prompt(segments_text: str, chapter_category: str, existing_
{{{{IMAGE:奶奶坐在院子里的藤椅上,手里摇着蒲扇}}}}"""
def get_state_extraction_prompt(user_message: str, current_stage: str, stage_slots: dict) -> str:
def get_state_extraction_prompt(
user_message: str, current_stage: str, stage_slots: dict
) -> str:
"""抽取结构化信息并判断阶段"""
slot_keys = list(stage_slots.keys())
all_stage_slots = {
@@ -296,9 +308,19 @@ def get_narrative_prompt(
"""将新对话改写为叙述(只输出新内容的改写,不重复已有内容)"""
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 ""
archived_section = f"\n\n【已删除的该类别历史章节(仅供参考,请勿直接使用或重复)】:\n{archived_summaries}" if archived_summaries else ""
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 ""
)
archived_section = (
f"\n\n【已删除的该类别历史章节(仅供参考,请勿直接使用或重复)】:\n{archived_summaries}"
if archived_summaries
else ""
)
profile_section = f"\n\n用户基本信息:\n{user_profile}" if user_profile else ""
age_hint = _build_age_hint(stage, birth_year)
@@ -366,8 +388,14 @@ def get_narrative_json_prompt(
"""将新对话改写为叙述,输出 JSON 格式paragraphs: [{content, image_description}]"""
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 ""
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 ""
)
profile_section = f"\n\n用户基本信息:\n{user_profile}" if user_profile else ""
age_hint = _build_age_hint(stage, birth_year)
time_section = f"\n时间参考:{age_hint}" if age_hint else ""