from pydantic import BaseModel, Field


class ModerationRequest(BaseModel):
    text: str = Field(..., min_length=1, description="Text content to moderate")
    context: str = Field("listing", description="Context: listing, comment, profile")


class ModerationFlag(BaseModel):
    category: str
    severity: str = Field(..., description="low, medium, high")
    matched_text: str
    reason: str


class ModerationResponse(BaseModel):
    is_flagged: bool
    score: float = Field(..., ge=0, le=1, description="Overall risk score")
    flags: list[ModerationFlag] = Field(default_factory=list)
    cleaned_text: str | None = Field(None, description="Text with flagged content redacted")
