|
22 | 22 | # except Exception: |
23 | 23 | # pass |
24 | 24 |
|
25 | | -def _maybe_init_sglang_engine_in_main() -> None: |
26 | | - """Initialize sglang engine in the main process if requested via env. |
| 25 | +def _maybe_init_engine_in_main() -> None: |
| 26 | + """Initialize VLM engine in the main process if requested via env. |
27 | 27 |
|
28 | 28 | Per MinerU guidance, sglang-engine must be initialized in the main process. |
29 | 29 | This avoids scheduler failures when workers spawn without prior initialization. |
30 | 30 | """ |
31 | 31 | backend_env = os.getenv("MINERU_BACKEND", "pipeline").lower() |
32 | | - if backend_env == "vlm-sglang-engine": |
33 | | - try: |
34 | | - from mineru.backend.vlm.vlm_analyze import ModelSingleton |
35 | | - # Initialize once; ModelSingleton handles idempotency |
36 | | - ModelSingleton().get_model("sglang-engine", None, None) |
37 | | - except Exception: |
38 | | - # Defer detailed errors to runtime path to avoid import-time crashes |
39 | | - pass |
| 32 | + from mineru.backend.vlm.vlm_analyze import ModelSingleton |
| 33 | + |
| 34 | + |
| 35 | + try: |
| 36 | + |
| 37 | + if backend_env == "vlm-vllm-async-engine": |
| 38 | + ModelSingleton().get_model("vllm-async-engine", None, None) |
| 39 | + except Exception: |
| 40 | + # Defer detailed errors to runtime path to avoid import-time crashes |
| 41 | + pass |
40 | 42 |
|
41 | | -_maybe_init_sglang_engine_in_main() |
| 43 | +_maybe_init_engine_in_main() |
42 | 44 |
|
43 | 45 | class TimeoutError(Exception): |
44 | 46 | pass |
@@ -184,7 +186,7 @@ async def convert_to_markdown_dispatch(pdf_bytes, filename=None, **kwargs): |
184 | 186 | Prefer using aio_do_parse to match official MinerU entrypoints. |
185 | 187 | """ |
186 | 188 | backend_env = os.getenv("MINERU_BACKEND", "pipeline").lower() |
187 | | - server_url = os.getenv("MINERU_SGLANG_SERVER_URL") |
| 189 | + server_url = os.getenv("MINERU_VLM_SERVER_URL") or os.getenv("MINERU_SGLANG_SERVER_URL") |
188 | 190 | lang = kwargs.get("lang", "en") |
189 | 191 | parse_method = kwargs.get("parse_method", "auto") |
190 | 192 | formula_enable = kwargs.get("formula_enable", True) |
|
0 commit comments