"""Pydantic-модели JSON-ответов (docs/05 §5.4.2, §5.4.4).""" from __future__ import annotations from typing import Literal from pydantic import BaseModel, Field class PairMetricsModel(BaseModel): good_matches: int = Field(description="Число пар после теста Лоу") inliers: int = Field(description="Число инлаеров RANSAC") inlier_ratio: float = Field(description="inliers / good_matches") coverage: float = Field(description="Доля площади пробы под оболочкой инлаеров") class ThresholdsModel(BaseModel): """Эффективные пороги сравнения лучшей пары (+ аддитивные поля диагностики).""" inliers_match: int inlier_ratio_match: float coverage_min: float inliers_uncertain_min: int geometry_model: str lowe_ratio: float ransac_reproj_threshold: float class VerifyDetailsModel(BaseModel): references_compared: int best_reference_index: int = Field(description="Индекс части reference (0-based)") metrics: PairMetricsModel thresholds: ThresholdsModel class VerifyResponse(BaseModel): verdict: Literal["match", "uncertain", "no_match"] is_match: bool = Field(description="true только при verdict = match") confidence: float = Field(ge=0.0, le=1.0) details: VerifyDetailsModel probe_sha256: str processing_ms: int class ProfileModel(BaseModel): name: str description: str extraction: dict comparison: dict class ProfilesResponse(BaseModel): profiles: list[ProfileModel] defaults: dict = Field(description="Базовые значения (env-умолчания) для наследования") class StatusResponse(BaseModel): status: str class UnreadyResponse(BaseModel): status: str reasons: list[str]