feat:初版
This commit is contained in:
5
apps/api/app/models/__init__.py
Normal file
5
apps/api/app/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from .admin import Base, Admin
|
||||
from .ai_provider import AIProvider
|
||||
from .usage_stats import UsageStats
|
||||
|
||||
__all__ = ["Base", "Admin", "AIProvider", "UsageStats"]
|
||||
14
apps/api/app/models/admin.py
Normal file
14
apps/api/app/models/admin.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from sqlalchemy import Column, String, Integer, Float, Boolean, DateTime, Text
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from datetime import datetime
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class Admin(Base):
|
||||
__tablename__ = "admins"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
username = Column(String(50), unique=True, nullable=False)
|
||||
password_hash = Column(String(255), nullable=False)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
17
apps/api/app/models/ai_provider.py
Normal file
17
apps/api/app/models/ai_provider.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from sqlalchemy import Column, String, Integer, Float, Boolean, DateTime, Text
|
||||
from datetime import datetime
|
||||
from .admin import Base
|
||||
|
||||
|
||||
class AIProvider(Base):
|
||||
__tablename__ = "ai_providers"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String(50), nullable=False)
|
||||
model_id = Column(String(100), nullable=False)
|
||||
base_url = Column(String(255))
|
||||
api_key = Column(Text, nullable=False)
|
||||
is_active = Column(Boolean, default=True)
|
||||
is_default = Column(Boolean, default=False)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
17
apps/api/app/models/usage_stats.py
Normal file
17
apps/api/app/models/usage_stats.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from sqlalchemy import Column, String, Integer, BigInteger, DateTime
|
||||
from datetime import datetime
|
||||
from .admin import Base
|
||||
|
||||
|
||||
class UsageStats(Base):
|
||||
__tablename__ = "usage_stats"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
provider_id = Column(Integer, nullable=False)
|
||||
date = Column(String(10), nullable=False)
|
||||
hour = Column(Integer, default=0)
|
||||
request_count = Column(Integer, default=0)
|
||||
input_tokens = Column(BigInteger, default=0)
|
||||
output_tokens = Column(BigInteger, default=0)
|
||||
cached_count = Column(Integer, default=0)
|
||||
error_count = Column(Integer, default=0)
|
||||
Reference in New Issue
Block a user