Skip to content

fix: harden Anthropic PDF and image content handling - #1407

Merged
shihaobai merged 1 commit into
ModelTC:mainfrom
sufubao:claude_code_support
Jul 28, 2026
Merged

fix: harden Anthropic PDF and image content handling#1407
shihaobai merged 1 commit into
ModelTC:mainfrom
sufubao:claude_code_support

Conversation

@sufubao

@sufubao sufubao commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Claude Code 的 Read 工具会在 tool_result 中返回图片或 PDF。LightLLM 的 Anthropic 适配层原先会丢失部分图片结构,也不能处理 PDF。

本 PR 恢复 tool_result 图片,并在显式开启 LIGHTLLM_ANTHROPIC_ENABLE_PDF_PARSING 后解析 base64 PDF:视觉模型转为 PNG 页面,文本模型使用 pdftotext;同时限制文档数、输入/输出大小、页数和处理时间,并明确拒绝 URL PDF。Docker 镜像显式安装 poppler-utils,提供 pdftotext、pdftoppm 和 pdfinfo。

验证:Anthropic 适配器测试 36/36 通过;Qwen3.5-27B 上使用 Claude Code 2.1.218 实测文本、Read 工具闭环和 PDF Read,/v1/messages 均返回 200。Dockerfile check、Black 和 git diff --check 通过。

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sufubao
sufubao force-pushed the claude_code_support branch from ce0254e to c579a47 Compare July 28, 2026 09:00
@shihaobai
shihaobai merged commit 50abda6 into ModelTC:main Jul 28, 2026
1 check 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.

2 participants