feat: 回忆录证据血缘与内部评测可追溯,顺带对齐本地评测台与 CI
数据库与模型:新增多版迁移(章节证据快照、对话血缘、记忆事实/时间线 lineage 等),把「成稿 ↔ 对话/记忆」的溯源信息落到表结构里。 业务链路:会话与 WS、回忆录/故事流水线、记忆写入与 enrichment 等跟着接上线索与快照;新增章节证据快照与评测侧 EvalTraceService 等模块,方便组评审用的证据包。 内部评测:自动化 run 与手工 memoir 评审共用可追溯证据;rubric/ judge 相关脚本与文档有配套调整。 app-eval-web:Memoir/实验详情里能展开看证据摘要与 evidence_trace(含对话轮次 id);Vite 代理与 development.sh 注入的 API 端口与当前默认内部评测端口一致,避免改端口后页面连错服务。 工程杂项:GitHub Actions / 仓库说明有更新;各适配器与支付/配额/plan 等多处为小改动或跟随主改动的收尾;新增/扩充了?
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Any
|
||||
|
||||
@@ -22,6 +23,14 @@ logger = get_logger(__name__)
|
||||
AI_RESPONSE_SEGMENT_JOIN = "[SPLIT]"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class HumanAiTurnIds:
|
||||
"""Durable ids for one user + assistant pair in conversation_messages."""
|
||||
|
||||
human_message_id: str
|
||||
assistant_message_id: str
|
||||
|
||||
|
||||
def _utc_now() -> datetime:
|
||||
return datetime.now(timezone.utc)
|
||||
|
||||
@@ -89,7 +98,8 @@ class ConversationHistoryStore:
|
||||
audio_duration_seconds: int | None,
|
||||
tts_audio_urls: list[str] | None,
|
||||
segment_id: str | None,
|
||||
) -> str | None:
|
||||
memory_retrieval_trace: dict | None = None,
|
||||
) -> HumanAiTurnIds | None:
|
||||
if not responses:
|
||||
return None
|
||||
human_ts = user_message_timestamp or _utc_now()
|
||||
@@ -120,13 +130,17 @@ class ConversationHistoryStore:
|
||||
tts_audio_urls=tts_audio_urls if tts_audio_urls else None,
|
||||
segment_id=segment_id,
|
||||
created_at=ai_ts,
|
||||
memory_retrieval_trace_json=memory_retrieval_trace,
|
||||
)
|
||||
repo.add_conversation_message(human, self._db)
|
||||
repo.add_conversation_message(ai, self._db)
|
||||
await self._touch_conversation(conversation_id, occurred_at=ai_ts)
|
||||
await self._db.commit()
|
||||
await self._sync_redis_best_effort(conversation_id)
|
||||
return ai.id
|
||||
return HumanAiTurnIds(
|
||||
human_message_id=str(human.id),
|
||||
assistant_message_id=str(ai.id),
|
||||
)
|
||||
|
||||
async def attach_ai_tts_audio_urls(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user