cazyundee commited on
Commit
1da23c9
·
verified ·
1 Parent(s): 1114348

Add benchmark test endpoint to diagnose issues

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -626,6 +626,37 @@ def _patched_create_app(blocks, **kwargs):
626
  except Exception as e:
627
  return JSONResponse({"error": str(e)}, status_code=500)
628
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
  _log("Respite API discovery routes injected")
630
  return fa_app
631
 
 
626
  except Exception as e:
627
  return JSONResponse({"error": str(e)}, status_code=500)
628
 
629
+ @fa_app.get("/respite/benchmark/test")
630
+ def _benchmark_test():
631
+ """Quick test: verify llama.cpp binary works."""
632
+ import subprocess as _sp
633
+ try:
634
+ llama_cli = _ensure_llama_cpp()
635
+ # Test binary
636
+ r = _sp.run([llama_cli, "--version"], capture_output=True, text=True, timeout=10)
637
+ binary_ok = r.returncode == 0
638
+ binary_info = r.stdout.strip()[:200] if binary_ok else r.stderr.strip()[:200]
639
+ # Test model download
640
+ from huggingface_hub import hf_hub_download
641
+ model_path = hf_hub_download(
642
+ repo_id="unsloth/gemma-4-E4B-it-GGUF",
643
+ filename="gemma-4-E4B-it-Q4_K_M.gguf",
644
+ cache_dir=_BENCHMARK_CACHE,
645
+ )
646
+ model_ok = os.path.isfile(model_path)
647
+ model_size = os.path.getsize(model_path) if model_ok else 0
648
+ return JSONResponse({
649
+ "binary_path": llama_cli,
650
+ "binary_exists": os.path.isfile(llama_cli),
651
+ "binary_ok": binary_ok,
652
+ "binary_info": binary_info,
653
+ "model_path": model_path,
654
+ "model_ok": model_ok,
655
+ "model_size_gb": round(model_size / 1024**3, 2),
656
+ })
657
+ except Exception as e:
658
+ return JSONResponse({"error": str(e)}, status_code=500)
659
+
660
  _log("Respite API discovery routes injected")
661
  return fa_app
662