import logging

from fastapi import APIRouter, HTTPException

from app.schemas.project_info_extraction import ProjectInfoExtractionModel
from app.schemas.response_template import ResponseModel
from app.service.project_info_extraction.service import ProjectInfoExtraction

router = APIRouter()
logger = logging.getLogger()


@router.post("/extraction_project_info")
def extraction_project_info(request_data: ProjectInfoExtractionModel):
    """
        通过prompt 提取project_name,role ,gender ,style。
        创建一个具有以下参数的请求体:
        - **prompt**:

        示例参数：
        {
          "prompt": "海边派对主题的系列设计",
          "image_list": [
            "https://www.minio-api.aida.com.hk/test/test123.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=vXKFLSJkYeEq2DrSZvkB%2F20250519%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250519T050808Z&X-Amz-Expires=7200&X-Amz-SignedHeaders=host&X-Amz-Signature=296ff07cc4692d0a26ddffac582064f036494af343389fe60193dc2c5dc883ff"
          ],
          "file_list": [
            ""
          ]
        }
    """
    try:
        logger.info(f"extraction_project_info request item is : @@@@@@:{request_data}")
        service = ProjectInfoExtraction(request_data)
        data = service.get_result()
        logger.info(f"extraction_project_info response @@@@@@:{data}")
    except Exception as e:
        logger.warning(f"extraction_project_info Run Exception @@@@@@:{e}")
        raise HTTPException(status_code=404, detail=str(e))
    return ResponseModel(data=data)
