mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-26 16:53:36 +08:00
* 新功能:
- WEBUI 添加对话评分功能
- 增加 /chat/feedback 接口,用于接收对话评分
- /chat/chat 接口返回值由 str 改为 {"text":str, "chat_history_id": str}
- init_database.py 添加 --create-tables --clear-tables 参数
依赖:
- streamlit-chatbox==1.1.11
开发者:
- ChatHistoryModel 的 id 字段支持自动生成
- SAVE_CHAT_HISTORY 改到 basic_config.py
* 修复:点击反馈后页面未刷新
---------
Co-authored-by: liqiankun.1111 <liqiankun.1111@bytedance.com>
Co-authored-by: liunux4odoo <liunux@qq.com>
Co-authored-by: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com>
26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
from sqlalchemy import Column, Integer, String, DateTime, JSON, func
|
||
|
||
from server.db.base import Base
|
||
|
||
|
||
class ChatHistoryModel(Base):
|
||
"""
|
||
聊天记录模型
|
||
"""
|
||
__tablename__ = 'chat_history'
|
||
# 由前端生成的uuid,如果是自增的话,则需要将id 传给前端,这在流式返回里有点麻烦
|
||
id = Column(String(32), primary_key=True, comment='聊天记录ID')
|
||
# chat/agent_chat等
|
||
chat_type = Column(String(50), comment='聊天类型')
|
||
query = Column(String(4096), comment='用户问题')
|
||
response = Column(String(4096), comment='模型回答')
|
||
# 记录知识库id等,以便后续扩展
|
||
meta_data = Column(JSON, default={})
|
||
# 满分100 越高表示评价越好
|
||
feedback_score = Column(Integer, default=-1, comment='用户评分')
|
||
feedback_reason = Column(String(255), default="", comment='用户评分理由')
|
||
create_time = Column(DateTime, default=func.now(), comment='创建时间')
|
||
|
||
def __repr__(self):
|
||
return f"<ChatHistory(id='{self.id}', chat_type='{self.chat_type}', query='{self.query}', response='{self.response}',meta_data='{self.meta_data}',feedback_score='{self.feedback_score}',feedback_reason='{self.feedback_reason}', create_time='{self.create_time}')>"
|