File size: 1,437 Bytes
014b14c | 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 | """Verify the teacher gateway is reachable and returns text.
python scripts/check_teacher.py # default: promptlens
python scripts/check_teacher.py --teacher openai
Loads .env, sends a 1-line prompt, prints the reply. Exits non-zero on failure.
"""
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from mathcompose.teachers import get_teacher # noqa: E402
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("--teacher", default="promptlens")
ap.add_argument("--model", default=None)
ap.add_argument("--prompt", default="Reply with exactly: pong")
args = ap.parse_args()
try:
teacher = get_teacher(args.teacher, **({"model": args.model} if args.model else {}))
except Exception as e:
print(f"[FAIL] could not build teacher '{args.teacher}': {e}")
return 1
who = f"{args.teacher} (model={getattr(teacher, 'model', '?')}, base_url={getattr(teacher, 'base_url', None)})"
print(f"calling {who} ...")
try:
reply = teacher.complete(
[{"role": "user", "content": args.prompt}], temperature=0.0, max_tokens=32
)
except Exception as e:
print(f"[FAIL] teacher call errored: {type(e).__name__}: {e}")
return 1
print(f"[OK] reply: {reply!r}")
return 0
if __name__ == "__main__":
raise SystemExit(main())
|