修复:CI 部署环境与 ref 错配、迁移碎片化、图片意图 source_span、章节物化脏版式、会话历史与本地语音不一致

新增:TTS 上传 COS 与分片、章节 reading_segments 物化与快照、markdown 清洗、会话消息 repository、语音 store 重构与相关测试
This commit is contained in:
Kevin
2026-03-20 16:36:42 +08:00
parent 7317bf10cd
commit 8af37e5e8e
65 changed files with 1704 additions and 504 deletions

View File

@@ -12,7 +12,6 @@ from __future__ import annotations
import re
from dataclasses import dataclass
from typing import Any
@dataclass
@@ -21,7 +20,6 @@ class StoryImageIntentResult:
caption: str
prompt_brief: str
source_span: dict[str, Any] | None
style_profile: str | None
@@ -59,36 +57,28 @@ def extract_primary_image_intent(
优先从正文中选取最具画面感的段落;若正文过短或过于抽象,则使用 fallback。
"""
paragraphs: list[tuple[str, int, int]] = [] # (text, start, end)
paragraphs: list[str] = []
if markdown and markdown.strip():
parts = re.split(r"\n\n+", markdown.strip())
offset = 0
for p in parts:
for p in re.split(r"\n\n+", markdown.strip()):
t = p.strip()
if t:
start = markdown.find(t, offset)
end = start + len(t)
paragraphs.append((t, start, end))
offset = end
paragraphs.append(t)
best_caption = ""
best_prompt_brief = ""
best_source_span: dict[str, Any] | None = None
best_score = 0.0
for text, start, end in paragraphs:
for text in paragraphs:
score = _score_paragraph(text)
if score > best_score:
best_score = score
best_caption = (text[:80] + "") if len(text) > 80 else text
best_prompt_brief = text[:500].strip()
best_source_span = {"start": start, "end": end, "text_preview": text[:100]}
if best_score >= 0.5:
return StoryImageIntentResult(
caption=best_caption,
prompt_brief=best_prompt_brief,
source_span=best_source_span,
style_profile=style_profile,
)
@@ -110,6 +100,5 @@ def extract_primary_image_intent(
return StoryImageIntentResult(
caption=fallback_text[:80],
prompt_brief=fallback_text,
source_span=None,
style_profile=style_profile,
)