Download tools/demo_live.sh from RightNowAI/RightNow-Mini: direct link, hf CLI and curl.
- Browser
- Download file 2.84 kB
-
https://huggingface.co/RightNowAI/RightNow-Mini/resolve/main/tools/demo_live.sh
- Command line
-
hf download hf://RightNowAI/RightNow-Mini/tools/demo_live.sh
-
curl -L -o demo_live.sh https://huggingface.co/RightNowAI/RightNow-Mini/resolve/main/tools/demo_live.sh
2.84 kB
| # Run the side-by-side demo server once against live endpoints and record what each side streamed. | |
| # MINI_URL=http://127.0.0.1:9007 MINI_MODEL=inkling-2-mini OTHER_URL=http://127.0.0.1:18811 bash tools/demo_live.sh | |
| # Writes results/raw/demo_live.json: per side, the HTTP status, seconds, characters and whether text arrived. | |
| set -u | |
| R=/data/train/mini | |
| PORT=${PORT:-8701} | |
| export MINI_URL=${MINI_URL:-http://127.0.0.1:9007} MINI_MODEL=${MINI_MODEL:-inkling-2-mini} | |
| export OTHER_URL=${OTHER_URL:-http://127.0.0.1:18811} OTHER_MODEL=${OTHER_MODEL:-anthropic/claude-opus-5.5} OTHER_KEY_ENV=${OTHER_KEY_ENV:-DEMO_NO_KEY} | |
| cd $R/src | |
| $R/venv/bin/python demo/server.py --port $PORT --max-tokens 400 > $R/logs/demo_live.log 2>&1 & | |
| S=$! | |
| sleep 4 | |
| $R/venv/bin/python - "$PORT" > $R/results/raw/demo_live.json <<'EOF' | |
| import json, sys, time, urllib.request | |
| port = sys.argv[1] | |
| out = {"task": "Write a Python function that merges overlapping intervals. Code only.", "measured": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())} | |
| out["page"] = urllib.request.urlopen(f"http://127.0.0.1:{port}/", timeout=20).status | |
| out["info"] = json.load(urllib.request.urlopen(f"http://127.0.0.1:{port}/info", timeout=20)) | |
| for side in ("mini", "other"): | |
| t0 = time.time() | |
| rec = {} | |
| try: | |
| req = urllib.request.Request(f"http://127.0.0.1:{port}/stream/{side}", data=json.dumps({"task": out["task"]}).encode(), | |
| headers={"Content-Type": "application/json"}) | |
| with urllib.request.urlopen(req, timeout=300) as r: | |
| rec["status"] = r.status | |
| text, first, usage = "", None, None | |
| for line in r: | |
| line = line.decode("utf-8", "replace").strip() | |
| if not line.startswith("data: ") or line == "data: [DONE]": | |
| continue | |
| try: | |
| d = json.loads(line[6:]) | |
| except ValueError: | |
| continue | |
| for c in d.get("choices") or []: | |
| piece = (c.get("delta") or {}).get("content") or (c.get("delta") or {}).get("reasoning") or (c.get("delta") or {}).get("reasoning_content") or "" | |
| if piece and first is None: | |
| first = time.time() - t0 | |
| text += piece | |
| usage = d.get("usage") or usage | |
| rec.update(seconds=round(time.time() - t0, 2), first_text_s=round(first, 2) if first else None, characters=len(text), | |
| completion_tokens=(usage or {}).get("completion_tokens"), has_def=("def " in text)) | |
| except Exception as e: | |
| rec.update(error=f"{type(e).__name__}: {str(e)[:200]}", seconds=round(time.time() - t0, 2)) | |
| out[side] = rec | |
| print(json.dumps(out, indent=1)) | |
| EOF | |
| kill $S 2>/dev/null | |
| cat $R/results/raw/demo_live.json | |