ciyidogan commited on
Commit
d0fd8e6
·
verified ·
1 Parent(s): 8fa51cb

Update admin_routes.py

Browse files
Files changed (1) hide show
  1. admin_routes.py +17 -2
admin_routes.py CHANGED
@@ -453,7 +453,11 @@ async def update_environment(
453
  elif update.work_mode in ("hfcloud", "cloud"):
454
  if not update.cloud_token:
455
  raise HTTPException(status_code=400, detail="Cloud token is required for cloud modes")
456
-
 
 
 
 
457
  # TTS/STT validation
458
  if update.tts_engine not in ("no_tts", "elevenlabs", "blaze"):
459
  raise HTTPException(status_code=400, detail="Invalid TTS engine")
@@ -474,18 +478,29 @@ async def update_environment(
474
  # Encrypt API keys if needed
475
  from encryption_utils import encrypt
476
 
 
 
 
 
 
 
 
 
477
  # Update config
478
  config["config"]["work_mode"] = update.work_mode
479
  config["config"]["cloud_token"] = update.cloud_token or ""
480
  config["config"]["spark_endpoint"] = update.spark_endpoint
481
  config["config"]["internal_prompt"] = update.internal_prompt or ""
482
  config["config"]["tts_engine"] = update.tts_engine
483
- config["config"]["tts_engine_api_key"] = encrypt(update.tts_engine_api_key) if update.tts_engine_api_key else ""
484
  config["config"]["stt_engine"] = update.stt_engine
485
  config["config"]["stt_engine_api_key"] = encrypt(update.stt_engine_api_key) if update.stt_engine_api_key else ""
486
  config["config"]["last_update_date"] = get_timestamp()
487
  config["config"]["last_update_user"] = username
488
 
 
 
 
489
  # Add activity log
490
  add_activity_log(config, username, "UPDATE_ENVIRONMENT", "config", None,
491
  "environment", f"Changed to {update.work_mode}, TTS: {update.tts_engine}, STT: {update.stt_engine}")
 
453
  elif update.work_mode in ("hfcloud", "cloud"):
454
  if not update.cloud_token:
455
  raise HTTPException(status_code=400, detail="Cloud token is required for cloud modes")
456
+
457
+ # Debug log - gelen değerleri kontrol et
458
+ log(f"📥 Received TTS engine: {update.tts_engine}")
459
+ log(f"📥 Received TTS key: {'***' + update.tts_engine_api_key[-4:] if update.tts_engine_api_key else 'None'}")
460
+
461
  # TTS/STT validation
462
  if update.tts_engine not in ("no_tts", "elevenlabs", "blaze"):
463
  raise HTTPException(status_code=400, detail="Invalid TTS engine")
 
478
  # Encrypt API keys if needed
479
  from encryption_utils import encrypt
480
 
481
+ # TTS key encryption debug
482
+ if update.tts_engine_api_key:
483
+ encrypted_tts_key = encrypt(update.tts_engine_api_key)
484
+ log(f"🔐 Encrypted TTS key: {encrypted_tts_key[:20]}...")
485
+ else:
486
+ encrypted_tts_key = ""
487
+ log("⚠️ No TTS key to encrypt")
488
+
489
  # Update config
490
  config["config"]["work_mode"] = update.work_mode
491
  config["config"]["cloud_token"] = update.cloud_token or ""
492
  config["config"]["spark_endpoint"] = update.spark_endpoint
493
  config["config"]["internal_prompt"] = update.internal_prompt or ""
494
  config["config"]["tts_engine"] = update.tts_engine
495
+ config["config"]["tts_engine_api_key"] = encrypted_tts_key # Direkt encrypted değeri kullan
496
  config["config"]["stt_engine"] = update.stt_engine
497
  config["config"]["stt_engine_api_key"] = encrypt(update.stt_engine_api_key) if update.stt_engine_api_key else ""
498
  config["config"]["last_update_date"] = get_timestamp()
499
  config["config"]["last_update_user"] = username
500
 
501
+ # Save öncesi kontrol
502
+ log(f"💾 Config before save - TTS key: {config['config'].get('tts_engine_api_key', 'NOT SET')[:20]}...")
503
+
504
  # Add activity log
505
  add_activity_log(config, username, "UPDATE_ENVIRONMENT", "config", None,
506
  "environment", f"Changed to {update.work_mode}, TTS: {update.tts_engine}, STT: {update.stt_engine}")