LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
fix: support MinerU 3.0-3.2 backend names
yyu031fd8d5a8b9c7
diff --git a/src/lib/mineru.test.ts b/src/lib/mineru.test.tsindex 6a0c63d8..724e336c 100644--- a/src/lib/mineru.test.ts+++ b/src/lib/mineru.test.ts@@ -385,6 +385,31 @@ describe("parseWithMineru", () => {}})+ it.each([+ ["2.1.11", "hybrid-engine"],+ ["3.1.15", "hybrid-auto-engine"],+ ["3.4.4", "hybrid-engine"],+ ])("submits the backend name supported by MinerU %s", async (version, expectedBackend) => {+ mockHttpFetch+ .mockResolvedValueOnce(jsonResponse({ status: "healthy", version }))+ .mockResolvedValueOnce(jsonResponse({ task_id: "task-1" }, { status: 202 }))+ .mockResolvedValueOnce(jsonResponse({ status: "completed" }))+ .mockResolvedValueOnce(jsonResponse({+ results: { report: { md_content: "# Parsed locally" } },+ }))++ await expect(parseWithMineru({+ enabled: true,+ backend: "local",+ localBackend: "hybrid-engine",+ token: "",+ modelVersion: "vlm",+ }, "/tmp/report.pdf")).resolves.toBe("# Parsed locally")++ const form = mockHttpFetch.mock.calls[1]?.[1]?.body as FormData+ expect(form.get("backend")).toBe(expectedBackend)+ })+it("rejects oversized local-backend files before reading or uploading", async () => {fsMocks.getFileSize.mockResolvedValueOnce(__mineruTest.MAX_ACCURATE_PARSE_BYTES + 1)@@ -401,6 +426,7 @@ describe("parseWithMineru", () => {it("rejects an empty local-backend result instead of caching it as success", async () => {mockHttpFetch+ .mockResolvedValueOnce(jsonResponse({ status: "healthy", version: "3.1.15" })).mockResolvedValueOnce(jsonResponse({ task_id: "task-1" }, { status: 202 })).mockResolvedValueOnce(jsonResponse({ status: "completed" })).mockResolvedValueOnce(jsonResponse({ results: { doc: { md_content: " " } } }))@@ -415,6 +441,7 @@ describe("parseWithMineru", () => {it("saves and rewrites images returned by the official local API", async () => {mockHttpFetch+ .mockResolvedValueOnce(jsonResponse({ status: "healthy", version: "3.1.15" })).mockResolvedValueOnce(jsonResponse({ task_id: "task-1" }, { status: 202 })).mockResolvedValueOnce(jsonResponse({ status: "completed" })).mockResolvedValueOnce(jsonResponse({@@ -443,12 +470,13 @@ describe("parseWithMineru", () => {"/project/wiki/media/doc/mineru/images/image-1.png",btoa("image bytes"),)- const form = mockHttpFetch.mock.calls[0]?.[1]?.body as FormData+ const form = mockHttpFetch.mock.calls[1]?.[1]?.body as FormDataexpect(form.get("return_images")).toBe("true")})it("uses the data URI MIME type when the MinerU filename extension disagrees", async () => {mockHttpFetch+ .mockResolvedValueOnce(jsonResponse({ status: "healthy", version: "3.1.15" })).mockResolvedValueOnce(jsonResponse({ task_id: "task-1" }, { status: 202 })).mockResolvedValueOnce(jsonResponse({ status: "completed" })).mockResolvedValueOnce(jsonResponse({diff --git a/src/lib/mineru.ts b/src/lib/mineru.tsindex ded6fbcd..7776434d 100644--- a/src/lib/mineru.ts+++ b/src/lib/mineru.ts@@ -673,6 +673,23 @@ async function downloadAndExtractMarkdown(// ── Local backend ──+const MINERU_3_0_TO_3_2_BACKENDS: Partial<+ Record<NonNullable<MineruConfig["localBackend"]>, string>+> = {+ "vlm-engine": "vlm-auto-engine",+ "hybrid-engine": "hybrid-auto-engine",+}++function localMineruBackendForVersion(+ backend: NonNullable<MineruConfig["localBackend"]>,+ version: unknown,+): string {+ if (typeof version === "string" && /^3\.[0-2](?:\.|$)/.test(version.trim())) {+ return MINERU_3_0_TO_3_2_BACKENDS[backend] ?? backend+ }+ return backend+}+/*** Parse a document through the official `mineru-api` asynchronous protocol.* Files are submitted as multipart/form-data to `/tasks`; the task status and@@ -688,7 +705,8 @@ async function parseWithLocalMineru(): Promise<MineruExtractedMarkdown> {const httpFetch = await getHttpFetch()const apiBase = localMineruApiBase(config.localEndpoint)- if (config.localBackend?.endsWith("http-client") && !config.localServerUrl?.trim()) {+ const configuredBackend = config.localBackend || "hybrid-engine"+ if (configuredBackend.endsWith("http-client") && !config.localServerUrl?.trim()) {throw new Error("MinerU HTTP client backends require a model server URL")}const fileSize = await getFileSize(sourcePath)@@ -696,6 +714,22 @@ async function parseWithLocalMineru(throw new Error("MinerU accurate parsing supports files up to 200 MB")}throwIfAborted(signal)+ let serverVersion: unknown+ if (configuredBackend.endsWith("-engine")) {+ try {+ const healthRes = await httpFetch(+ `${apiBase}/health`,+ localMineruRequestInit(config.localToken, { signal }),+ )+ if (healthRes.ok) {+ const health = await healthRes.json() as { version?: unknown }+ serverVersion = health.version+ }+ } catch (err) {+ if (signal?.aborted) throw err+ }+ }+ const localBackend = localMineruBackendForVersion(configuredBackend, serverVersion)const { base64 } = await readFileAsBase64(sourcePath)const bytes = decodeBase64ToBytes(base64)const fileBuffer = bytes.buffer.slice(@@ -705,7 +739,7 @@ async function parseWithLocalMineru(const form = new FormData()form.append("files", new Blob([fileBuffer], { type: "application/pdf" }), fileName)form.append("lang_list", config.localLanguage || "ch")- form.append("backend", config.localBackend || "hybrid-engine")+ form.append("backend", localBackend)form.append("effort", config.localEffort || "medium")form.append("parse_method", config.localParseMethod || "auto")form.append("formula_enable", String(config.localFormulaEnabled !== false))