from __future__ import annotations

from datetime import datetime
from typing import Dict, List, Optional

from pydantic import BaseModel, ConfigDict, Field


class PiiRedactionRequest(BaseModel):
    model_config = ConfigDict(populate_by_name=True)

    text: str
    user_id: Optional[str] = Field(None, alias="userId")


class PiiRedactionResponse(BaseModel):
    model_config = ConfigDict(populate_by_name=True)

    anonymized_text: str = Field(alias="anonymized_text")
    entities: Dict[str, List[str]] = Field(default_factory=dict)
    credits_used: int = Field(0, alias="creditsUsed")
    timestamp: datetime = Field(default_factory=datetime.utcnow)
