Download tools/smoke_api.py from Angshul/Falcon-H1-0.5B-Rust: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/Angshul/Falcon-H1-0.5B-Rust/resolve/main/tools/smoke_api.py
- Command line
-
hf download hf://Angshul/Falcon-H1-0.5B-Rust/tools/smoke_api.py
-
curl -L -o smoke_api.py https://huggingface.co/Angshul/Falcon-H1-0.5B-Rust/resolve/main/tools/smoke_api.py
1.1 kB
| """Check actual HTTP endpoint execution, including reported device.""" | |
| import argparse | |
| import json | |
| import urllib.request | |
| p = argparse.ArgumentParser() | |
| p.add_argument('--backend', default='cpu-reference') | |
| p.add_argument('--url', default='http://127.0.0.1:8080') | |
| a = p.parse_args() | |
| def request(path, data=None): | |
| body = json.dumps(data).encode() if data is not None else None | |
| req = urllib.request.Request(a.url+path, data=body, | |
| headers={'Content-Type': 'application/json'} if body else {}) | |
| with urllib.request.urlopen(req, timeout=600) as resp: | |
| assert resp.status == 200 | |
| return json.load(resp) | |
| health = request('/health') | |
| assert health['status'] == 'ok', health | |
| assert health['backend'] == a.backend, health | |
| info = request('/v1/model') | |
| assert info['architecture'] == 'falcon_h1' | |
| assert info['backend'] == a.backend | |
| assert len(request('/v1/logits', {'input_ids': [1,2,3]})['logits']) == 64 | |
| assert len(request('/v1/generate', {'input_ids': [1,2], 'max_new_tokens':2})['output_ids']) == 4 | |
| print('PASS:', a.backend, 'health, model, logits, generate via HTTP') | |