liunux4odoo 5c650a8dc3
优化目录结构 (#4058)
* 优化目录结构

* 修改一些测试问题

---------

Co-authored-by: glide-the <2533736852@qq.com>
2024-05-22 13:11:45 +08:00

24 lines
919 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from fastapi import Body
from chatchat.configs import log_verbose
from chatchat.server.utils import BaseResponse
from chatchat.server.db.repository import feedback_message_to_db
import logging
logger = logging.getLogger()
def chat_feedback(message_id: str = Body("", max_length=32, description="聊天记录id"),
score: int = Body(0, max=100, description="用户评分满分100越大表示评价越高"),
reason: str = Body("", description="用户评分理由,比如不符合事实等")
):
try:
feedback_message_to_db(message_id, score, reason)
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)
return BaseResponse(code=200, msg=f"已反馈聊天记录 {message_id}")