Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
refactor: add local models directory handling and update config version
myhlolia149a49cdec1
diff --git a/magic-pdf.template.json b/magic-pdf.template.jsonindex f61e7d12..9b9971db 100644--- a/magic-pdf.template.json+++ b/magic-pdf.template.json@@ -21,5 +21,9 @@"enable": false}},- "config_version": "1.2.2"+ "models-dir": {+ "pipeline": "",+ "vlm": ""+ },+ "config_version": "1.3.0"}\ No newline at end of filediff --git a/mineru/utils/config_reader.py b/mineru/utils/config_reader.pyindex b78acbaa..f80d92b9 100644--- a/mineru/utils/config_reader.py+++ b/mineru/utils/config_reader.py@@ -114,4 +114,12 @@ def get_llm_aided_config():logger.warning(f"'llm-aided-config' not found in {CONFIG_FILE_NAME}, use 'None' as default")return Noneelse:- return llm_aided_config\ No newline at end of file+ return llm_aided_config+++def get_local_models_dir():+ config = read_config()+ models_dir = config.get('models-dir')+ if models_dir is None:+ logger.warning(f"'models-dir' not found in {CONFIG_FILE_NAME}, use None as default")+ return models_dir\ No newline at end of filediff --git a/mineru/utils/models_download_utils.py b/mineru/utils/models_download_utils.pyindex b222a4f5..af0c9a1c 100644--- a/mineru/utils/models_download_utils.py+++ b/mineru/utils/models_download_utils.py@@ -2,6 +2,7 @@ import osfrom huggingface_hub import snapshot_download as hf_snapshot_downloadfrom modelscope import snapshot_download as ms_snapshot_download+from mineru.utils.config_reader import get_local_models_dirfrom mineru.utils.enum_class import ModelPathdef get_file_from_repos(relative_path: str, repo_mode='pipeline') -> str:@@ -15,6 +16,13 @@ def get_file_from_repos(relative_path: str, repo_mode='pipeline') -> str:"""model_source = os.getenv('MINERU_MODEL_SOURCE', None)+ if model_source == 'local':+ local_models_config = get_local_models_dir()+ root_path = local_models_config.get(repo_mode, None)+ if not root_path:+ raise ValueError(f"Local path for repo_mode '{repo_mode}' is not configured.")+ return os.path.join(root_path, relative_path.strip('/'))+# 建立仓库模式到路径的映射repo_mapping = {'pipeline': {