feat: 手术视频消耗、待确认与持久化改造

- 新增 Alembic 初始迁移、领域明细模型及归档持久化与重试链路\n- 拆分视频会话注册表、分类处理、推理时间窗聚合与流处理\n- 消耗日志:TSV/Markdown 含 top2/top3;item_id 优先产品编码;待确认记「待确认」行,语音确认后落正式行并更新汇总\n- 待确认时内存/DB 明细为占位行,确认后替换;拒绝时移除占位\n- 分类 probs 先 detach/cpu 再转 NumPy,修复 MPS/CUDA 上推理被静默跳过\n- 补充集成测试、归档与设备张量等单测

Made-with: Cursor
This commit is contained in:
Kevin
2026-04-23 20:42:21 +08:00
parent 69980d8073
commit 3d7bd70355
55 changed files with 4544 additions and 2050 deletions

View File

@@ -88,6 +88,45 @@ def append_voice_tsv_line(surgery_id: str, line: str, settings: Settings) -> Non
f.write(line)
class VoiceTextLogWriter:
"""注入式 voice 日志写入器,封装 `init_file` / `emit_event`。
行为等价于模块级函数;保留模块级函数以兼容既有调用点。
"""
def __init__(self, app_settings: Settings) -> None:
self._s = app_settings
def init_file(self, surgery_id: str) -> None:
init_voice_log_file(surgery_id, self._s)
def emit_event(
self,
*,
surgery_id: str,
source: str,
status: str,
confirmation_id: str,
asr_text: str | None = None,
resolved_label: str | None = None,
rejected: str | bool | None = None,
error_message: str | None = None,
audio_object_key: str | None = None,
) -> None:
emit_voice_event(
self._s,
surgery_id=surgery_id,
source=source,
status=status,
confirmation_id=confirmation_id,
asr_text=asr_text,
resolved_label=resolved_label,
rejected=rejected,
error_message=error_message,
audio_object_key=audio_object_key,
)
def emit_voice_event(
settings: Settings,
*,