Skip to content

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

Open
sufubao wants to merge 1 commit into
ModelTC:mainfrom
sufubao:claude_code_support
Open

fix: harden Anthropic PDF and image content handling#1407
sufubao wants to merge 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。

验证:Anthropic 适配器测试 36/36 通过;Qwen3.5-27B 上使用 Claude Code 2.1.218 实测文本、Read 工具闭环和 PDF Read,/v1/messages 均返回 200。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.

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.

1 participant