支持自定义API接口
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""设置数据模型"""
|
||||
from sqlalchemy import Column, String, Text, Float, Integer, DateTime
|
||||
from sqlalchemy import Column, String, Text, Float, Integer, DateTime, Index
|
||||
from sqlalchemy.sql import func
|
||||
from app.database import Base
|
||||
import uuid
|
||||
@@ -10,6 +10,7 @@ class Settings(Base):
|
||||
__tablename__ = "settings"
|
||||
|
||||
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
user_id = Column(String(50), nullable=False, unique=True, index=True, comment="用户ID")
|
||||
api_provider = Column(String(50), default="openai", comment="API提供商")
|
||||
api_key = Column(String(500), comment="API密钥")
|
||||
api_base_url = Column(String(500), comment="自定义API地址")
|
||||
@@ -20,5 +21,9 @@ class Settings(Base):
|
||||
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_user_id', 'user_id'),
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Settings(id={self.id}, api_provider={self.api_provider})>"
|
||||
return f"<Settings(id={self.id}, user_id={self.user_id}, api_provider={self.api_provider})>"
|
||||
Reference in New Issue
Block a user