Spaces:
Paused
Paused
Download scripts/render_config.py from qf46578/My-openclaw: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/qf46578/My-openclaw/resolve/main/scripts/render_config.py
- Command line
-
hf download hf://spaces/qf46578/My-openclaw/scripts/render_config.py
-
curl -L -o render_config.py https://huggingface.co/spaces/qf46578/My-openclaw/resolve/main/scripts/render_config.py
1.21 kB
| #!/usr/bin/env python3 | |
| import argparse | |
| import os | |
| import sys | |
| PLACEHOLDERS = { | |
| "__GATEWAY_TOKEN__": "GATEWAY_TOKEN", | |
| "__NVIDIA_API_KEY__": "NVIDIA_API_KEY", | |
| "__GOOGLE_API_KEY__": "GOOGLE_API_KEY", | |
| "__MISTRAL_API_KEY__": "MISTRAL_API_KEY", | |
| } | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--template", required=True) | |
| ap.add_argument("--out", required=True) | |
| args = ap.parse_args() | |
| with open(args.template, "r", encoding="utf-8") as f: | |
| text = f.read() | |
| for ph, env_name in PLACEHOLDERS.items(): | |
| val = os.getenv(env_name, "") | |
| # Allow empty optional keys (google/mistral); but gateway token must exist (checked in start.sh) | |
| text = text.replace(ph, val) | |
| # Safety: refuse to write file if template placeholders remain | |
| if "__GATEWAY_TOKEN__" in text or "__NVIDIA_API_KEY__" in text: | |
| print("[render][FATAL] Missing required secrets (GATEWAY_TOKEN/NVIDIA_API_KEY).", file=sys.stderr) | |
| sys.exit(2) | |
| os.makedirs(os.path.dirname(args.out), exist_ok=True) | |
| with open(args.out, "w", encoding="utf-8") as f: | |
| f.write(text) | |
| print(f"[render] wrote {args.out}") | |
| if __name__ == "__main__": | |
| main() |