Adarshu07 commited on
Commit
b0df81d
·
verified ·
1 Parent(s): e86212e

Delete smoke_test.py

Browse files
Files changed (1) hide show
  1. smoke_test.py +0 -79
smoke_test.py DELETED
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Small end-to-end check for a running local or Hugging Face deployment."""
3
- from __future__ import annotations
4
-
5
- import json
6
- import sys
7
-
8
- import httpx
9
-
10
-
11
- def check(name: str, condition: bool, detail: str = "") -> None:
12
- mark = "✓" if condition else "✗"
13
- print(f"{mark} {name}{': ' + detail if detail else ''}")
14
- if not condition:
15
- raise SystemExit(1)
16
-
17
-
18
- def main() -> None:
19
- base = (sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:7860").rstrip("/")
20
- model = sys.argv[2] if len(sys.argv) > 2 else "osaii/faster-experimental"
21
-
22
- with httpx.Client(timeout=120, follow_redirects=True) as client:
23
- health = client.get(f"{base}/healthz")
24
- check("health", health.status_code == 200 and health.json().get("ok") is True)
25
-
26
- models = client.get(
27
- f"{base}/v1/models", headers={"Authorization": "Bearer public"}
28
- )
29
- model_data = models.json().get("data", []) if models.status_code == 200 else []
30
- ids = [item.get("id") for item in model_data if isinstance(item, dict)]
31
- check("models", models.status_code == 200 and bool(ids), f"{len(ids)} available")
32
- check("selected model exists", model in ids, model)
33
-
34
- payload = {
35
- "model": model,
36
- "stream": False,
37
- "messages": [{"role": "user", "content": "Reply with exactly: OK"}],
38
- }
39
- reply = client.post(
40
- f"{base}/v1/chat/completions",
41
- headers={"Authorization": "Bearer public"},
42
- json=payload,
43
- )
44
- try:
45
- answer = reply.json()["choices"][0]["message"]
46
- except Exception:
47
- answer = {}
48
- check("JSON chat", reply.status_code == 200 and bool(answer), reply.text[:160])
49
-
50
- payload["stream"] = True
51
- payload["stream_options"] = {"include_usage": True}
52
- chunks = 0
53
- done = False
54
- with client.stream(
55
- "POST",
56
- f"{base}/v1/chat/completions",
57
- headers={"Authorization": "Bearer public"},
58
- json=payload,
59
- ) as stream:
60
- check(
61
- "SSE content type",
62
- stream.headers.get("content-type", "").startswith("text/event-stream"),
63
- )
64
- for line in stream.iter_lines():
65
- if not line.startswith("data: "):
66
- continue
67
- if line[6:] == "[DONE]":
68
- done = True
69
- else:
70
- json.loads(line[6:])
71
- chunks += 1
72
- check("SSE chunks", chunks > 0, str(chunks))
73
- check("SSE done marker", done)
74
-
75
- print("\nAll smoke checks passed.")
76
-
77
-
78
- if __name__ == "__main__":
79
- main()