from __future__ import annotations

from typing import TYPE_CHECKING

from fastapi import APIRouter
from pydantic import BaseModel, Field

if TYPE_CHECKING:
    from niannian.client import NianNian


class AdultVerifyBody(BaseModel):
    terms: list[str] = Field(default_factory=list)
    use_llm: bool = True


def create_adult_router(nn: NianNian) -> APIRouter:
    router = APIRouter(tags=["adult"])

    @router.post("/v1/adult/verify")
    def verify(payload: AdultVerifyBody):
        from niannian.memory.adult_verify import verify_terms

        results = verify_terms(
            payload.terms,
            config=nn._config,
            llm=nn._router.llm,
            use_llm=payload.use_llm,
        )
        return {"results": results}

    return router
