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:
@@ -2,7 +2,9 @@
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
|
||||
from app.core.logging import get_logger
|
||||
from app.ports.asr import ASRTranscriptionError
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -39,7 +41,9 @@ class TencentASRProvider:
|
||||
async def transcribe(self, audio: bytes, format: str = "m4a") -> str:
|
||||
client = self._get_client()
|
||||
if not client:
|
||||
return "转写失败: 腾讯云 ASR 客户端未初始化(请检查密钥与依赖)"
|
||||
raise ASRTranscriptionError(
|
||||
"Tencent ASR client not initialized (check credentials)"
|
||||
)
|
||||
try:
|
||||
from tencentcloud.asr.v20190614 import models
|
||||
|
||||
@@ -64,10 +68,11 @@ class TencentASRProvider:
|
||||
req.VoiceFormat,
|
||||
err,
|
||||
)
|
||||
return (
|
||||
"转写失败: 腾讯云返回空文本(常见原因:采样率与 16k_zh 不匹配、"
|
||||
"格式不受支持或音频无效;请确认客户端为 16kHz 单声道 m4a)"
|
||||
raise ASRTranscriptionError(
|
||||
"Tencent ASR empty Result (check sample rate / format / audio)"
|
||||
)
|
||||
except ASRTranscriptionError:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error("Tencent ASR transcribe failed: {}", e, exc_info=True)
|
||||
return f"转写失败: {e}"[:500]
|
||||
raise ASRTranscriptionError(f"Tencent ASR transcribe failed: {e!s}") from e
|
||||
|
||||
@@ -9,6 +9,7 @@ import tempfile
|
||||
from typing import Any, Iterable
|
||||
|
||||
from app.core.logging import get_logger
|
||||
from app.ports.asr import ASRTranscriptionError
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -104,7 +105,7 @@ class WhisperASRProvider:
|
||||
# 与 v1.1.0 相同的单次 transcribe;推理放线程池,避免阻塞 asyncio(tag 上为同步调用)。
|
||||
self._load_model()
|
||||
if not self._model:
|
||||
return ""
|
||||
raise ASRTranscriptionError("Whisper model not loaded")
|
||||
|
||||
model = self._model
|
||||
|
||||
@@ -182,9 +183,11 @@ class WhisperASRProvider:
|
||||
logger.warning("Whisper decode_audio 回退失败: {}", ex)
|
||||
|
||||
return text
|
||||
except ASRTranscriptionError:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error("Whisper transcribe failed: {}", e)
|
||||
return ""
|
||||
raise ASRTranscriptionError(f"Whisper transcribe failed: {e!s}") from e
|
||||
finally:
|
||||
if tmp_path and os.path.exists(tmp_path):
|
||||
try:
|
||||
|
||||
@@ -6,8 +6,6 @@ Feature 通过 port ImageGenerator 使用,本模块仅被 app.adapters.image_g
|
||||
import base64
|
||||
import hmac
|
||||
import logging
|
||||
|
||||
from app.core.logging import get_logger
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
@@ -17,6 +15,7 @@ from urllib.parse import urlparse
|
||||
import httpx
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.logging import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"""Tencent Cloud SMS adapter — implements SmsSender port."""
|
||||
|
||||
from app.core.logging import get_logger
|
||||
|
||||
from tencentcloud.common import credential
|
||||
from tencentcloud.common.exception.tencent_cloud_sdk_exception import (
|
||||
TencentCloudSDKException,
|
||||
@@ -9,6 +7,8 @@ from tencentcloud.common.exception.tencent_cloud_sdk_exception import (
|
||||
from tencentcloud.sms.v20210111 import models as sms_models
|
||||
from tencentcloud.sms.v20210111 import sms_client
|
||||
|
||||
from app.core.logging import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
CODE_EXPIRE_MINUTES = 5
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"""Tencent COS adapter — implements ObjectStorage port."""
|
||||
|
||||
from app.core.logging import get_logger
|
||||
|
||||
from qcloud_cos import CosConfig, CosS3Client
|
||||
from qcloud_cos.cos_exception import CosClientError, CosServiceError
|
||||
|
||||
from app.core.logging import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +1,38 @@
|
||||
"""OpenAI TTS adapter — implements TTSProvider port."""
|
||||
|
||||
import asyncio
|
||||
from io import BytesIO
|
||||
|
||||
from openai import OpenAI
|
||||
|
||||
from app.core.logging import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class OpenAITTSProvider:
|
||||
def __init__(self, api_key: str, model: str = "tts-1"):
|
||||
self._client = OpenAI(api_key=api_key) if api_key else None
|
||||
self._model = model
|
||||
|
||||
def _synthesize_sync(self, text: str, voice: str) -> bytes:
|
||||
if not self._client:
|
||||
return b""
|
||||
response = self._client.audio.speech.create(
|
||||
model=self._model,
|
||||
voice=voice,
|
||||
input=text,
|
||||
)
|
||||
buf = BytesIO()
|
||||
for chunk in response.iter_bytes():
|
||||
buf.write(chunk)
|
||||
return buf.getvalue()
|
||||
|
||||
async def synthesize(self, text: str, voice: str = "alloy") -> bytes:
|
||||
if not self._client:
|
||||
return b""
|
||||
try:
|
||||
response = self._client.audio.speech.create(
|
||||
model=self._model,
|
||||
voice=voice,
|
||||
input=text,
|
||||
)
|
||||
buf = BytesIO()
|
||||
for chunk in response.iter_bytes():
|
||||
buf.write(chunk)
|
||||
return buf.getvalue()
|
||||
except Exception:
|
||||
return await asyncio.to_thread(self._synthesize_sync, text, voice)
|
||||
except Exception as e:
|
||||
logger.warning("OpenAI TTS synthesize failed: {}", e)
|
||||
return b""
|
||||
|
||||
Reference in New Issue
Block a user