This commit is contained in:
2026-06-16 09:49:16 +08:00
parent 0e2b2f3994
commit e932b07fa6
2 changed files with 11 additions and 2 deletions
+10 -2
View File
@@ -100,8 +100,16 @@ async def process_pdf(file_obj, backend, lang, progress=gr.Progress()):
return "Please upload a PDF file.", "", ""
tmp_dir = tempfile.mkdtemp(prefix="mineru-client-")
file_path = file_obj.name if hasattr(file_obj, "name") else os.path.join(tmp_dir, "input.pdf")
file_name = os.path.basename(file_path)
# 兼容不同 Gradio 版本的 file 返回值
if isinstance(file_obj, str):
file_path = file_obj
file_name = os.path.basename(file_path)
elif hasattr(file_obj, 'name'):
file_path = file_obj.name
file_name = os.path.basename(file_path)
else:
return "Unsupported file object type", "", ""
async with httpx.AsyncClient(timeout=httpx.Timeout(120)) as client:
# 1. 探测 API