feat: add NSFW script generation feature and Grok API configuration

This commit is contained in:
2026-03-13 12:58:28 +08:00
parent 424c3edf0b
commit 0d63d0e6d1
28 changed files with 850 additions and 36 deletions

View File

@@ -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,