Spaces:
Configuration error
Configuration error
Download cli/toolbox.py from AnthropicallyHuggingFaces/ai-platform-toolbox: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/resolve/main/cli/toolbox.py
- Command line
-
hf download hf://spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/cli/toolbox.py
-
curl -L -o toolbox.py https://huggingface.co/spaces/AnthropicallyHuggingFaces/ai-platform-toolbox/resolve/main/cli/toolbox.py
2.26 kB
| #!/usr/bin/env python3 | |
| """toolbox.py - CLI over the registry + orchestrator. | |
| Examples: | |
| python cli/toolbox.py providers | |
| python cli/toolbox.py capabilities | |
| python cli/toolbox.py endpoints groq | |
| python cli/toolbox.py run "summarize recent NVIDIA news" | |
| python cli/toolbox.py gateway # start the inference gateway | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(ROOT / "runtime")) | |
| def cmd_providers(): | |
| from registry_loader import providers | |
| for name, p in providers().items(): | |
| print(f"{name:16} type={p.get('type','?'):16} label={p.get('label','?')}") | |
| prem = p.get("premium_features") or [] | |
| if prem: | |
| print(f" premium: {', '.join(prem)}") | |
| def cmd_capabilities(): | |
| from registry_loader import capabilities | |
| for name, c in capabilities().items(): | |
| flag = "ON" if c.get("default_on") else "off" | |
| prem = " (premium)" if c.get("premium") else "" | |
| print(f"{name:28} {flag}{prem}") | |
| def cmd_endpoints(provider: str): | |
| from registry_loader import endpoints | |
| ep = endpoints().get(provider, {}) | |
| for k, v in ep.items(): | |
| print(f" {k:24} {v}") | |
| def cmd_run(prompt: str): | |
| from agent import run | |
| print(run(prompt)) | |
| def cmd_gateway(): | |
| import uvicorn | |
| sys.path.insert(0, str(ROOT / "90-execution/distributed-inference/gateway")) | |
| uvicorn.run("gateway:app", host="0.0.0.0", port=int(8000)) | |
| def main() -> int: | |
| ap = argparse.ArgumentParser(prog="toolbox") | |
| sub = ap.add_subparsers(dest="cmd", required=True) | |
| sub.add_parser("providers") | |
| sub.add_parser("capabilities") | |
| p = sub.add_parser("endpoints") | |
| p.add_argument("provider") | |
| r = sub.add_parser("run") | |
| r.add_argument("prompt") | |
| sub.add_parser("gateway") | |
| args = ap.parse_args() | |
| if args.cmd == "providers": | |
| cmd_providers() | |
| elif args.cmd == "capabilities": | |
| cmd_capabilities() | |
| elif args.cmd == "endpoints": | |
| cmd_endpoints(args.provider) | |
| elif args.cmd == "run": | |
| cmd_run(args.prompt) | |
| elif args.cmd == "gateway": | |
| cmd_gateway() | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |