feat(doc-intel): expose model_id and analysis features on DocumentIntelligenceConverter (#2273) - #2284
Open
Tai An (Anai-Guo) wants to merge 1 commit into
Open
Conversation
…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.
|
Tai An (@Anai-Guo) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2273.
Problem
DocumentIntelligenceConverterhardcodes both the analysis model and the add-onfeature set:
There is no constructor parameter for either, so a caller who only needs plain
text OCR has no way to ask for
prebuilt-reador to drop the add-ons short ofbypassing MarkItDown and calling
azure-ai-documentintelligencedirectly. 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, plumbedthrough
MarkItDown(...)following the existingdocintel_*kwargs pattern:MarkItDownkwargmodel_id: strdocintel_model_id"prebuilt-layout"begin_analyze_documentfeatures: List[str] | Nonedocintel_featuresNoneNonekeeps today's add-on set;[]disables all add-onsThe 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:
.docx/.pptx/.xlsx/.htmlearlyreturn runs before the new branch, because the service does not accept add-ons
for those types — an explicit
features=[...]cannot re-introduce a requestthe API would reject.
Tests
New
packages/markitdown/tests/test_docintel_options.py(8 tests), built withthe same
__new__no-Azure-client pattern as the existingtest_docintel_html.py.Run against the released package with the patch applied and removed:
test_docintel_html.pystill passes (2 passed), andblack==23.7.0(the pinnedpre-commit version) reports all three touched files unchanged.
Plumbing verified end to end:
🤖 Generated with Claude Code