opendatalab/MinerU · error · ValueError

Invalid latex delimiters type: {latex_delimiters_type}.

Error message

Invalid latex delimiters type: {latex_delimiters_type}.

What it means

ValueError raised in mineru/cli/gradio_app.py when building the Gradio app: the latex_delimiters_type parameter must be exactly 'a', 'b', or 'all' (selecting among latex_delimiters_type_a/b/all presets that control how inline/display math is delimited in output markdown). Any other string — including 'A', 'none', 'default' — hits the else branch. Because it is raised during app construction, it kills the Gradio server at startup, not at request time.

Source

Thrown at mineru/cli/gradio_app.py:1784

        return build_interface_updates(backend_choice, effort_choice)

    del kwargs
    _gradio_local_api_server.configure(
        resolve_gradio_local_api_cli_args(
            ctx.args,
            api_url=api_url,
            enable_vlm_preload=enable_vlm_preload,
        )
    )

    if latex_delimiters_type == 'a':
        latex_delimiters = latex_delimiters_type_a
    elif latex_delimiters_type == 'b':
        latex_delimiters = latex_delimiters_type_b
    elif latex_delimiters_type == 'all':
        latex_delimiters = latex_delimiters_type_all
    else:
        raise ValueError(f"Invalid latex delimiters type: {latex_delimiters_type}.")


    async def convert_to_markdown_stream(
        file_path,
        end_pages=10,
        is_ocr=False,
        formula_enable=True,
        table_enable=True,
        image_analysis=True,
        effort=DEFAULT_HYBRID_EFFORT,
        language="ch",
        backend="pipeline",
        url=None,
        request: gr.Request = None,
    ):
        request_locale = resolve_request_locale(request)
        async for update in stream_to_markdown(
            file_path=file_path,

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Set latex_delimiters_type to one of 'a', 'b', or 'all' (case-sensitive, lowercase).
  2. If you do not care about delimiter style, omit the parameter if it has a default in your version.
  3. Check the latex_delimiters_type_a/b/all definitions near the top of gradio_app.py to see which preset each maps to and pick deliberately.
  4. Pin your mineru version so the accepted enum does not shift under you.

Example fix

# before
app = build_app(latex_delimiters_type='default')  # ValueError

# after
app = build_app(latex_delimiters_type='all')  # or 'a' / 'b'
Defensive patterns

Strategy: type-guard

Validate before calling

VALID_LATEX = {'a', 'b', 'all'}
if latex_delimiters_type not in VALID_LATEX:
    raise ValueError(f'latex_delimiters_type must be one of {VALID_LATEX}')

Type guard

def is_valid_latex_delimiters_type(v: str) -> bool:
    return isinstance(v, str) and v in {'a', 'b', 'all'}

Prevention

When it happens

Trigger: Programmatically instantiating the Gradio app (building the demo object) with latex_delimiters_type='default' or another unsupported value; copying example code from an older/newer mineru version whose accepted values differ; passing a UI dropdown value that was customized.

Common situations: Embedding the mineru Gradio app in another tool and guessing parameter names/values; version drift changing the accepted enum; scripts importing the build function directly instead of using the CLI.

Related errors


AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14). Data as JSON: /api/errors/cab5a0a7678c9911. Report an issue: GitHub.