Fiabilise le préchargement et le benchmark

This commit is contained in:
Michael committed 2026-07-07 15:25:12 +02:00
1 parent d9169a1d27
commit 0f6abf6dde
7 files changed
+154 -49

No files matched your search

+10 -3
View File
@@ -24,9 +24,16 @@ async def scores() -> dict:
@router.post("")
async def run(req: BenchRequest) -> StreamingResponse:
async def event_stream():
async for ev in bench.run_bench(req.model):
etype = ev.pop("type")
yield f"event: {etype}\ndata: {json.dumps(ev, ensure_ascii=False)}\n\n"
try:
async for ev in bench.run_bench(req.model):
etype = ev.pop("type")
yield f"event: {etype}\ndata: {json.dumps(ev, ensure_ascii=False)}\n\n"
except Exception as exc:
payload = json.dumps(
{"message": f"benchmark interrompu : {str(exc)[:200]}"},
ensure_ascii=False,
)
yield f"event: error\ndata: {payload}\n\n"
return StreamingResponse(
event_stream(),