fix: harden Anthropic PDF and image content handling - #1407
Open
sufubao wants to merge 1 commit into
Open
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Claude Code 的 Read 工具会在 tool_result 中返回图片或 PDF。LightLLM 的 Anthropic 适配层原先会丢失部分图片结构,也不能处理 PDF。
本 PR 恢复 tool_result 图片,并在显式开启 LIGHTLLM_ANTHROPIC_ENABLE_PDF_PARSING 后解析 base64 PDF:视觉模型转为 PNG 页面,文本模型使用 pdftotext;同时限制文档数、输入/输出大小、页数和处理时间,并明确拒绝 URL PDF。
验证:Anthropic 适配器测试 36/36 通过;Qwen3.5-27B 上使用 Claude Code 2.1.218 实测文本、Read 工具闭环和 PDF Read,/v1/messages 均返回 200。Black 和 git diff --check 通过。