Skip to content

feat(cli): add --document-dpi and --document-max-pages to vlmrun gw chat - #204

Closed
spillai wants to merge 1 commit into
mainfrom
feat/gateway-document-dpi
Closed

feat(cli): add --document-dpi and --document-max-pages to vlmrun gw chat#204
spillai wants to merge 1 commit into
mainfrom
feat/gateway-document-dpi

Conversation

@spillai

@spillai spillai commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Expose the gateway's PDF rasterization controls as first-class flags on vlmrun gw chat, so callers don't have to reach for -e key=value:

  • --document-dpi / -d — rasterization DPI per PDF page. Gateway default is 72; 150 is a good balance for denser pages, 300+ preserves fine print on high-resolution pages at higher inference cost.
  • --document-max-pages — cap the number of PDF pages processed (gateway default 500).

Both parameters are gateway-specific, so — like --method — they ride in the request body via extra_body rather than as OpenAI create() kwargs. PDFs are already sent whole (the gateway rasterizes and fans them out per page), so no change was needed to input handling.

Reference: https://docs.vlm.run/gateway

Example

vlmrun gw chat doc.pdf -m paddleocr/pp-ocrv6 --document-dpi 150
vlmrun gw chat doc.pdf -m paddleocr/pp-ocrv6 --document-dpi 300 --document-max-pages 50

Changes

  • vlmrun/cli/_cli/gateway.py — two new options on the chat command, routed into extra_body; help text (examples + notes) and module docstring updated.
  • tests/test_gateway.py — new tests: each flag reaches extra_body, the -d short flag, and correct merging with --method and -e extras.

Testing

  • pytest tests/test_gateway.py — 97 passed.
  • ruff + black clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RHvcT3Zc2SJB8ZvB8s8Y7E


Open in Devin Review

…chat`

Expose the gateway's PDF rasterization controls as first-class flags on the
chat command:

- `--document-dpi` / `-d`: rasterization DPI per page (gateway default 72;
  150 is a good balance, 300+ preserves fine print on dense/high-res pages).
- `--document-max-pages`: cap the number of PDF pages processed.

Both are gateway-specific, so they ride in the request body alongside `method`
(via extra_body) rather than as OpenAI create() kwargs. Includes help text and
module docstring updates, plus tests covering the new flags and their merge
with `--method` and `-e` extras.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RHvcT3Zc2SJB8ZvB8s8Y7E
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment on lines +573 to +586
document_dpi: Optional[int] = typer.Option(
None,
"--document-dpi",
"-d",
help=(
"Rasterization DPI per PDF page (gateway default 72; 150 is a good "
"balance; 300+ preserves fine print on dense/high-res pages at "
"higher cost). PDF input only."
),
),
document_max_pages: Optional[int] = typer.Option(
None,
"--document-max-pages",
help="Cap the number of PDF pages processed (gateway default 500).",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 New command options use outdated type-hint style disallowed by repo guidelines

The two new options are annotated with Optional[int] (vlmrun/cli/_cli/gateway.py:573 and vlmrun/cli/_cli/gateway.py:583), but the repository's mandatory style guide requires the modern int | None union syntax for all new code.
Impact: The new code does not follow the repository's required modern Python type-hint style.

Rule reference in AGENTS.md

AGENTS.md, section "Modern Python Style", states: "Use X | None instead of Optional[X] for type hints (PEP 604)." The newly added parameters document_dpi and document_max_pages use Optional[int] instead of int | None. Note the surrounding file already uses Optional throughout, so this is a pre-existing convention in the module, but the rule explicitly applies to new code.

Suggested change
document_dpi: Optional[int] = typer.Option(
None,
"--document-dpi",
"-d",
help=(
"Rasterization DPI per PDF page (gateway default 72; 150 is a good "
"balance; 300+ preserves fine print on dense/high-res pages at "
"higher cost). PDF input only."
),
),
document_max_pages: Optional[int] = typer.Option(
None,
"--document-max-pages",
help="Cap the number of PDF pages processed (gateway default 500).",
document_dpi: int | None = typer.Option(
None,
"--document-dpi",
"-d",
help=(
"Rasterization DPI per PDF page (gateway default 72; 150 is a good "
"balance; 300+ preserves fine print on dense/high-res pages at "
"higher cost). PDF input only."
),
),
document_max_pages: int | None = typer.Option(
None,
"--document-max-pages",
help="Cap the number of PDF pages processed (gateway default 500).",
),
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@spillai spillai closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant