Skip to content

fix: enable PDF upload support for Web UI agents#582

Merged
yaozheng-fang merged 1 commit into
volcengine:mainfrom
FirstayZheng:fix/enable-pdf-support-clean
Jun 5, 2026
Merged

fix: enable PDF upload support for Web UI agents#582
yaozheng-fang merged 1 commit into
volcengine:mainfrom
FirstayZheng:fix/enable-pdf-support-clean

Conversation

@FirstayZheng
Copy link
Copy Markdown
Contributor

问题描述

修复 Web UI 中 PDF 文件上传时的错误:

用户在 web_demodogfoodingdogfooding_bfront_with_sso 等 agent 中上传 PDF 文件时,系统报错:
Missing credentials. Please pass an 'api_key', 'workload_identity', 'admin_api_key',
or set the 'OPENAI_API_KEY' or 'OPENAI_ADMIN_KEY' environment variable.

根本原因

  • 这些 Web UI agent 没有配置 before_model_callback 参数
  • 导致后端使用 Google ADK 的默认 PDF 处理逻辑,尝试调用 OpenAI API
  • 但环境中没有配置 OpenAI API key,导致失败

修复方案

为所有 Web UI agent 添加 VeADK 内置的 PDF 处理回调:

from veadk.utils.pdf_to_images import pdf_to_images_before_model_callback

agent = Agent(
    ...
    before_model_callback=pdf_to_images_before_model_callback,
)
该回调使用本地库pypdfium2 PDF 转换为图像无需依赖外部 API修改文件
examples/web_demo/agent.py - 添加 PDF 处理回调
examples/dogfooding/agent.py - 添加 PDF 处理回调智能模式 agent builderexamples/dogfooding_b/agent.py - 添加 PDF 处理回调A/B 对比模式 agent builderexamples/front_with_sso/agent.py - 添加 PDF 处理回调
frontend/bug-fixes/fix-enable-pdf-support.md - 修复文档
frontend/bug-fixes/README.md - 更新索引
测试验证已测试通过启动 Web UI agent
上传多页 PDF 文件
确认 LLM 能够正确理解 PDF 内容
无错误信息
影响范围启用所有 Web UI agent  PDF 上传功能不影响其他文件类型图片文本等的处理无副作用仅依赖项目已有的库pypdfium2pillow相关文档
详细修复记录:[frontend/bug-fixes/fix-enable-pdf-support.md](vscode-webview://1otdvgdcg0p2ak8hjfmagbmpuoblu3cvn1rv9khotabfk8ajbrrb/frontend/bug-fixes/fix-enable-pdf-support.md)

Add pdf_to_images_before_model_callback to all Web UI agents to handle
PDF file uploads locally without requiring OpenAI API credentials.

Changes:
- Add PDF processing callback to web_demo agent
- Add PDF processing callback to dogfooding agent (smart mode builder)
- Add PDF processing callback to dogfooding_b agent (A/B compare mode)
- Add PDF processing callback to front_with_sso agent

Fixes the error: "Missing credentials. Please pass an 'api_key'..." when
users upload PDF files in the Web UI.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@FirstayZheng FirstayZheng force-pushed the fix/enable-pdf-support-clean branch from c0e67bf to b9a85ee Compare June 5, 2026 06:25
@yaozheng-fang yaozheng-fang merged commit 60f59df into volcengine:main Jun 5, 2026
5 checks passed
@FirstayZheng FirstayZheng deleted the fix/enable-pdf-support-clean branch June 5, 2026 06:34
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