Files
xc_agent_platform_demo/src/config_params.py

32 lines
1.4 KiB
Python
Raw Normal View History

"""Offline sample by default; explicit opt-in enables captured build-config API."""
import os
from pathlib import Path
from src.build_config_client import build_config, BuildConfigError
from src.task_add_client import resolve_token
SOURCE = 'POST /api/adapt/task/build-config (discovered via capture); default templates/config_params.sample.yaml'
GAP = 'GAP: build-config API discovered via capture (autoconfig-capture-2026-10-16.md); live/实锤 needs token + API call and auth proof. Sample is dry-run draft only, NOT production-ready.'
def config_params_source():
source = os.environ.get('CONFIG_PARAMS_SOURCE', '').strip()
if source not in ('', 'sample', 'build-config'):
raise BuildConfigError('unsupported CONFIG_PARAMS_SOURCE')
if source == 'build-config':
return 'build-config'
if os.environ.get('ALLOW_BUILD_CONFIG') == '1':
try:
resolve_token()
except (ValueError, OSError):
pass
else:
return 'build-config'
return 'sample'
def build_config_params(gpu_type=None, framework='vllm', task_type='text-generation'):
"""Return YAML; opted-in API failures propagate, never fall back to sample."""
if config_params_source() == 'build-config':
return build_config(gpu_type, framework, task_type)
return (Path(__file__).resolve().parents[1] / 'templates/config_params.sample.yaml').read_text()