"""API data models."""

from typing import Dict, Optional, Any, List
from pydantic import BaseModel, Field


class ScoreRequest(BaseModel):
    """Request model for scoring endpoint."""
    task_input: str = Field(..., description="The input/prompt given to the model")
    model_output: str = Field(..., description="The output generated by the model")
    rubric_name: Optional[str] = Field(None, description="Name of rubric to use (if not specified in endpoint)")
    llm_config: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Configuration for LLM provider")


class BatchScoreRequest(BaseModel):
    """Request model for batch scoring endpoint."""
    items: List[Dict[str, str]] = Field(..., description="List of task_input/model_output pairs")
    rubric_name: Optional[str] = Field(None, description="Name of rubric to use")
    llm_config: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Configuration for LLM provider")


class ScoreResponse(BaseModel):
    """Response model for scoring endpoint."""
    overall_score: float
    overall_explanation: str
    criterion_scores: Dict[str, float]
    criterion_explanations: Dict[str, str]
    rubric_name: str
    rubric_version: str


class BatchScoreResponse(BaseModel):
    """Response model for batch scoring endpoint."""
    results: List[ScoreResponse]
    summary: Dict[str, Any]


class RubricSummary(BaseModel):
    """Summary of a rubric."""
    name: str
    version: str
    description: Optional[str]
    domain: Optional[str]
    criteria_count: int
    scale_min: float
    scale_max: float


class ErrorResponse(BaseModel):
    """Error response model."""
    error: str
    detail: Optional[str] = None
    error_code: Optional[str] = None