Skip to content

feat(hosted): let callers choose the Parse mode - #199

Open
erikengervall wants to merge 2 commits into
mainfrom
parse-mode-option
Open

erikengervall wants to merge 2 commits into
mainfrom
parse-mode-option

Conversation

@erikengervall

@erikengervall erikengervall commented Oct 20, 2026 •

Copy link
Copy Markdown

Hosted OCR always asks Parse for mode: 'auto', so a caller who knows the document is scanned cannot force OCR, and one who wants text-only extraction cannot ask for fast.

Node takes parseMode: 'auto' | 'fast' | 'ocr', Python parse_mode (exported as ParseMode), the CLI --parse-mode. The default stays auto, so the request body is unchanged for existing callers. The value is checked when the call starts, before any conversion or request: a bad one rejects with code: 'hosted' in Node and raises HostedError in Python, and the CLI exits 2 like other usage errors.

The Rust crate and the Wasm binding never call Parse, so they are untouched.

Tests against the local /v2/parse stub now also read the options each request sent: the default is auto, a custom mode is sent as given, an invalid mode raises with no request made.


Summary by cubic

Lets hosted OCR callers choose the Parse PDF mode instead of always sending auto.

Node takes parseMode, Python takes parse_mode (exported as ParseMode), and the CLI takes --parse-mode, each accepting 'auto', 'fast', or 'ocr'. The default stays auto, so existing callers see no change in the request body. Invalid values are rejected before any conversion or request, even when the document would convert locally: in Node with code: 'hosted', in Python with HostedError, and in the CLI with exit code 2.

The Rust crate and Wasm binding never call Parse, so they are untouched.

Written for commit 139087f. Summary will update on new commits.

View guided diff Turn on auto-fix

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread python/tests/test_anydoc.py Outdated

This branch has not been deployed

No deployments
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