File size: 1,114 Bytes
2d0768b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb8bc0e
 
 
2d0768b
 
23a1da7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import json
from loguru import logger

if __name__ == '__main__':
    os.system('pip uninstall -y mineru')
    os.system('pip install git+https://github.com/myhloli/Magic-PDF.git@dev')
    os.system('mineru-models-download -s huggingface -m vlm')
    try:
        with open('/home/user/mineru.json', 'r+') as file:
            config = json.load(file)
            
            delimiters = {
                'display': {'left': '\\[', 'right': '\\]'},
                'inline': {'left': '\\(', 'right': '\\)'}
            }
            
            config['latex-delimiter-config'] = delimiters
            
            if os.getenv('apikey'):
                config['llm-aided-config']['title_aided']['api_key'] = os.getenv('apikey')
                config['llm-aided-config']['title_aided']['enable'] = True
            
            file.seek(0)
            file.truncate()
            json.dump(config, file, indent=4)
    except Exception as e:
        logger.exception(e)
    os.system('mineru-gradio --enable-sglang-engine false --enable-api false --max-convert-pages 10 --latex-delimiters-type b')