Spaces:
Paused
Paused
File size: 1,127 Bytes
4baaa2f | 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 | """Smoke test: text chat + vision (image_url) against the phi_inference Space."""
import base64
import json
import sys
import requests
BASE = "https://Leon4gr45-phi-inference.hf.space"
# 1) text-only
r = requests.post(f"{BASE}/v1/chat/completions", json={
"model": "lfm2.5-vl-1.6b",
"messages": [{"role": "user", "content": "Say hello in one sentence."}],
"max_tokens": 48,
}, timeout=180)
print("TEXT:", json.dumps(r.json(), indent=2)[:500])
# 2) vision — pass an image path as argv[1], else skip
if len(sys.argv) > 1:
with open(sys.argv[1], "rb") as f:
b64 = base64.b64encode(f.read()).decode()
r = requests.post(f"{BASE}/v1/chat/completions", json={
"model": "lfm2.5-vl-1.6b",
"messages": [{"role": "user", "content": [
{"type": "text", "text": "Describe this image in detail."},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}},
]}],
"max_tokens": 256,
}, timeout=300)
print("VISION:", r.json()["choices"][0]["message"]["content"])
else:
print("(pass an image path as argv[1] to test vision)")
|