From b9a85ee88c5b82b5fc799c0fc0b7a729132083f7 Mon Sep 17 00:00:00 2001 From: zhengchuyi Date: Fri, 5 Jun 2026 14:22:47 +0800 Subject: [PATCH] fix: enable PDF upload support for Web UI agents 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 --- examples/dogfooding/agent.py | 2 ++ examples/dogfooding_b/agent.py | 2 ++ examples/front_with_sso/agent.py | 2 ++ examples/web_demo/agent.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/examples/dogfooding/agent.py b/examples/dogfooding/agent.py index eae6cdcf..aee43544 100644 --- a/examples/dogfooding/agent.py +++ b/examples/dogfooding/agent.py @@ -24,6 +24,7 @@ import os from veadk import Agent +from veadk.utils.pdf_to_images import pdf_to_images_before_model_callback # The schema mirrors the web UI's AgentDraft and the codegen catalog # (frontend/src/create/veadkCatalog.ts). Output values MUST come from the @@ -90,6 +91,7 @@ name="agent_builder", description="VeADK Agent Builder:把自然语言需求转化为智能体配置 JSON(前端据此生成 VeADK 项目)。", instruction=lambda _ctx: INSTRUCTION, + before_model_callback=pdf_to_images_before_model_callback, **({"model_name": _MODEL_A} if _MODEL_A else {}), ) diff --git a/examples/dogfooding_b/agent.py b/examples/dogfooding_b/agent.py index b746fc35..27133726 100644 --- a/examples/dogfooding_b/agent.py +++ b/examples/dogfooding_b/agent.py @@ -24,6 +24,7 @@ import os from veadk import Agent +from veadk.utils.pdf_to_images import pdf_to_images_before_model_callback # The two builder apps share one instruction. ADK puts the agents dir on # sys.path, so the sibling app package is importable; fall back to the @@ -39,6 +40,7 @@ name="agent_builder_b", description="VeADK Agent Builder (B):A/B 对比中的第二个构建器。", instruction=lambda _ctx: INSTRUCTION, + before_model_callback=pdf_to_images_before_model_callback, **({"model_name": _MODEL_B} if _MODEL_B else {}), ) diff --git a/examples/front_with_sso/agent.py b/examples/front_with_sso/agent.py index ef8a132c..9433d0ae 100644 --- a/examples/front_with_sso/agent.py +++ b/examples/front_with_sso/agent.py @@ -20,11 +20,13 @@ """ from veadk import Agent +from veadk.utils.pdf_to_images import pdf_to_images_before_model_callback agent = Agent( name="sso_demo_agent", description="Demo agent served behind an SSO login page.", instruction="You are a helpful assistant. Answer concisely.", + before_model_callback=pdf_to_images_before_model_callback, ) # Required by the Google ADK agent loader. diff --git a/examples/web_demo/agent.py b/examples/web_demo/agent.py index 8491b589..d3774a65 100644 --- a/examples/web_demo/agent.py +++ b/examples/web_demo/agent.py @@ -24,6 +24,7 @@ """ from veadk import Agent +from veadk.utils.pdf_to_images import pdf_to_images_before_model_callback agent = Agent( name="web_demo", @@ -32,6 +33,7 @@ "You are a helpful assistant. Answer clearly and concisely in the " "user's language." ), + before_model_callback=pdf_to_images_before_model_callback, ) # Required by the ADK agent loader.