23 lines
832 B
Python
23 lines
832 B
Python
from app.extensions import db
|
|
from datetime import datetime
|
|
|
|
|
|
class AiInsight(db.Model):
|
|
__tablename__ = 'ai_insights'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
insight_date = db.Column(db.Date, nullable=False, index=True)
|
|
insight_type = db.Column(
|
|
db.Enum('daily_summary', 'weekly_summary', 'chat_response', 'alert'),
|
|
nullable=False,
|
|
default='daily_summary'
|
|
)
|
|
prompt_summary = db.Column(db.Text, nullable=True) # what context was sent
|
|
content = db.Column(db.Text, nullable=False) # AI response
|
|
model_used = db.Column(db.String(64), nullable=True)
|
|
tokens_used = db.Column(db.Integer, nullable=True)
|
|
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
|
|
|
def __repr__(self):
|
|
return f'<AiInsight {self.insight_type} {self.insight_date}>'
|