feat: add admin usage statistics and LLM configuration management
This commit is contained in:
@@ -72,9 +72,10 @@ async def process_custom_voice_job(
|
||||
|
||||
user_api_key = None
|
||||
if backend_type == "aliyun":
|
||||
user = db.query(User).filter(User.id == user_id).first()
|
||||
if user and user.aliyun_api_key:
|
||||
user_api_key = decrypt_api_key(user.aliyun_api_key)
|
||||
from db.crud import get_system_setting
|
||||
encrypted = get_system_setting(db, "aliyun_api_key")
|
||||
if encrypted:
|
||||
user_api_key = decrypt_api_key(encrypted)
|
||||
|
||||
backend = await TTSServiceFactory.get_backend(backend_type, user_api_key)
|
||||
|
||||
@@ -134,9 +135,10 @@ async def process_voice_design_job(
|
||||
|
||||
user_api_key = None
|
||||
if backend_type == "aliyun":
|
||||
user = db.query(User).filter(User.id == user_id).first()
|
||||
if user and user.aliyun_api_key:
|
||||
user_api_key = decrypt_api_key(user.aliyun_api_key)
|
||||
from db.crud import get_system_setting
|
||||
encrypted = get_system_setting(db, "aliyun_api_key")
|
||||
if encrypted:
|
||||
user_api_key = decrypt_api_key(encrypted)
|
||||
|
||||
backend = await TTSServiceFactory.get_backend(backend_type, user_api_key)
|
||||
|
||||
@@ -201,9 +203,10 @@ async def process_voice_clone_job(
|
||||
from core.security import decrypt_api_key
|
||||
user_api_key = None
|
||||
if backend_type == "aliyun":
|
||||
user = db.query(User).filter(User.id == user_id).first()
|
||||
if user and user.aliyun_api_key:
|
||||
user_api_key = decrypt_api_key(user.aliyun_api_key)
|
||||
from db.crud import get_system_setting
|
||||
encrypted = get_system_setting(db, "aliyun_api_key")
|
||||
if encrypted:
|
||||
user_api_key = decrypt_api_key(encrypted)
|
||||
|
||||
with open(ref_audio_path, 'rb') as f:
|
||||
ref_audio_data = f.read()
|
||||
@@ -352,11 +355,13 @@ async def create_custom_voice_job(
|
||||
detail="Local model is not available. Please contact administrator."
|
||||
)
|
||||
|
||||
if backend_type == "aliyun" and not current_user.aliyun_api_key:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Aliyun API key not configured. Please set your API key in Settings."
|
||||
)
|
||||
if backend_type == "aliyun":
|
||||
from db.crud import get_system_setting
|
||||
if not get_system_setting(db, "aliyun_api_key"):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Aliyun API key not configured. Please contact administrator."
|
||||
)
|
||||
|
||||
try:
|
||||
validate_text_length(req_data.text)
|
||||
@@ -459,11 +464,13 @@ async def create_voice_design_job(
|
||||
detail="Local model is not available. Please contact administrator."
|
||||
)
|
||||
|
||||
if backend_type == "aliyun" and not current_user.aliyun_api_key:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Aliyun API key not configured. Please set your API key in Settings."
|
||||
)
|
||||
if backend_type == "aliyun":
|
||||
from db.crud import get_system_setting
|
||||
if not get_system_setting(db, "aliyun_api_key"):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Aliyun API key not configured. Please contact administrator."
|
||||
)
|
||||
|
||||
try:
|
||||
validate_text_length(req_data.text)
|
||||
@@ -562,11 +569,13 @@ async def create_voice_clone_job(
|
||||
detail="Local model is not available. Please contact administrator."
|
||||
)
|
||||
|
||||
if backend_type == "aliyun" and not current_user.aliyun_api_key:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Aliyun API key not configured. Please set your API key in Settings."
|
||||
)
|
||||
if backend_type == "aliyun":
|
||||
from db.crud import get_system_setting
|
||||
if not get_system_setting(db, "aliyun_api_key"):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Aliyun API key not configured. Please contact administrator."
|
||||
)
|
||||
|
||||
ref_audio_data = None
|
||||
ref_audio_hash = None
|
||||
|
||||
Reference in New Issue
Block a user