live: EXTERNAL_SERVICE_TOKEN precedence, baked A/B candidates, model|gpu ledger from task/page modelId+gpuType, string total fix, Iluvatar/MTT enums (59 tests)

This commit is contained in:
Victor Cao
2026-10-17 06:53:56 +08:00
parent 3adf13ad22
commit 49d59b6bd4
20 changed files with 5029 additions and 129 deletions

View File

@@ -12,10 +12,10 @@ from typing import Optional
# Community alias order (level C); we only check presence, never echo values.
_TOKEN_ENV_KEYS = (
"EXTERNAL_SERVICE_TOKEN",
"XC_TOKEN_FILE",
"XC_TOKEN",
"MODELHUB_XC_TOKEN",
"EXTERNAL_SERVICE_TOKEN",
)
@@ -62,20 +62,9 @@ def _token_from_file(path: str) -> bool:
def external_service_token_present() -> bool:
"""Whether any known token env / file alias is present (boolean only)."""
for key in _TOKEN_ENV_KEYS:
raw = os.environ.get(key)
if raw is None:
continue
value = raw.strip()
if not value:
continue
if key == "XC_TOKEN_FILE":
if _token_from_file(value):
return True
continue
# Reject obvious placeholders (community practice, level C)
lowered = value.lower()
if lowered in ("tmp", "placeholder", "changeme", "xxx"):
continue
from .task_add_client import resolve_token_with_source
try:
resolve_token_with_source()
return True
return False
except (ValueError, OSError, UnicodeError):
return False