Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import yaml
|
| 3 |
import re
|
| 4 |
import os
|
|
|
|
| 5 |
|
| 6 |
import glmocr
|
| 7 |
GLMOCR_BASE = os.path.dirname(glmocr.__file__)
|
|
@@ -70,6 +71,20 @@ def run_ocr(uploaded_file):
|
|
| 70 |
debug_lines.append(f"7. json_result len: {len(j) if j else 0}")
|
| 71 |
debug_lines.append("==========================")
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
if not isinstance(result, list):
|
| 74 |
result = [result]
|
| 75 |
if not result:
|
|
|
|
| 2 |
import yaml
|
| 3 |
import re
|
| 4 |
import os
|
| 5 |
+
import json
|
| 6 |
|
| 7 |
import glmocr
|
| 8 |
GLMOCR_BASE = os.path.dirname(glmocr.__file__)
|
|
|
|
| 71 |
debug_lines.append(f"7. json_result len: {len(j) if j else 0}")
|
| 72 |
debug_lines.append("==========================")
|
| 73 |
|
| 74 |
+
r0 = result[0] if (isinstance(result, list) and len(result) > 0) else None
|
| 75 |
+
raw_resp = getattr(r0, '_maas_response', None) if r0 else None
|
| 76 |
+
if raw_resp is not None:
|
| 77 |
+
try:
|
| 78 |
+
resp_str = json.dumps(raw_resp, indent=2, ensure_ascii=False)
|
| 79 |
+
except Exception:
|
| 80 |
+
resp_str = str(raw_resp)
|
| 81 |
+
if len(resp_str) > 15000:
|
| 82 |
+
resp_str = resp_str[:15000] + "\n\n... (truncated, total " + str(len(resp_str)) + " chars)"
|
| 83 |
+
debug_lines.append("10. FULL API RESPONSE (first page):")
|
| 84 |
+
debug_lines.append(resp_str)
|
| 85 |
+
else:
|
| 86 |
+
debug_lines.append("10. FULL API RESPONSE: not available (no _maas_response)")
|
| 87 |
+
|
| 88 |
if not isinstance(result, list):
|
| 89 |
result = [result]
|
| 90 |
if not result:
|