probe: show raw responses
This commit is contained in:
1 parent
4860a22215
commit
acc33f5ff4
1 file changed
+26
-13
+26
-13
@@ -14,18 +14,31 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json, os, urllib.request
|
||||
import json, os, urllib.request, urllib.error
|
||||
tok = os.environ["GH_TOKEN"]
|
||||
h = {"Authorization": f"Bearer {tok}", "Accept": "application/json"}
|
||||
req = urllib.request.Request("https://models.github.ai/catalog/models", headers=h)
|
||||
cat = json.loads(urllib.request.urlopen(req, timeout=30).read())
|
||||
print(f"{len(cat)} models")
|
||||
for m in cat:
|
||||
print(m["id"], "|", m.get("rate_limit_tier"), "|", m.get("publisher"))
|
||||
body = {"model": "openai/gpt-4.1-mini", "messages": [{"role": "user", "content": "Reply with exactly: ok"}]}
|
||||
req = urllib.request.Request("https://models.github.ai/inference/chat/completions",
|
||||
data=json.dumps(body).encode(), method="POST",
|
||||
headers={**h, "Content-Type": "application/json"})
|
||||
out = json.loads(urllib.request.urlopen(req, timeout=60).read())
|
||||
print("inference:", out["choices"][0]["message"]["content"])
|
||||
h = {"Authorization": f"Bearer {tok}", "Accept": "application/vnd.github+json",
|
||||
"X-GitHub-Api-Version": "2022-11-28"}
|
||||
def call(url, body=None):
|
||||
req = urllib.request.Request(url, headers={**h, "Content-Type": "application/json"},
|
||||
data=json.dumps(body).encode() if body else None,
|
||||
method="POST" if body else "GET")
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
return r.status, r.headers.get("Content-Type"), r.read().decode(errors="replace")
|
||||
except urllib.error.HTTPError as e:
|
||||
return e.code, e.headers.get("Content-Type"), e.read().decode(errors="replace")
|
||||
st, ct, txt = call("https://models.github.ai/catalog/models")
|
||||
print("catalog:", st, ct, len(txt), "bytes")
|
||||
try:
|
||||
for m in json.loads(txt):
|
||||
print(" ", m["id"], "|", m.get("rate_limit_tier"))
|
||||
except Exception:
|
||||
print(" raw:", txt[:300])
|
||||
for model in ("openai/gpt-4.1-mini", "xai/grok-3-mini", "deepseek/deepseek-v3-0324", "meta/llama-4-scout-17b-16e-instruct"):
|
||||
st, ct, txt = call("https://models.github.ai/inference/chat/completions",
|
||||
{"model": model, "messages": [{"role": "user", "content": "Reply with exactly: ok"}]})
|
||||
try:
|
||||
print("inference", model, st, json.loads(txt)["choices"][0]["message"]["content"][:40])
|
||||
except Exception:
|
||||
print("inference", model, st, txt[:200])
|
||||
PY
|
||||
Reference in new issue
Block a user