feat: add topic summaries and growth profiles
This commit is contained in:
@@ -3,6 +3,7 @@ from app.models.ai_config import ModelConfig, Prompt, SystemConfig
|
||||
from app.models.base import Base
|
||||
from app.models.chat import ChatMessage, ChatSession, TopicSession
|
||||
from app.models.entitlement import EntitlementPlan, UserEntitlement, UserEntitlementLog
|
||||
from app.models.growth import GrowthProfileRevision, TopicSummary, UserGrowthProfile
|
||||
from app.models.knowledge import (
|
||||
HumanAttentionHistory,
|
||||
HumanAttentionRecord,
|
||||
@@ -30,6 +31,7 @@ __all__ = [
|
||||
"ChatMessage",
|
||||
"ChatSession",
|
||||
"EntitlementPlan",
|
||||
"GrowthProfileRevision",
|
||||
"Knowledge",
|
||||
"KnowledgeCard",
|
||||
"KnowledgeChunk",
|
||||
@@ -49,11 +51,13 @@ __all__ = [
|
||||
"LogRetentionPolicy",
|
||||
"StorageSnapshot",
|
||||
"TopicSession",
|
||||
"TopicSummary",
|
||||
"Prompt",
|
||||
"Role",
|
||||
"SystemConfig",
|
||||
"User",
|
||||
"UserEntitlement",
|
||||
"UserEntitlementLog",
|
||||
"UserGrowthProfile",
|
||||
"UserKnowledgePermission",
|
||||
]
|
||||
|
||||
66
ai_knowledge_base_v2/apps/backend/app/models/growth.py
Normal file
66
ai_knowledge_base_v2/apps/backend/app/models/growth.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import BigInteger, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
PRIMARY_KEY_TYPE = BigInteger().with_variant(Integer, "sqlite")
|
||||
|
||||
|
||||
class TopicSummary(Base):
|
||||
__tablename__ = "sys_topic_summary"
|
||||
__table_args__ = (UniqueConstraint("topic_session_id", name="uq_sys_topic_summary_topic"),)
|
||||
|
||||
id: Mapped[int] = mapped_column(PRIMARY_KEY_TYPE, primary_key=True, autoincrement=True)
|
||||
topic_session_id: Mapped[int] = mapped_column(ForeignKey("sys_topic_session.id"), index=True, nullable=False)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("sys_user.id"), index=True, nullable=False)
|
||||
summary: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
main_events: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
emotions: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
body_feelings: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
beliefs: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
recommended_homework: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
insights: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
next_observation: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
model_name: Mapped[str | None] = mapped_column(String(100), nullable=True)
|
||||
status: Mapped[str] = mapped_column(String(20), default="success", index=True, nullable=False)
|
||||
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
generated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)
|
||||
|
||||
|
||||
class UserGrowthProfile(Base):
|
||||
__tablename__ = "sys_user_growth_profile"
|
||||
__table_args__ = (UniqueConstraint("user_id", name="uq_sys_user_growth_profile_user"),)
|
||||
|
||||
id: Mapped[int] = mapped_column(PRIMARY_KEY_TYPE, primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("sys_user.id"), index=True, nullable=False)
|
||||
profile_text: Mapped[str] = mapped_column(Text, default="", nullable=False)
|
||||
recurring_topics: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
common_emotions: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
body_patterns: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
relation_patterns: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
homework_done: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
effective_homework: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
recent_progress: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
last_topic_summary_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
|
||||
updated_by: Mapped[str] = mapped_column(String(30), default="system", nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)
|
||||
|
||||
|
||||
class GrowthProfileRevision(Base):
|
||||
__tablename__ = "sys_growth_profile_revision"
|
||||
|
||||
id: Mapped[int] = mapped_column(PRIMARY_KEY_TYPE, primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(ForeignKey("sys_user.id"), index=True, nullable=False)
|
||||
profile_id: Mapped[int] = mapped_column(ForeignKey("sys_user_growth_profile.id"), index=True, nullable=False)
|
||||
topic_summary_id: Mapped[int | None] = mapped_column(BigInteger, index=True, nullable=True)
|
||||
before_json: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
after_json: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
reason: Mapped[str] = mapped_column(String(50), default="topic_summary", nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
|
||||
Reference in New Issue
Block a user