feat: 章节软删除、对话左滑删除,移除已读状态
- 章节:详情页增加删除按钮,软删除(is_active=False),AI 不再修改但保留供参考 - 章节:get_chapter 增加 is_active 校验,已删除章节返回 404 - 章节:AI 生成时参考同类别已删除章节摘要 - 对话:左滑显示删除,调用 hard delete API,删除前二次确认 - 对话:根布局包裹 GestureHandlerRootView 以支持 Swipeable - 对话:移除已读/未读状态展示及相关 i18n
This commit is contained in:
@@ -23,6 +23,7 @@ from app.features.memoir.models import (
|
||||
MemoirImage,
|
||||
MemoirState,
|
||||
)
|
||||
from app.features.memoir import repo as memoir_repo
|
||||
from app.features.user.models import User
|
||||
from app.core.dependencies import get_llm_provider
|
||||
from app.agents.state_schema import MemoirStateSchema, SlotData, default_state
|
||||
@@ -713,6 +714,12 @@ def process_memoir_segments(self, user_id: str, segment_ids: List[str]):
|
||||
)
|
||||
narrative = combined_text
|
||||
|
||||
# 已删除章节摘要供 AI 参考
|
||||
archived = memoir_repo.get_archived_chapter_summaries_sync(db, user_id, chapter_category)
|
||||
archived_summaries = "\n".join(
|
||||
f"- 《{title_text}》:{preview}" for title_text, preview in archived
|
||||
) if archived else ""
|
||||
|
||||
if llm:
|
||||
try:
|
||||
if not chapter:
|
||||
@@ -733,6 +740,7 @@ def process_memoir_segments(self, user_id: str, segment_ids: List[str]):
|
||||
existing_content=existing_content,
|
||||
user_profile=user_profile,
|
||||
birth_year=user_birth_year,
|
||||
archived_summaries=archived_summaries,
|
||||
)
|
||||
narrative_response = llm.invoke(narrative_prompt)
|
||||
new_narrative = narrative_response.content.strip()
|
||||
@@ -861,12 +869,18 @@ def generate_chapter_content(self, user_id: str, stage: str, new_content: str):
|
||||
s.content for s in sorted(chapter.sections, key=lambda x: x.order_index) if (s.content or "").strip()
|
||||
)
|
||||
|
||||
archived = memoir_repo.get_archived_chapter_summaries_sync(db, user_id, stage)
|
||||
archived_summaries = "\n".join(
|
||||
f"- 《{title_text}》:{preview}" for title_text, preview in archived
|
||||
) if archived else ""
|
||||
|
||||
if llm:
|
||||
prompt = get_narrative_prompt(
|
||||
stage=stage,
|
||||
slots={},
|
||||
new_content=new_content,
|
||||
existing_content=existing_content,
|
||||
archived_summaries=archived_summaries,
|
||||
)
|
||||
response = llm.invoke(prompt)
|
||||
new_narrative = response.content.strip()
|
||||
|
||||
Reference in New Issue
Block a user