playreel/backend/answers/detect_answer.py

33 lines
708 B
Python

"""detect 단계 VLM 응답 스키마.
strict structured output 제약: 전 필드 required, 없을 수 있는 값은 `| None`.
좌표 단위는 격자 눈금 퍼센트(0~100)다 — 정규화 좌표는 후처리에서 만든다.
"""
from typing import Literal
from pydantic import BaseModel
class GridBox(BaseModel):
x0: int
y0: int
x1: int
y1: int
text: str | None
class FocalAnswer(BaseModel):
name: str
x: int
y: int
class DetectAnswer(BaseModel):
festival_name: str
title: GridBox | None
datetime: GridBox | None
place: GridBox | None
logo: GridBox | None
title_style: Literal["calligraphy", "typeset"]
focal_points: list[FocalAnswer]