2023-11-03 11:31:45 +08:00
|
|
|
|
from fastapi import Body
|
2024-04-02 10:32:34 +08:00
|
|
|
|
from configs import logger, log_verbose, logger
|
2023-11-03 11:31:45 +08:00
|
|
|
|
from server.utils import BaseResponse
|
2023-11-22 18:38:26 +08:00
|
|
|
|
from server.db.repository import feedback_message_to_db
|
2023-11-03 11:31:45 +08:00
|
|
|
|
|
2023-11-22 18:38:26 +08:00
|
|
|
|
def chat_feedback(message_id: str = Body("", max_length=32, description="聊天记录id"),
|
2023-11-03 11:31:45 +08:00
|
|
|
|
score: int = Body(0, max=100, description="用户评分,满分100,越大表示评价越高"),
|
|
|
|
|
|
reason: str = Body("", description="用户评分理由,比如不符合事实等")
|
|
|
|
|
|
):
|
|
|
|
|
|
try:
|
2023-11-22 18:38:26 +08:00
|
|
|
|
feedback_message_to_db(message_id, score, reason)
|
2023-11-03 11:31:45 +08:00
|
|
|
|
except Exception as e:
|
|
|
|
|
|
msg = f"反馈聊天记录出错: {e}"
|
|
|
|
|
|
logger.error(f'{e.__class__.__name__}: {msg}',
|
|
|
|
|
|
exc_info=e if log_verbose else None)
|
|
|
|
|
|
return BaseResponse(code=500, msg=msg)
|
|
|
|
|
|
|
2023-11-22 18:38:26 +08:00
|
|
|
|
return BaseResponse(code=200, msg=f"已反馈聊天记录 {message_id}")
|