Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -287,7 +287,14 @@ async def ocr_pdf(request: Request):
|
|
| 287 |
page_text = _ocr_page_via_siliconflow(local_path, i)
|
| 288 |
if page_text:
|
| 289 |
full_text += page_text + "\n\n"
|
| 290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
|
| 292 |
try:
|
| 293 |
local_path.unlink()
|
|
@@ -1415,5 +1422,4 @@ async def skill_view(request: Request):
|
|
| 1415 |
return JSONResponse({"name": s["name"], "content": r.text[:2000]})
|
| 1416 |
except Exception:
|
| 1417 |
pass
|
| 1418 |
-
return JSONResponse({"error": "not found"}, status_code=404)
|
| 1419 |
-
|
|
|
|
| 287 |
page_text = _ocr_page_via_siliconflow(local_path, i)
|
| 288 |
if page_text:
|
| 289 |
full_text += page_text + "\n\n"
|
| 290 |
+
pct = int(((i + 1) / total_pages) * 100)
|
| 291 |
+
_ocr_tasks[t_id]["progress"] = pct
|
| 292 |
+
# 每页完成后推送进度到 Worker(推模式替代拉模式)
|
| 293 |
+
if cb_url and (i % max(1, total_pages // 10) == 0 or i == total_pages - 1):
|
| 294 |
+
try:
|
| 295 |
+
requests.post(cb_url, json={"ok": True, "task_id": t_id, "status": "processing", "progress": pct}, timeout=10)
|
| 296 |
+
except Exception:
|
| 297 |
+
pass
|
| 298 |
|
| 299 |
try:
|
| 300 |
local_path.unlink()
|
|
|
|
| 1422 |
return JSONResponse({"name": s["name"], "content": r.text[:2000]})
|
| 1423 |
except Exception:
|
| 1424 |
pass
|
| 1425 |
+
return JSONResponse({"error": "not found"}, status_code=404)
|
|
|