Files
AiDA_Python/app/api/api_chat_robot.py
zhouchengrong b012b91613 feat 更新响应模板
fix
2024-06-13 14:31:14 +08:00

24 lines
764 B
Python

import json
import logging
import time
from fastapi import APIRouter, HTTPException
from app.schemas.chat_robot import ChatRobotModel
from app.schemas.response_template import ResponseModel
from app.service.chat_robot.script.main import chat
router = APIRouter()
logger = logging.getLogger()
@router.post("/chat_robot")
def chat_robot(request_data: ChatRobotModel):
try:
logger.info(f"chat_robot request item is : @@@@@@:{request_data}")
data = chat(post_data=request_data)
logger.info(f"chat_robot response @@@@@@:{json.dumps(data, indent=4)}")
except Exception as e:
logger.warning(f"chat_robot Run Exception @@@@@@:{e}")
raise HTTPException(status_code=404, detail=str(e))
return ResponseModel(data=data)