feat(eval): Playground GLM 评分落库并可恢复

在 conversations 表增加 playground_conversation_judge_json,流式/非流式对话评审结束后写入最近一次快照(整体分、逐轮分、对比文案、错误与基线文件名等)。新增只读 GET 供前端按会话拉取;评测台 Playground 切换会话时自动恢复,并提示基线是否和当时一致。
This commit is contained in:
Kevin
2026-04-08 16:50:53 +08:00
parent 309a051038
commit 78b61c076e
8 changed files with 361 additions and 91 deletions

View File

@@ -0,0 +1,39 @@
"""Persist Playground GLM conversation judge snapshot on conversations.
Revision ID: 0013_playground_judge
Revises: 0012_mem_fact_tl_lineage
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from alembic import op
revision: str = "0013_playground_judge"
down_revision: Union[str, None] = "0012_mem_fact_tl_lineage"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def _has_column(table: str, column: str) -> bool:
bind = op.get_bind()
return any(c["name"] == column for c in sa.inspect(bind).get_columns(table))
def upgrade() -> None:
if not _has_column("conversations", "playground_conversation_judge_json"):
op.add_column(
"conversations",
sa.Column(
"playground_conversation_judge_json",
postgresql.JSON(astext_type=sa.Text()),
nullable=True,
),
)
def downgrade() -> None:
if _has_column("conversations", "playground_conversation_judge_json"):
op.drop_column("conversations", "playground_conversation_judge_json")