I E V A L File Search —— Managed RAG。 Building applications in the Gemini API family SUP PORTS 支援的格式與規格 PDF、DOCX、TXT、JSON、常見程式碼檔 單一 store 建議 < 20 GB 內建 citation 標註來源段落 raw file 48 小時清掉、store 內 embedding 永久保留 支援 Gemini 3.5 Pro / Flash / Flash-Lite 目前不能與 Grounding with Google Search 在同一次 call 並 用。
C D E L I V E R Y Webhook —— 換 Google 來 call 你。 Agents API 的同胞雙生。不要 polling、不要長連接——agent 跑完,Gemini 主動 POST 結果進來。 01 · KICK OFF 建立 interaction 你的 server 呼叫 Agents API,帶 上 webhookUrl 與 metadata。 立刻拿到 interaction_id。 → 0 2 · G O O GL E W O R K S Agent 背景跑任務 幾秒到幾分鐘。你的 server 不用 等、不用連著。 → 03 · C ALLBACK Gemini POST 到你的 webhook 帶 interaction_id、status、完整 結果。HMAC 簽章 + timestamp ,你負責驗。 → 04 · FAN-OUT 推回使用者 查 interaction_id 跟蹤的 user, 用 LINE Push API 送結果。 WHY WEBHOOK, NOT POLLING 低延遲 × 低成本 不用輪詢、不用 keep-alive 長連接 At-least-once delivery——設計冪等 handler 適合上百、上千個並行任務 ARCHITECTURAL PATTERN Webhook In · Webhook Out 入口:LINE webhook 送使用者訊息進來 出口:Gemini webhook 送 agent 結果進來 中間不 block,server = event handler。 Building applications in the Gemini API family
R E D E C I S I O N 不是「丟給 LLM」, 是「query 該走哪一條路徑」。 架構師的工作:在 LLM 之前設一個快、便宜、可預測的 routing 層。 INPUT User message 使用者在 LINE 傳訊息進來 → ROUTE Intent router (Flash-Lite ) 用便宜小模型判斷分類;幾十毫 秒、幾乎免費。 → BRANC H 三條路徑 · 快問快答 → generateContent · 查公司資料 → File Search · 長任 務 → Agents API → DELIVE RY 同步 reply / 非同步 webhook 快問題用 LINE reply token 同步 回;長任務等 Gemini webhook 進來再 push。 Routing 層是「你設計的」那一黚,不是 Google 給你的。 這是你從 「call API」 變成 「architect」 的關鍵動作——準確、可觀測、成本可控。 Building applications in the Gemini API family
進、Reply 出。 01 · USER 使用者傳訊息 在 LINE App 輸入文字、貼圖、圖 片、語音。 → 02 · P LATFORM LINE Messaging Platform 把 event POST 到你設定的 webhook URL,附 X-Line- Signature 簽章。 → 03 · YOUR SE RVE R Webhook handler 驗章 → 業務邏輯(通常是 keyword match / if-else)→ 組 回應。 → 04 · RE PLY Reply / Push API 用 replyToken 回(限 1 次)或 push(隨時、有額度)。 便宜、可預測、但擴充很痛——新的需求都要寫新的 if 。 語意理解幾乎為零,使用者多打一個錯字就 fallback 到 default reply。 Building applications in the Gemini API family
+ 三個工具。 CHANNEL Messaging Platform 收訊息、回訊息 簽章驗證 LIFF / Rich Menu 前端入口、權限授權 Push API 非同步任務完成回推 YOUR WE BHOOK SER VER 1 · 驗章 & parse 驗 X-Line-Signature、抽出 message text + user_id 2 · Intent Router Flash-Lite 結構化輸出,分類到三條路徑之一 3 · Tool dispatch 呼叫對應的 Gemini API,組成回應 4 · Format & reply 把 citation 轉成 Flex Message,呼叫 LINE Reply GEMI NI API generateContent + File Search 私有資料、需要 citation generateContent + Grounding 即時公開資訊 Agents API + Webhook 長任務、Deep Research File Search Store 公司知識庫、預先 index 好 Building applications in the Gemini API family