Spaces:
Configuration error
Configuration error
File size: 2,264 Bytes
e6e73c8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #!/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())
|