Skip to content

fix(vlm): handle content_filter finish reason in API responses#3051

Merged
cau-git merged 4 commits intodocling-project:mainfrom
Br1an67:fix/issue-2988-vlm-content-filter
Mar 23, 2026
Merged

fix(vlm): handle content_filter finish reason in API responses#3051
cau-git merged 4 commits intodocling-project:mainfrom
Br1an67:fix/issue-2988-vlm-content-filter

Conversation

@Br1an67
Copy link
Contributor

@Br1an67 Br1an67 commented Mar 1, 2026

Issue resolved by this Pull Request:
Resolves #2988

Add CONTENT_FILTERED = "content_filter" to the VlmStopReason enum and detect finish_reason == "content_filter" in api_image_request(). This prevents silent drops when an API provider (e.g. Azure OpenAI) filters content due to safety policies.

Changes:

  • docling/datamodel/base_models.py: Add CONTENT_FILTERED enum value to VlmStopReason
  • docling/utils/api_image_request.py: Detect content_filter finish reason, log a warning, and return VlmStopReason.CONTENT_FILTERED
  • docling/pipeline/extraction_vlm_pipeline.py: Treat CONTENT_FILTERED as partial success (same as LENGTH and STOP_SEQUENCE)

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

DCO Check Passed

Thanks @Br1an67, all your commits are properly signed off. 🎉

@mergify
Copy link

mergify bot commented Mar 1, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@dosubot
Copy link

dosubot bot commented Mar 1, 2026

Related Documentation

Checked 20 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Member

@dolfim-ibm dolfim-ibm left a comment

Choose a reason for hiding this comment

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

Overall the idea of the PR looks ok, but I'm not sure about partial success (see prev comment)

@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Br1an67 Br1an67 force-pushed the fix/issue-2988-vlm-content-filter branch 3 times, most recently from f314776 to 40e7ff0 Compare March 7, 2026 02:34
@Br1an67
Copy link
Contributor Author

Br1an67 commented Mar 8, 2026

Hi — just a gentle bump on this. Happy to make any changes if needed!

@cau-git
Copy link
Member

cau-git commented Mar 10, 2026

@Br1an67 thanks, could you please address the DCO remediation? Instructions are posted above. Once this is done we can approve.

@cau-git
Copy link
Member

cau-git commented Mar 17, 2026

@Br1an67 only missing thing is your DCO remediation commit. It is mandated by the Linux Foundation that all contributors must sign off their commits. Could you please complete this? Then we can merge.

Br1an67 added 4 commits March 17, 2026 17:08
Add `CONTENT_FILTERED` to `VlmStopReason` enum and detect
`finish_reason == "content_filter"` in `api_image_request()`. This
prevents silent drops when an API provider (e.g. Azure OpenAI)
filters content, and logs a warning for downstream consumers.

Signed-off-by: Br1an67 <932039080@qq.com>
Add unit tests for the api_image_request function covering all finish
reason types: content_filter, length, and stop/end_of_sequence.

Signed-off-by: Br1an67 <932039080@qq.com>
- Convert Optional[X] to X | None for type annotations (UP045)
- Replace percent format with f-strings in tests (UP031)
- Prefix unused unpacked variables with underscore (RUF059)

This fixes the code-checks / lint (3.12) CI failure.

Signed-off-by: Br1an67 <932039080@qq.com>
@Br1an67 Br1an67 force-pushed the fix/issue-2988-vlm-content-filter branch from bc90e86 to aa85b9a Compare March 17, 2026 09:09
@cau-git cau-git self-requested a review March 23, 2026 08:32
@cau-git cau-git merged commit f0e3d1d into docling-project:main Mar 23, 2026
25 checks passed
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.

VLM fails silently when external API calls are content filtered.

3 participants