Setting up the chat client functionality using SocketIO - Start
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
from ..extensions import db
|
||||
from .user import User, Tenant
|
||||
|
||||
|
||||
class ChatSession(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('public.user.id'), nullable=True)
|
||||
session_start = db.Column(db.DateTime, nullable=False)
|
||||
session_end = db.Column(db.DateTime, nullable=True)
|
||||
|
||||
# Relations
|
||||
chat_interactions = db.relationship('Interaction', backref='chat_session', lazy=True)
|
||||
user = db.relationship('User', backref='chat_sessions', lazy=True)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ChatSession {self.id} by {self.user_id}>"
|
||||
|
||||
|
||||
class Interaction(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
chat_session_id = db.Column(db.Integer, db.ForeignKey('public.chat_session.id'), nullable=False)
|
||||
question = db.Column(db.Text, nullable=False)
|
||||
answer = db.Column(db.Text, nullable=True)
|
||||
language = db.Column(db.String(2), nullable=False)
|
||||
appreciation = db.Column(db.Integer, nullable=True, default=100)
|
||||
|
||||
# Timing information
|
||||
question_at = db.Column(db.DateTime, nullable=False)
|
||||
answer_at = db.Column(db.DateTime, nullable=True)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Interaction {self.id}>"
|
||||
|
||||
|
||||
class InteractionEmbedding(db.Model):
|
||||
interaction_id = db.Column(db.Integer, db.ForeignKey('interaction.id', ondelete='CASCADE'), primary_key=True)
|
||||
embedding_id = db.Column(db.Integer, db.ForeignKey('embedding.id', ondelete='CASCADE'), primary_key=True)
|
||||
|
||||
Reference in New Issue
Block a user