You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

3 years ago
# !/usr/bin/env python3
# -*- encoding : utf-8 -*-
# @Filename : chat.py
# @Software : VSCode
# @Datetime : 2023/03/20 21:46:54
# @Author : leo liu
# @Version : 1.0
# @Description :
"""
聊天模型
"""
from datetime import datetime
from sqlalchemy import Column, Integer, Text, Date, DateTime, ForeignKey, VARCHAR
from sqlalchemy.orm import relationship
from db.base_class import Base
class ChatHistory(Base):
"""
聊天记录
"""
__tablename__ = "nlt_chat_history"
user_id = Column(VARCHAR(32), ForeignKey('nlt_user.user_id'))
username = Column(VARCHAR(128), comment="用户名")
q_content = Column(Text, nullable=False, comment="提问内容")
a_content = Column(Text, nullable=False, comment="回答内容")
q_time = Column(DateTime, default=datetime.now, comment="提问时间")
user = relationship("User", backref="chat_history")
class ChatCountDay(Base):
"""
日聊天计数
"""
__tablename__ = "nlt_chat_count_day"
user_id = Column(VARCHAR(32), ForeignKey('nlt_user.user_id'))
q_time = Column(Date, default=datetime.now, comment="聊天计数日期")
q_times = Column(Integer, default=0, comment="聊天计数")
user = relationship("User", backref="chat_count_day")