from typing import List

from fastapi import APIRouter, Body, Depends, HTTPException

from models.sql.user import UserModel
from services.content_intelligence_service import ContentIntelligenceService
from utils.auth_dependencies import get_current_user

CONTENT_ROUTER = APIRouter(prefix="/content", tags=["Content"])


@CONTENT_ROUTER.post("/follow-up-questions")
async def follow_up_questions(
    content: str = Body(..., embed=True),
    _current_user: UserModel = Depends(get_current_user),
):
    """Classify content and return follow-up questions if the brief is thin."""
    if not content or not content.strip():
        raise HTTPException(status_code=400, detail="Content is required")

    ci_service = ContentIntelligenceService()
    classified = await ci_service.classify(content)
    questions: List[str] = await ci_service.ask_followup_questions(classified) or []

    return {"questions": questions}
