fix: separate voice credentials and refresh feature toggle

This commit is contained in:
2026-08-11 17:46:56 +08:00
parent fd2da26d10
commit 74213a363f
10 changed files with 97 additions and 11 deletions

View File

@@ -49,6 +49,8 @@ class Settings(BaseSettings):
aliyun_sms_template_param_key: str = "code"
aliyun_sms_endpoint: str = "dysmsapi.aliyuncs.com"
aliyun_nls_app_key: str = ""
aliyun_nls_access_key_id: str = ""
aliyun_nls_access_key_secret: str = ""
aliyun_nls_endpoint: str = "https://nls-gateway-cn-shanghai.aliyuncs.com/stream/v1/asr"
mock_rag_enabled: bool = False
mock_model_enabled: bool = True

View File

@@ -10,7 +10,11 @@ from app.core.config import get_settings
ENCRYPTED_PREFIX = "enc:v1:"
MASKED_SECRET = "******"
SENSITIVE_CONFIG_KEYS = {"aliyun_sms_access_key_secret", "feishu_app_secret"}
SENSITIVE_CONFIG_KEYS = {
"aliyun_sms_access_key_secret",
"aliyun_nls_access_key_secret",
"feishu_app_secret",
}
class SecretService:

View File

@@ -105,15 +105,15 @@ def load_voice_config(db: Session) -> VoiceInputConfig:
values = {row.config_key: row.config_value for row in rows}
enabled = _bool(values.get("voice_input_enabled"), settings.voice_input_enabled)
duration = _int(values.get("voice_max_duration_seconds"), settings.voice_max_duration_seconds, 5, 60)
access_key_id = str(values.get("aliyun_sms_access_key_id") or settings.aliyun_sms_access_key_id).strip()
encrypted_secret = str(values.get("aliyun_sms_access_key_secret") or settings.aliyun_sms_access_key_secret).strip()
access_key_id = str(values.get("aliyun_nls_access_key_id") or settings.aliyun_nls_access_key_id).strip()
encrypted_secret = str(values.get("aliyun_nls_access_key_secret") or settings.aliyun_nls_access_key_secret).strip()
return VoiceInputConfig(
enabled=enabled,
max_duration_seconds=duration,
app_key=settings.aliyun_nls_app_key.strip(),
app_key=str(values.get("aliyun_nls_app_key") or settings.aliyun_nls_app_key).strip(),
access_key_id=access_key_id,
access_key_secret=SecretService.decrypt(encrypted_secret),
endpoint=settings.aliyun_nls_endpoint.strip(),
endpoint=str(values.get("aliyun_nls_endpoint") or settings.aliyun_nls_endpoint).strip(),
)