okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221rc1 merge tui-update (3165c2e8a)a1cc285fa

main
967 B17 linesraw
1#!/usr/bin/env python3
2"""prompt_check.py PORT: one real question to the running server; exit 0 when the answer names Canberra.  Standard library only."""
3import json
4import sys
5import time
6import urllib.request
7
8port = sys.argv[1]
9body = {"messages": [{"role": "user", "content": "What is the capital city of Australia? Answer with the city name only."}], "max_tokens": 400, "temperature": 0}
10request = urllib.request.Request(f"http://127.0.0.1:{port}/v1/chat/completions", json.dumps(body).encode(), {"Content-Type": "application/json"})
11started = time.time()
12with urllib.request.urlopen(request, timeout=900) as response:
13    data = json.load(response)
14message = data["choices"][0]["message"]
15text = (message.get("content") or "") + " " + (message.get("reasoning_content") or "")
16print(f"answer ({time.time() - started:.1f}s, {data.get('usage', {}).get('completion_tokens', '?')} tokens): {text.strip()[-160:]!r}")
17sys.exit(0 if "canberra" in text.lower() else 1)