1. 建立问题库大纲,对应每个人生阶段槽位
2. 鼓励使用更生活化的交流语言共情与总结
3. 降低评审模型可能发生截断的概率
4. 成稿质量维度强化情感表达和上下文连贯性
This commit is contained in:
yangshilin
2026-04-09 15:32:35 +08:00
parent 064ad2161d
commit e1341c6d18
49 changed files with 938 additions and 271 deletions

View File

@@ -121,7 +121,9 @@ class EvalTraceService:
return "partial"
return "fallback"
async def build_chapter_bundle(self, user_id: str, chapter: Chapter) -> ChapterEvidenceBundle:
async def build_chapter_bundle(
self, user_id: str, chapter: Chapter
) -> ChapterEvidenceBundle:
notes: list[str] = []
live_segment_ids = normalize_source_segment_ids(
getattr(chapter, "source_segments", None)
@@ -130,7 +132,15 @@ class EvalTraceService:
row = getattr(chapter, "current_evidence_snapshot", None)
row_has_closure = bool(
(row and (row.segment_ids or []))
or (row and (row.memory_chunk_ids or row.memory_fact_ids or row.timeline_event_ids or row.summary_ids))
or (
row
and (
row.memory_chunk_ids
or row.memory_fact_ids
or row.timeline_event_ids
or row.summary_ids
)
)
)
if (
row is not None
@@ -139,19 +149,13 @@ class EvalTraceService:
and int(row.schema_version or 0) == EVIDENCE_SNAPSHOT_SCHEMA_VERSION
and row_has_closure
):
segment_ids = [
str(x) for x in (row.segment_ids or []) if str(x).strip()
]
segment_ids = [str(x) for x in (row.segment_ids or []) if str(x).strip()]
conv_ids = sorted(
{str(x) for x in (row.conversation_ids or []) if str(x).strip()}
)
chunk_ids = [
str(x) for x in (row.memory_chunk_ids or []) if str(x).strip()
]
chunk_ids = [str(x) for x in (row.memory_chunk_ids or []) if str(x).strip()]
fact_ids = [str(x) for x in (row.memory_fact_ids or []) if str(x).strip()]
tl_ids = [
str(x) for x in (row.timeline_event_ids or []) if str(x).strip()
]
tl_ids = [str(x) for x in (row.timeline_event_ids or []) if str(x).strip()]
sum_ids = [str(x) for x in (row.summary_ids or []) if str(x).strip()]
notes.extend([str(x) for x in (row.notes or []) if x])
notes.append("evidence_from_chapter_evidence_snapshot_table")
@@ -163,7 +167,9 @@ class EvalTraceService:
sum_ids=sum_ids,
)
if live_segment_ids and set(live_segment_ids) != set(segment_ids):
notes.append("live_source_segments_differ_from_snapshot_reconcile_in_pipeline")
notes.append(
"live_source_segments_differ_from_snapshot_reconcile_in_pipeline"
)
dlg = getattr(row, "message_lineage_json", None)
return ChapterEvidenceBundle(
user_id=user_id,
@@ -202,14 +208,24 @@ class EvalTraceService:
)
if use_snap and isinstance(snap, dict):
segment_ids = [str(x) for x in (snap.get("segment_ids") or []) if str(x).strip()]
segment_ids = [
str(x) for x in (snap.get("segment_ids") or []) if str(x).strip()
]
conv_ids = sorted(
{str(x) for x in (snap.get("conversation_ids") or []) if str(x).strip()}
)
chunk_ids = [str(x) for x in (snap.get("memory_chunk_ids") or []) if str(x).strip()]
fact_ids = [str(x) for x in (snap.get("memory_fact_ids") or []) if str(x).strip()]
tl_ids = [str(x) for x in (snap.get("timeline_event_ids") or []) if str(x).strip()]
sum_ids = [str(x) for x in (snap.get("summary_ids") or []) if str(x).strip()]
chunk_ids = [
str(x) for x in (snap.get("memory_chunk_ids") or []) if str(x).strip()
]
fact_ids = [
str(x) for x in (snap.get("memory_fact_ids") or []) if str(x).strip()
]
tl_ids = [
str(x) for x in (snap.get("timeline_event_ids") or []) if str(x).strip()
]
sum_ids = [
str(x) for x in (snap.get("summary_ids") or []) if str(x).strip()
]
notes.extend([str(x) for x in (snap.get("notes") or []) if x])
notes.append("evidence_from_chapter_evidence_bundle_json_column")
tier = self._chapter_closure_tier(
@@ -220,8 +236,12 @@ class EvalTraceService:
sum_ids=sum_ids,
)
if live_segment_ids and set(live_segment_ids) != set(segment_ids):
notes.append("live_source_segments_differ_from_snapshot_reconcile_in_pipeline")
snap_dlg = snap.get("message_lineage_json") if isinstance(snap, dict) else None
notes.append(
"live_source_segments_differ_from_snapshot_reconcile_in_pipeline"
)
snap_dlg = (
snap.get("message_lineage_json") if isinstance(snap, dict) else None
)
return ChapterEvidenceBundle(
user_id=user_id,
chapter_id=str(chapter.id),
@@ -256,8 +276,15 @@ class EvalTraceService:
resolved_seg_ids = [s.id for s in segments] or segment_ids
if len(segments) < len(segment_ids):
notes.append("some_segments_missing_or_foreign_user")
conv_ids = sorted({str(s.conversation_id) for s in segments if s.conversation_id})
chunk_ids, fact_ids, tl_ids, sum_ids = await fetch_memory_closure_for_conversations(
conv_ids = sorted(
{str(s.conversation_id) for s in segments if s.conversation_id}
)
(
chunk_ids,
fact_ids,
tl_ids,
sum_ids,
) = await fetch_memory_closure_for_conversations(
self._db, user_id=user_id, conversation_ids=conv_ids
)
tier = self._chapter_closure_tier(
@@ -339,8 +366,12 @@ class EvalTraceService:
)
return formatted, bundle
async def build_story_bundle(self, user_id: str, story_id: str) -> StoryEvidenceBundle:
st = await get_story_for_eval_trace(self._db, user_id=user_id, story_id=story_id)
async def build_story_bundle(
self, user_id: str, story_id: str
) -> StoryEvidenceBundle:
st = await get_story_for_eval_trace(
self._db, user_id=user_id, story_id=story_id
)
if not st:
return StoryEvidenceBundle(
user_id=user_id,
@@ -378,7 +409,9 @@ class EvalTraceService:
segments = await fetch_segments_for_user(
self._db, user_id=user_id, segment_ids=dedup_seg
)
conv_ids = sorted({str(s.conversation_id) for s in segments if s.conversation_id})
conv_ids = sorted(
{str(s.conversation_id) for s in segments if s.conversation_id}
)
if dedup_seg and not segments:
notes.append("chapter_segment_ids_unresolved")
if conv_ids:
@@ -428,11 +461,16 @@ class EvalTraceService:
segments = await fetch_segments_for_user(
self._db, user_id=user_id, segment_ids=dedup_seg
)
conv_ids = sorted({str(s.conversation_id) for s in segments if s.conversation_id})
chunk_ids, fact_ids, tl_ids, sum_ids = (
await fetch_memory_closure_for_conversations(
self._db, user_id=user_id, conversation_ids=conv_ids
)
conv_ids = sorted(
{str(s.conversation_id) for s in segments if s.conversation_id}
)
(
chunk_ids,
fact_ids,
tl_ids,
sum_ids,
) = await fetch_memory_closure_for_conversations(
self._db, user_id=user_id, conversation_ids=conv_ids
)
notes.append("fallback_lineage_no_story_evidence_links")
notes.append("augmented_with_chapter_context")