Download scripts/check_teacher.py from 42e/mathcompose: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/42e/mathcompose/resolve/ca5eeebef012b49d221da68dddbc4ccfd0266c63/scripts/check_teacher.py
- Command line
-
hf download hf://42e/mathcompose@ca5eeebef012b49d221da68dddbc4ccfd0266c63/scripts/check_teacher.py
-
curl -L -o check_teacher.py https://huggingface.co/42e/mathcompose/resolve/ca5eeebef012b49d221da68dddbc4ccfd0266c63/scripts/check_teacher.py
1.44 kB
| """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()) | |