document-granular-decompose
Skill11 starsChanged 3 months agoMITView on GitHub
Upload local documents to TianGong AI Unstructure `/mineru_with_images` API for fine-grained parsing and return only plain fulltext content. Use when a task needs document fulltext extraction with `return_txt=true`, strict file-type allowlist validation, API base URL/auth token from environment variables, and optional provider/model overrides.
- Reads credentials
In this repository62 other files it gives its agents.
- AGENTS.mdAGENTS.md
- academic-paper-downloadSkill
- airnow-hourly-obs-fetchSkill
- ai-tech-fulltext-fetchSkill
- ai-tech-rss-fetchSkill
- ai-tech-summarySkill
- apply-environmental-thinkingSkill
- bluesky-cascade-fetchSkill
- convert-image-to-jpgSkill
- dify-knowledge-base-searchSkill
- dify-knowledge-base-uploadSkill
- domain-onboardingSkill
- eceee-news-fulltext-fetchSkill
- email-imap-appendSkill
- email-imap-fetchSkill
- email-imap-full-fetchSkill
- email-smtp-sendSkill
- epa-eis-records-fetchSkill
- federal-register-doc-fetchSkill
- fetch-abstract-to-kbSkill
- fetch-meta-from-kbSkill
- fetch-meta-to-kbSkill
- figshare-data-downloadSkill
- gdelt-doc-searchSkill
- gdelt-events-fetchSkill
- gdelt-gkg-fetchSkill
- gdelt-mentions-fetchSkill
- gdelt-web-ngrams-searchSkill
- github-contribution-period-analysisSkill
- nasa-firms-fire-fetchSkill
- notebooklmSkill
- openaq-data-fetchSkill
- open-meteo-air-quality-fetchSkill
- open-meteo-flood-fetchSkill
- open-meteo-historical-fetchSkill
- regulationsgov-attachments-fetchSkill
- regulationsgov-comment-detail-fetchSkill
- regulationsgov-comments-fetchSkill
- remove-similar-imageSkill
- river-outfall-status-visualizerSkill
- sustainability-fulltext-fetchSkill
- sustainability-rss-fetchSkill
- sustainability-summarySkill
- synology-file-stationSkill
- tiangong-auto-researchSkill
- tiangong-auto-research-workbuddySkill
- tiangong-kb-course-fulltext-fetchSkill
- tiangong-kb-course-searchSkill
- tiangong-kb-edu-searchSkill
- tiangong-kb-esg-searchSkill
- tiangong-kb-ingestSkill
- tiangong-kb-patent-searchSkill
- tiangong-kb-report-searchSkill
- tiangong-kb-sci-searchSkill
- tiangong-kb-textbook-searchSkill
- tsinghua-graduate-thesisSkill
- usbr-project-records-fetchSkill
- usbr-rise-fetchSkill
- use-thuenv-presentation-styleSkill
- usgs-water-iv-fetchSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Read environment variables for endpoint, request identity, and model routing:
- Distinctive: line 34
Run extraction and print fulltext to stdout.
- Distinctive: line 78
Do not output chunk metadata/json unless the user explicitly requests debugging.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Document Granular Decompose
Core Goal
- Parse a local document through
POST /mineru_with_images. - Always force
return_txt=true. - Read environment variables for endpoint, request identity, and model routing:
UNSTRUCTURED_API_BASE_URL(example:https://your-unstructured-host:7770)UNSTRUCTURED_AUTH_TOKENUNSTRUCTURED_PROVIDER(optional)UNSTRUCTURED_MODEL(optional)
- Return only plain fulltext (prefer API
txt; fallback to joinedresult[].text).
Triggering Conditions
- Need robust document fulltext extraction for PDF/Office/image files.
- Need image-aware MinerU parsing but only textual output for downstream chunking/search/summarization.
- Need to standardize provider/model/token input via environment variables instead of ad-hoc command parameters.
Workflow
- Prepare environment variables.
export UNSTRUCTURED_AUTH_TOKEN="your-fastapi-bearer-token"
export UNSTRUCTURED_API_BASE_URL="https://your-unstructured-host:7770"
# Optional routing overrides. Omit them to let the server choose its defaults.
export UNSTRUCTURED_PROVIDER="vllm"
export UNSTRUCTURED_MODEL="Qwen/Qwen3.5-122B-A10B-FP8"- Run extraction and print fulltext to stdout.
python3 scripts/mineru_fulltext_extract.py \
--file "/absolute/path/to/document.pdf"- Save fulltext to a local file when needed.
python3 scripts/mineru_fulltext_extract.py \
--file "/absolute/path/to/document.pdf" \
--output "/absolute/path/to/fulltext.txt"Request Contract
- Endpoint resolution:
--api-urlif provided- else
UNSTRUCTURED_API_BASE_URL + /mineru_with_images - else fail fast with missing environment variable error
- Method:
POSTmultipart form. - Query params:
- Force
return_txt=true(always set by script).
- Force
- Form fields sent:
file(required)provider(optional, fromUNSTRUCTURED_PROVIDERwhen set)model(optional, fromUNSTRUCTURED_MODELwhen set)
- Header sent:
Authorization: Bearer $UNSTRUCTURED_AUTH_TOKEN
Supported File Types (Strict)
- Supported file types:
.bmp, .doc, .docm, .docx, .dot, .dotx, .gif, .jp2, .jpeg, .jpg, .odp, .odt, .pdf, .png, .pot, .potx, .pps, .ppsx, .ppt, .pptm, .pptx, .tiff, .webp, .xls, .xlsm, .xlsx, .xlt, .xltx
- Office formats:
.doc, .docm, .docx, .dot, .dotx, .odp, .odt, .pot, .potx, .pps, .ppsx, .ppt, .pptm, .pptx, .xls, .xlsm, .xlsx, .xlt, .xltx
- Any other extension is rejected before sending API requests.
Output Rules
- Success output must be plain text fulltext only.
- Normalize the confirmed upstream Markdown underscore escape (
\_to_) in both supported response paths; preserve other backslashes and escapes. - Fulltext source priority:
response.txt- join non-empty
response.result[].textby blank lines
- Do not output chunk metadata/json unless the user explicitly requests debugging.
Error Handling
- Missing required env vars (
UNSTRUCTURED_API_BASE_URL,UNSTRUCTURED_AUTH_TOKEN): fail fast with actionable message. - Missing
UNSTRUCTURED_PROVIDERorUNSTRUCTURED_MODEL: omit the form field and let the service choose its default. - HTTP 401/403: report token/auth issue.
- HTTP 4xx/5xx: print status and API error body if available.
- Missing text in response: fail with explicit schema mismatch error.
References
references/env.mdreferences/request-response.md
Assets
assets/config.example.env
Scripts
scripts/mineru_fulltext_extract.py
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

