fix: omit description heading for custom image prompts - #2263
Open
VictorMaxWang wants to merge 1 commit into
Open
fix: omit description heading for custom image prompts#2263VictorMaxWang wants to merge 1 commit into
VictorMaxWang wants to merge 1 commit into
Conversation
Only emit the default English heading when the converter also uses its default prompt.
|
@VictorMaxWang 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.
Summary
# Description:heading.llm_promptisNone, empty, or whitespace-only.Reproduction / root cause
ImageConvertercorrectly passedllm_promptto the LLM client, but then unconditionally prepended# Description:to the returned caption. As a result, callers requesting localized or heading-free output still received an English heading.The regression test uses the repository's existing
test_llm.jpgand aMagicMockclient, so it exercises the publicMarkItDown.convert()path without credentials or network access.Changes
llm_promptwhen generating the image description.None, empty, whitespace-only, and non-empty custom prompts with a parameterized regression test.Tests
hatch test tests/test_module_misc.py -k 'test_markitdown_llm_prompt_controls_default_heading or test_markitdown_llm_parameters' -vv: passed (5 passed, 14 deselected).MarkItDown.convert()probe withtest_llm.jpgand a mocked client: passed; custom output was\nBeschreibung auf Deutsch.\n, while default output remained\n# Description:\nDefault caption.\n.$testEnv = hatch env find hatch-test.py3.13; $env:PYTHONPATH = (Resolve-Path 'src').Path + ';' + (Join-Path $testEnv 'Lib\site-packages'); $env:GITHUB_ACTIONS = 'true'; $env:PYTHONUTF8 = '1'; hatch test:309 passed, 34 skipped, 1 failed. The remaining failure is the existing Windows-onlytest_file_urisPOSIX-path assertion (/path/to/file.txtvsD:\path\to\file.txt); this PR does not modify URI handling.pre-commit run --all-files: passed.Security / compatibility considerations
Fixes #315