feat: add admin usage statistics and LLM configuration management
This commit is contained in:
@@ -47,6 +47,7 @@ class User(Base):
|
||||
voice_caches = relationship("VoiceCache", back_populates="user", cascade="all, delete-orphan")
|
||||
voice_designs = relationship("VoiceDesign", back_populates="user", cascade="all, delete-orphan")
|
||||
audiobook_projects = relationship("AudiobookProject", back_populates="user", cascade="all, delete-orphan")
|
||||
usage_logs = relationship("UsageLog", back_populates="user", cascade="all, delete-orphan")
|
||||
|
||||
class Job(Base):
|
||||
__tablename__ = "jobs"
|
||||
@@ -200,3 +201,17 @@ class AudiobookSegment(Base):
|
||||
__table_args__ = (
|
||||
Index('idx_project_chapter', 'project_id', 'chapter_index', 'segment_index'),
|
||||
)
|
||||
|
||||
|
||||
class UsageLog(Base):
|
||||
__tablename__ = "usage_logs"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
prompt_tokens = Column(Integer, nullable=False, default=0)
|
||||
completion_tokens = Column(Integer, nullable=False, default=0)
|
||||
model = Column(String(200), nullable=True)
|
||||
context = Column(String(100), nullable=True)
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False, index=True)
|
||||
|
||||
user = relationship("User", back_populates="usage_logs")
|
||||
|
||||
Reference in New Issue
Block a user