Skip to content

feat(doc-intel): expose model_id and analysis features on DocumentIntelligenceConverter (#2273) - #2284

Closed
Tai An (Anai-Guo) wants to merge 1 commit into
microsoft:mainfrom
Anai-Guo:docintel-model-and-features
Closed

Tai An (Anai-Guo) wants to merge 1 commit into
microsoft:mainfrom
Anai-Guo:docintel-model-and-features

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

Closes #2273.

Problem

DocumentIntelligenceConverter hardcodes both the analysis model and the add-on
feature set:

poller = self.doc_intel_client.begin_analyze_document(
    model_id="prebuilt-layout",
    ...
    features=self._analysis_features(stream_info),   # always FORMULAS + OCR_HIGH_RESOLUTION + STYLE_FONT
)

There is no constructor parameter for either, so a caller who only needs plain
text OCR has no way to ask for prebuilt-read or to drop the add-ons short of
bypassing MarkItDown and calling azure-ai-documentintelligence directly. As
#2273 notes, on Azure pay-as-you-go that is roughly a 10–19× cost difference
(~$1.50 vs ~$16–28 per 1,000 pages).

Change

Two new keyword-only parameters on DocumentIntelligenceConverter, plumbed
through MarkItDown(...) following the existing docintel_* kwargs pattern:

parameter MarkItDown kwarg default meaning
model_id: str docintel_model_id "prebuilt-layout" model passed to begin_analyze_document
features: List[str] | None docintel_features None None keeps today's add-on set; [] disables all add-ons
md = MarkItDown(
    docintel_endpoint=...,
    docintel_model_id="prebuilt-read",
    docintel_features=[],
)

The defaults are the current values, so existing callers send byte-identical
requests. This exposes the choice rather than changing it, as the issue asks.

Two behaviours are deliberately preserved:

  • Office types still get no add-ons. The .docx/.pptx/.xlsx/.html early
    return runs before the new branch, because the service does not accept add-ons
    for those types — an explicit features=[...] cannot re-introduce a request
    the API would reject.
  • The caller's list is copied, not aliased into the request.

Tests

New packages/markitdown/tests/test_docintel_options.py (8 tests), built with
the same __new__ no-Azure-client pattern as the existing
test_docintel_html.py.

Run against the released package with the patch applied and removed:

# unpatched: the two tests that assert the new behaviour fail, the
# "defaults unchanged" guards pass
2 failed, 6 passed

# patched
8 passed

test_docintel_html.py still passes (2 passed), and black==23.7.0 (the pinned
pre-commit version) reports all three touched files unchanged.

Plumbing verified end to end:

custom  model_id = prebuilt-read   | features = []
default model_id = prebuilt-layout | features = ['formulas', 'ocrHighResolution', 'styleFont']

🤖 Generated with Claude Code

…elligenceConverter (microsoft#2273)

DocumentIntelligenceConverter hardcoded model_id="prebuilt-layout" and an
unconditional FORMULAS + OCR_HIGH_RESOLUTION + STYLE_FONT add-on set for every
OCR-eligible input, with no way to select a cheaper analysis through the public
API. Per Azure pay-as-you-go pricing that is roughly 10-19x the cost of
prebuilt-read with no add-ons.

Add two keyword-only parameters, plumbed through MarkItDown as
docintel_model_id / docintel_features:

- model_id: str = "prebuilt-layout"
- features: List[str] | None = None  (None keeps the current add-on set,
  [] disables all add-ons)

Defaults are unchanged, so existing callers get identical requests. Add-ons are
still never sent for office file types, which the service does not support them
for, and the caller's list is copied rather than aliased into the request.
@chienyuanchang

Copy link
Copy Markdown
Member

Thanks, Tai An (@Anai-Guo), for opening this PR and contributing the configurable model ID and analysis-feature design and tests. #1913 has now merged and incorporates that work, along with query fields, structured output, and CLI support. Your contribution is credited in the merged PR. Closing this PR as superseded by #1913.

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.

Title: Expose model_id and analysis features as configurable parameters in DocumentIntelligenceConverter

2 participants