Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: add example file rendering for supported file types in the Gradio app

myhloli73631e018414
diff --git a/mineru/kit/gradio/app.py b/mineru/kit/gradio/app.py
index d96fc60f..d6796e19 100644
--- a/mineru/kit/gradio/app.py
+++ b/mineru/kit/gradio/app.py
@@ -427,6 +427,8 @@ def build_gradio_app(
inputs=input_file,
label=i18n("mineru.examples"),
elem_id="mineru-kit-examples",
+ # 示例全部落在第一页,超出由卡片内部滚动;避免出现翻页控件。
+ examples_per_page=_EXAMPLES_PER_PAGE,
)
with gr.Column(scale=4, min_width=340, elem_classes=["mineru-kit-preview", "mineru-preview-pane"]):
@@ -1080,6 +1082,10 @@ def _example_files(file_types: list[str]) -> list[str]:
return [str(path) for path in sorted(example_root.iterdir()) if path.is_file() and path.suffix.lower() in suffixes]
+# 示例数量预期很小;单页放全部文件,翻页交给卡片内部滚动。
+_EXAMPLES_PER_PAGE = 1000
+
+
def _gradio_public_base_url(request: object | None = None) -> str:
"""从 Gradio 请求获取当前外部站点根地址,保留反向代理协议、域名和挂载路径。"""
headers = getattr(request, "headers", None) or {}
diff --git a/tests/unittest/test_kit_gradio.py b/tests/unittest/test_kit_gradio.py
index 51305d41..e4332f92 100644
--- a/tests/unittest/test_kit_gradio.py
+++ b/tests/unittest/test_kit_gradio.py
@@ -1049,6 +1049,7 @@ def test_gradio_examples_render_only_with_local_files(monkeypatch: pytest.Monkey
demo = build_gradio_app(Mock(), capabilities, output_root=tmp_path / "out", enable_example=True)
(dataset,) = find_examples(demo)
assert [sample[0] for sample in dataset.samples] == ["demo.pdf"]
+ assert dataset.samples_per_page == gradio_app._EXAMPLES_PER_PAGE
upload = next(block for block in demo.blocks.values() if "mineru-upload-file" in (block.elem_classes or []))
click = next(event for event in demo.config["dependencies"] if (dataset._id, "click") in event["targets"])
assert upload._id in click["outputs"]