Farhan Beg commited on
Commit ·
8759429
1
Parent(s): defac91
feat(debug): add Python traceback probe for /api/model/options 500
Browse files- debug-model-options.py +31 -0
- health-server.js +13 -0
debug-model-options.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Debug script: call build_models_payload() directly and print the traceback."""
|
| 3 |
+
import os, sys, traceback, json
|
| 4 |
+
|
| 5 |
+
os.environ.setdefault("HERMES_HOME", "/opt/data")
|
| 6 |
+
sys.path.insert(0, "/opt/hermes")
|
| 7 |
+
sys.path.insert(0, "/opt/hermes/.venv/lib/python3.12/site-packages")
|
| 8 |
+
|
| 9 |
+
try:
|
| 10 |
+
from hermes_cli.inventory import build_models_payload, load_picker_context
|
| 11 |
+
ctx = load_picker_context()
|
| 12 |
+
print("=== load_picker_context OK ===")
|
| 13 |
+
print(f" current_model: {ctx.current_model!r}")
|
| 14 |
+
print(f" current_provider: {ctx.current_provider!r}")
|
| 15 |
+
print(f" current_base_url: {ctx.current_base_url!r}")
|
| 16 |
+
print(f" user_providers: {list(ctx.user_providers.keys()) if isinstance(ctx.user_providers, dict) else type(ctx.user_providers)}")
|
| 17 |
+
print(f" custom_providers: {list(ctx.custom_providers.keys()) if isinstance(ctx.custom_providers, dict) else type(ctx.custom_providers)}")
|
| 18 |
+
except Exception:
|
| 19 |
+
print("=== load_picker_context FAILED ===")
|
| 20 |
+
traceback.print_exc()
|
| 21 |
+
sys.exit(0)
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
result = build_models_payload(ctx, max_models=50, include_unconfigured=True, picker_hints=True, canonical_order=True, pricing=True, capabilities=True)
|
| 25 |
+
print("=== build_models_payload OK ===")
|
| 26 |
+
print(f" providers count: {len(result.get('providers', []))}")
|
| 27 |
+
print(f" model: {result.get('model')!r}")
|
| 28 |
+
print(f" provider: {result.get('provider')!r}")
|
| 29 |
+
except Exception:
|
| 30 |
+
print("=== build_models_payload FAILED ===")
|
| 31 |
+
traceback.print_exc()
|
health-server.js
CHANGED
|
@@ -978,6 +978,19 @@ const server = http.createServer(async (req, res) => {
|
|
| 978 |
return;
|
| 979 |
}
|
| 980 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 981 |
// Legacy /dashboard -> /hm
|
| 982 |
if (path === "/dashboard" || path === "/dashboard/") {
|
| 983 |
redirect(res, `${HM_PREFIX}${parsed.search}`);
|
|
|
|
| 978 |
return;
|
| 979 |
}
|
| 980 |
|
| 981 |
+
// /hm/debug/model-options-trace — runs the Python debug script that
|
| 982 |
+
// calls build_models_payload() directly with full traceback output.
|
| 983 |
+
if (path === `${HM_PREFIX}/debug/model-options-trace`) {
|
| 984 |
+
if (!requireAuth(req, res)) return;
|
| 985 |
+
const { execFile } = require("child_process");
|
| 986 |
+
const script = `${process.env.HUGGINGMES_APP_DIR || "/opt/huggingmes"}/debug-model-options.py`;
|
| 987 |
+
execFile("/opt/hermes/.venv/bin/python", [script], { timeout: 30000 }, (err, stdout, stderr) => {
|
| 988 |
+
res.writeHead(200, { "content-type": "text/plain; charset=utf-8" });
|
| 989 |
+
res.end(`--- stdout ---\n${stdout}\n--- stderr ---\n${stderr}\n--- exit ---\n${err ? err.message : "0"}`);
|
| 990 |
+
});
|
| 991 |
+
return;
|
| 992 |
+
}
|
| 993 |
+
|
| 994 |
// Legacy /dashboard -> /hm
|
| 995 |
if (path === "/dashboard" || path === "/dashboard/") {
|
| 996 |
redirect(res, `${HM_PREFIX}${parsed.search}`);
|