feat: add NSFW script generation feature and Grok API configuration
This commit is contained in:
@@ -32,14 +32,16 @@ def create_user_by_admin(
|
||||
email: str,
|
||||
hashed_password: str,
|
||||
is_superuser: bool = False,
|
||||
can_use_local_model: bool = False
|
||||
can_use_local_model: bool = False,
|
||||
can_use_nsfw: bool = False
|
||||
) -> User:
|
||||
user = User(
|
||||
username=username,
|
||||
email=email,
|
||||
hashed_password=hashed_password,
|
||||
is_superuser=is_superuser,
|
||||
can_use_local_model=can_use_local_model
|
||||
can_use_local_model=can_use_local_model,
|
||||
can_use_nsfw=can_use_nsfw
|
||||
)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
@@ -62,7 +64,8 @@ def update_user(
|
||||
hashed_password: Optional[str] = None,
|
||||
is_active: Optional[bool] = None,
|
||||
is_superuser: Optional[bool] = None,
|
||||
can_use_local_model: Optional[bool] = None
|
||||
can_use_local_model: Optional[bool] = None,
|
||||
can_use_nsfw: Optional[bool] = None
|
||||
) -> Optional[User]:
|
||||
user = get_user_by_id(db, user_id)
|
||||
if not user:
|
||||
@@ -80,6 +83,8 @@ def update_user(
|
||||
user.is_superuser = is_superuser
|
||||
if can_use_local_model is not None:
|
||||
user.can_use_local_model = can_use_local_model
|
||||
if can_use_nsfw is not None:
|
||||
user.can_use_nsfw = can_use_nsfw
|
||||
|
||||
user.updated_at = datetime.utcnow()
|
||||
db.commit()
|
||||
@@ -273,6 +278,9 @@ def update_system_setting(db: Session, key: str, value: dict) -> SystemSettings:
|
||||
def can_user_use_local_model(user: User) -> bool:
|
||||
return user.is_superuser or user.can_use_local_model
|
||||
|
||||
def can_user_use_nsfw(user: User) -> bool:
|
||||
return user.is_superuser or user.can_use_nsfw
|
||||
|
||||
def create_voice_design(
|
||||
db: Session,
|
||||
user_id: int,
|
||||
|
||||
@@ -44,6 +44,7 @@ def init_db():
|
||||
"ALTER TABLE audiobook_segments ADD COLUMN emo_text VARCHAR(20)",
|
||||
"ALTER TABLE audiobook_segments ADD COLUMN emo_alpha REAL",
|
||||
"ALTER TABLE audiobook_projects ADD COLUMN script_config JSON",
|
||||
"ALTER TABLE users ADD COLUMN can_use_nsfw BOOLEAN DEFAULT FALSE NOT NULL",
|
||||
]:
|
||||
try:
|
||||
conn.execute(__import__("sqlalchemy").text(col_def))
|
||||
|
||||
@@ -39,6 +39,7 @@ class User(Base):
|
||||
llm_base_url = Column(String(500), nullable=True)
|
||||
llm_model = Column(String(200), nullable=True)
|
||||
can_use_local_model = Column(Boolean, default=False, nullable=False)
|
||||
can_use_nsfw = Column(Boolean, default=False, nullable=False)
|
||||
user_preferences = Column(JSON, nullable=True, default=lambda: {"default_backend": "aliyun", "onboarding_completed": False})
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
||||
|
||||
Reference in New Issue
Block a user