interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / tools / omegallm-ui / check.py

78 lines · 3301 bytes Raw Blame History
1#!/usr/bin/env python3
2"""HTTP test oracle only. Not a model runtime or installation dependency."""
3import argparse
4import hashlib
5import json
6import time
7import urllib.error
8import urllib.request
9from pathlib import Path
10
11p = argparse.ArgumentParser()
12p.add_argument("--port", type=int, choices=(8098, 8099), required=True)
13p.add_argument("--output", type=Path, required=True)
14a = p.parse_args()
15model = "Omega-Astra-Aienux" if a.port == 8099 else "Omega-Astra-2026-11-04"
16base = f"http://127.0.0.1:{a.port}"
17results = []
18
19def request(path, body=None, headers=None):
20 return urllib.request.urlopen(urllib.request.Request(
21 base + path, None if body is None else json.dumps(body).encode(),
22 {"Content-Type": "application/json", **(headers or {})}), timeout=180)
23
24body = {"model": model, "messages": [{"role": "user", "content":
25 "Once upon a time, a little robot found a lost kitten."}],
26 "temperature": 0, "seed": 42, "max_tokens": 1, "stream": True}
27start = time.monotonic()
28text = ""
29first = None
30done = False
31with request("/v1/chat/completions", body) as response:
32 for raw in response:
33 if not raw.startswith(b"data: "):
34 continue
35 line = raw[6:].strip()
36 if line == b"[DONE]":
37 done = True
38 break
39 part = json.loads(line)["choices"][0]["delta"].get("content", "")
40 if part and first is None:
41 first = time.monotonic() - start
42 text += part
43assert text == " The" and done, (text, done)
44results.append({"case": "stream-parity", "model": model, "text": text,
45 "first_text_seconds": first, "total_seconds": time.monotonic() - start, "pass": True})
46
47for name, payload, headers, expected in [
48 ("unknown-model", {"model": "unknown", "messages": []}, {}, 404),
49 ("empty-prompt", {"model": model, "messages": []}, {}, 400),
50 ("foreign-origin", body, {"Origin": "https://example.invalid"}, 403),
51 ("foreign-host", body, {"Host": "example.invalid"}, 403),
52 ("tools", {**body, "tools": [{}]}, {}, 400),
53]:
54 try:
55 with request("/v1/chat/completions", payload, headers) as r:
56 status = r.status
57 except urllib.error.HTTPError as e:
58 status = e.code
59 assert status == expected, (name, status, expected)
60 results.append({"case": name, "status": status, "pass": True})
61
62with request("/") as r:
63 actual = r.read()
64with urllib.request.urlopen(urllib.request.Request("http://127.0.0.1:8097/",
65 headers={"Accept-Encoding": "gzip"}), timeout=10) as r:
66 reference = r.read()
67assert actual == reference, "UI asset proxy changed the upstream bytes"
68results.append({"case": "ui-assets", "sha256": hashlib.sha256(actual).hexdigest(), "pass": True})
69
70with request("/v1/chat/completions", {"model": "build-mac/qwen.gguf", "messages": [
71 {"role": "user", "content": "What is 17 plus 25? Answer with only the number."}],
72 "temperature": 0, "max_tokens": 8, "stream": False}) as r:
73 answer = json.load(r)["choices"][0]["message"]["content"]
74assert "42" in answer, answer
75results.append({"case": "qwen-route", "text": answer, "pass": True})
76a.output.parent.mkdir(parents=True, exist_ok=True)
77a.output.write_text(json.dumps({"port": a.port, "results": results}, indent=2) + "\n")
78print(f"PASS port={a.port} checks={len(results)}")