DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
merge: integrate recent issue fixes
Bingxi Zhao (Frank)5228af91414f
diff --cc docs/plans/2026-08-30-mineru-multiformat-integration-design.mdindex 000000000,3538368a1..dd20c4cb8mode 000000,100644..100644--- a/docs/plans/2026-08-30-mineru-multiformat-integration-design.md+++ b/docs/plans/2026-08-30-mineru-multiformat-integration-design.md@@@ -1,0 -1,85 +1,84 @@@+ # MinerU multi-format integration design++ ## Context++ Issue #1087 correctly points out that current DeepTutor documentation and the+ `MinerUParser` adapter expose PDF only, while current MinerU supports PDF,+ images, DOCX, PPTX, and XLSX. Merely updating the docs would leave Office files+ blocked by the parser adapter and standalone images routed around the parser in+ two of the three knowledge-base pipelines.++ ## Goals++ - Expose the exact current MinerU local input set: PDF, PNG, JPEG/JPG, JP2,+ WEBP, GIF, BMP, TIFF, DOCX, PPTX, and XLSX.+ - Make those inputs work through the shared `ParseService` in local CLI and+ mineru.net cloud modes.+ - Route standalone images through MinerU when MinerU is active, so OCR and+ structured content are available consistently to LightRAG, GraphRAG, and+ LlamaIndex.+ - Preserve existing public PDF entry points and exam-paper behavior.+ - Fail clearly when the detected legacy `magic-pdf` command is asked to parse+ anything other than PDF.++ ## Non-goals++ - Supporting legacy DOC/PPT/XLS inputs that the current local `mineru` CLI+ does not advertise.+ - Changing the PDF-only question/exam upload contract.+ - Replacing image-native multimodal ingestion when a non-image-capable parser+ is active.+ - Adding MinerU as an in-process Python dependency; the supported deployment+ boundaries remain the external CLI and the hosted cloud API.++ ## Design++ The MinerU engine owns a canonical immutable format set. Its generic adapter+ calls a new document-named backend function. The existing+ `parse_pdf_to_workdir` and `parse_pdf_with_mineru` functions remain as wrappers+ for compatibility with imports, tests, and the exam-paper flow.++ The local runner passes every supported source to the modern `mineru -p ...+ -o ...` contract unchanged. If auto-detection selects `magic-pdf`, or an+ explicit configured executable is named `magic-pdf`, non-PDF input is rejected+ before spawning the subprocess with an actionable upgrade message. Output is+ still normalized into `<output>/<source stem>` so the cache loader remains+ format-agnostic.++ The cloud client keeps the same mineru.net v4 batch-upload protocol while+ generalizing source names and errors. It sends the original filename, which is+ how the service determines the file type, and continues to upload unsigned raw+ bytes without a Content-Type header as required by the signed URL.++ `ParseService.supports(source, engine=...)` supplies one shared capability+ check. GraphRAG routes supported images into document parsing instead of+ skipping them. LlamaIndex parses supported images first and uses the resulting+ text/assets; when the active engine does not support images, its existing+ direct multimodal image-node path is unchanged. LightRAG already calls+ `ParseService` for every staged source and needs no routing change.++ Static settings copy and documentation are updated to describe the real+ format set. Runtime readiness remains separate from format support.++ ## Error handling and compatibility++ - Unsupported suffixes still fail in `ParseService` before readiness checks.+ - Legacy `magic-pdf` receives PDFs exactly as before and never receives a new+ input type it cannot handle.+ - Existing PDF-named functions are retained and delegate to the generic+ implementation.+ - Cache keys remain byte- and parser-signature-based; no migration is needed.+ - A parsed image with no textual or structured output is treated as an empty+ parse, matching existing document semantics.++ ## Verification++ - Unit-test the advertised extension set.+ - Exercise generic local parsing with an Office input and assert the exact CLI+ argv and normalized output.+ - Assert legacy `magic-pdf` rejects non-PDF without spawning a process.+ - Exercise cloud submission with a non-PDF filename and archive loading.+ - Test GraphRAG and LlamaIndex image routing for both image-capable and+ image-incapable active parsers.+ - Re-run the existing MinerU, parsing, and RAG suites, followed by repository+ Python and web quality gates.-diff --cc web/context/UnifiedChatContext.tsxindex b0eba6c8c,5784d1a2a..a85af84f1--- a/web/context/UnifiedChatContext.tsx+++ b/web/context/UnifiedChatContext.tsx@@@ -1750,6 -1726,9 +1761,10 @@@ export function UnifiedChatProvider(const effectiveQuestionNotebookReferences =replaySnapshot?.questionNotebookReferences ??questionNotebookReferences;- const liveReadingFields = readingTurnFields(effectiveCapability);++ const liveReadingFields = readingTurnFields(effectiveWorkspaceMode);+ const effectiveReadingMaterialId =- replaySnapshot?.readingMaterialId ?? liveReadingFields.reading_material_id;++ replaySnapshot?.readingMaterialId ??++ liveReadingFields.reading_material_id;const requestSnapshot: MessageRequestSnapshot = replaySnapshot ?? {content,capability: effectiveCapability,@@@ -1854,12 -1834,14 +1872,14 @@@...(effectiveMasteryPathId? { mastery_path_id: effectiveMasteryPathId }: {}),- // Immersive reading. Gated on the capability as well as on an open- // document: the reader outlives both a mode switch and a new session, so- // without the capability check every later turn would still carry it.+ // Immersive reading. Gated on the stable workspace mode as well as on+ // an open document: the reader outlives action switches and new+ // sessions, so Home must never inherit its source context.// Read from a module cell rather than context state so scrolling the// reader never re-renders the chat.- ...readingTurnFields(effectiveWorkspaceMode),- ...(effectiveReadingMaterialId- ? { reading_material_id: effectiveReadingMaterialId }++ ...(replaySnapshot?.readingMaterialId++ ? { reading_material_id: replaySnapshot.readingMaterialId }+ : liveReadingFields),// Always sent (possibly ""): an explicit key is the backend's signal// to persist the value into session.preferences — "" clears back to// Default. Omitting the key would make the backend fall back to thediff --cc web/tests/reading-turn-state.test.tsindex 606c87bc7,fdefb093e..defadb7e2--- a/web/tests/reading-turn-state.test.ts+++ b/web/tests/reading-turn-state.test.ts@@@ -1,8 -1,9 +1,9 @@@import test from "node:test";import assert from "node:assert/strict";import {- READING_CAPABILITY,+ READING_WORKSPACE_MODE,getReadingTurnState,+ normalizeReadingMaterialId,readingTurnFields,resetReadingTurnState,setReadingMaterial,@@@ -12,7 -13,17 +13,17 @@@test.beforeEach(() => resetReadingTurnState());+ test("normalizes persisted reading material ids and rejects unsafe values", () => {+ assert.equal(+ normalizeReadingMaterialId(" 0123456789ABCDEF "),+ "0123456789abcdef",+ );+ assert.equal(normalizeReadingMaterialId("../../etc/passwd"), null);+ assert.equal(normalizeReadingMaterialId("0123"), null);+ assert.equal(normalizeReadingMaterialId(null), null);+ });+-test("carries the document and viewport on a reading turn", () => {+test("carries the document and viewport for every action inside reading", () => {setReadingMaterial("d138eacaad029843");setReadingViewport({ locator: 3, selection: "attention" });