feat(cli): add --document-dpi and --document-max-pages to vlmrun gw chat - #204
feat(cli): add --document-dpi and --document-max-pages to vlmrun gw chat#204spillai wants to merge 1 commit into
vlmrun gw chat#204Conversation
…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
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
| 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).", |
There was a problem hiding this comment.
🟡 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.
| 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).", | |
| ), |
Was this helpful? React with 👍 or 👎 to provide feedback.
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 is72;150is 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 default500).Both parameters are gateway-specific, so — like
--method— they ride in the request body viaextra_bodyrather than as OpenAIcreate()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
Changes
vlmrun/cli/_cli/gateway.py— two new options on thechatcommand, routed intoextra_body; help text (examples + notes) and module docstring updated.tests/test_gateway.py— new tests: each flag reachesextra_body, the-dshort flag, and correct merging with--methodand-eextras.Testing
pytest tests/test_gateway.py— 97 passed.ruff+blackclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01RHvcT3Zc2SJB8ZvB8s8Y7E