Set Google Cloud project information

Check my progress

/ 15

Build ADK agent

Check my progress

/ 15

Evaluating an ADK agent with Agent Platform Gen AI Evaluation

Check my progress

/ 40

Perform BYOD evaluation of LangGraph agents using GenAI

Check my progress

/ 20

Clean up the experiment

Check my progress

/ 10

This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

GENAI110

總覽

Agent Development Kit (ADK) 是可擴充的模組化開放原始碼框架,可用於建構 AI 代理。雖然 ADK 提供了內建的評估模組,但本實驗室會示範如何使用 Agent Platform Gen AI Evaluation Service,衡量基於此框架的代理成效。這種方法提供更廣泛、可解釋且經過品質控管的工具包,可使用自訂指標和符合人類偏好的基準,評估生成式模型或應用程式。

在這個實驗室,您會按照逐步指南操作,使用 Agent Platform Gen AI Evaluation Service 評估 ADK 代理。

這個實驗室參考自 GoogleCloudPlatform/generative-ai 存放區的這個筆記本。

目標

在本實驗室中,您將瞭解如何執行下列工作:

  • 建構及執行本機 ADK 代理。
  • 建立代理評估資料集,並整理成指定格式。
  • 使用下列方法衡量代理成效:
    • 單一工具使用情形評估。
    • 軌跡評估。
    • 回覆品質評估。
  • 使用 Agent Platform Evaluation Service,生成可解釋的指標和基準結果。

設定和需求

實驗室活動啟動須知

請詳閱以下操作說明。實驗室活動會計時,且中途無法暫停。點選「Start Lab」後就會開始計時,顯示可使用 Google Cloud 資源的時間。

您將在真正的雲端環境完成實作實驗室活動,而不是模擬或示範環境。為此,我們會提供新的臨時憑證,供您在實驗室活動期間登入及存取 Google Cloud。

為了順利完成這個實驗室,請先確認:

  • 可以使用標準的網際網路瀏覽器 (Chrome 瀏覽器為佳)。
注意事項:請使用無痕模式 (建議選項) 或私密瀏覽視窗執行此實驗室,這可以防止個人帳戶和學員帳戶之間的衝突,避免個人帳戶產生額外費用。
  • 是時候完成實驗室活動了!別忘了,活動一旦開始將無法暫停。
注意事項:務必使用實驗室專用的學員帳戶。如果使用其他 Google Cloud 帳戶,可能會產生額外費用。

如何開始實驗室及登入 Google Cloud 控制台

  1. 按一下「Start Lab」按鈕。如果實驗室會產生費用,畫面上會出現選擇付款方式的對話方塊。左側的「Lab Details」窗格會顯示下列項目:

    • 「Open Google Cloud console」按鈕
    • 剩餘時間
    • 必須在這個實驗室使用的臨時憑證
    • 完成這個實驗室所需的其他資訊 (如有)
  2. 按一下「Open Google Cloud console」;如果使用 Chrome 瀏覽器,也可以按一下滑鼠右鍵,選取「在無痕視窗中開啟連結」。

    接著,實驗室會啟動相關資源,並開啟另一個分頁,顯示「登入」頁面。

    提示:您可以在不同的視窗並排開啟分頁。

    注意:頁面顯示「選擇帳戶」對話方塊時,請點選「使用其他帳戶」。
  3. 如有必要,請將下方的 Username 貼到「登入」對話方塊。

    {{{user_0.username | "Username"}}}

    您也可以在「Lab Details」窗格找到 Username。

  4. 點按「下一步」。

  5. 複製下方的 Password,並貼到「歡迎使用」對話方塊。

    {{{user_0.password | "Password"}}}

    您也可以在「Lab Details」窗格找到 Password。

  6. 點按「下一步」。

    重要事項:請務必使用實驗室提供的憑證,而非自己的 Google Cloud 帳戶憑證。 注意:如果使用自己的 Google Cloud 帳戶來進行這個實驗室,可能會產生額外費用。
  7. 繼續點按後續頁面:

    • 接受條款及細則。
    • 由於這是臨時帳戶,請勿新增救援選項或雙重驗證機制。
    • 請勿申請免費試用。

Google Cloud 控制台稍後會在這個分頁開啟。

注意:如要使用 Google Cloud 產品和服務,請按一下「導覽選單」,或在「搜尋」欄位輸入服務或產品名稱。「導覽選單」圖示和搜尋欄位

工作 1:在 Agent Platform Workbench 準備環境

  1. 前往 Google Cloud 控制台,依序選取「導覽選單」圖示 (導覽選單) >「Agent Platform」>「Notebooks」>「Workbench」。

  2. 點選「啟用 API」,再點選「啟用」確認。

  3. 在「執行個體」部分,點選 vertex-ai-jupyterlab 執行個體旁的「Open JupyterLab」。JupyterLab 會在新分頁啟動。

  4. 在 JupyterLab 啟動器頁面,點選「終端機」來開啟殼層。

  5. 使用下列指令,下載這個實驗室要使用的筆記本和輔助檔案:

    gcloud storage cp gs://{{{project_0.project_id| YOUR_GCP_PROJECT_ID}}}-bucket/* .
  6. 開啟 檔案。

  7. 出現「Select Kernel」對話方塊時,從可用核心清單選取「Python 3 (Local)」。

  8. 在「Install Agent Development Kit (ADK) and other required packages」(安裝 Agent Development Kit (ADK) 和其他必要套件) 標題下方,執行第一個程式碼儲存格,安裝依附元件。點選頂端的播放按鈕,或是反白選取儲存格並按下鍵盤上的 Shift + Enter 鍵,即可執行儲存格。

  9. 如要在這個 Jupyter 執行階段使用新安裝的套件,您必須重新啟動核心。等待儲存格旁的 [*] 變為 [1] (代表儲存格已完成),然後在 Jupyter Lab 選單依序選取「Kernel」>「Restart Kernel and Clear Outputs of All Cells...」。

  10. 收到確認提示詞時,請選取「Restart」。

  11. 核心重新啟動後,請在「Set Google Cloud project information」(設定 Google Cloud 專案資訊) 下方執行下一個儲存格,設定 Google Cloud 專案資訊並初始化 Agent Platform。

  12. 執行筆記本「Import libraries」(匯入程式庫) 部分的下一個儲存格。

點選「Check my progress」,確認目標已達成。 設定 Google Cloud 專案資訊

工作 2:閱讀並執行筆記本的其餘部分

完整閱讀並執行筆記本的所有儲存格,以便執行下列操作:

  • 設定工具,定義 get_product_details() 和 get_product_price() 函式,做為代理之後使用的工具。
  • 設定模型,定義代理要使用的 Gemini 模型。
  • 定義會建構代理的函式來組合代理,提供您在前述步驟定義的工具,以便生成查詢回覆。
  • 測試代理,查看幾則範例回覆,包括載明曾呼叫哪些函式的 Markdown 格式輸出內容。

點選「Check my progress」,確認目標已達成。 建構 ADK 代理

  • 瞭解如何使用 Agent Platform Gen AI Evaluation Service 評估 ADK 代理。
  • 準備代理評估資料集,內含一組提示詞和預期的工具呼叫 (參考軌跡)。
  • 執行單一工具使用情形評估,判斷代理是否為特定工作選用某項合適的工具。
  • 執行軌跡評估,評估代理是否選用合適的工具,並按照您預期的順序使用。
  • 瞭解如何以圖表呈現評估結果。
  • 瞭解如何定義自訂指標,並根據該指標評估。

點選「Check my progress」,確認目標已達成。 使用 Agent Platform 生成式 AI Evaluation 評估 ADK 代理

  • 額外的「Bring-Your-Own-Dataset (BYOD)」(自備資料集 (BYOD)) 部分,會說明如何提供內含回覆的評估資料集,藉此衡量代理在別處生成的回覆。

點選「Check my progress」,確認目標已達成。 使用 Gen AI Evaluation Service 評估 LangGraph 代理的 BYOD 效能

點選「Check my progress」,確認目標已達成。 清除實驗

恭喜!

您已成功使用 Agent Platform 的 Gen AI Evaluation Service 評估 ADK 代理,並在本機建構及執行代理、準備自訂評估資料集,同時使用內建評估工具,衡量代理的工具使用情形、動作軌跡和最終回覆品質。

您使用下列元件評估代理:

  • 用於建構及執行代理的 ADK (Agent Development Kit)
  • 結構化評估資料集,當中包含預期工具使用情形和參考資料
  • Agent Platform Gen AI Evaluation Service
  • 工具使用情形評估指標
  • 確保每一步準確度的軌跡比對
  • 使用自訂指標評估

使用手冊上次更新日期:2026 年 8 月 28 日

實驗室上次測試日期:2026 年 8 月 28 日

著作權所有 2026 Google LLC。保留所有權利。Google 和 Google 標誌是 Google LLC 的商標,所有其他公司和產品名稱可能是其關聯公司的商標。

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We can notify you via email when it becomes available

Great!

We can contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.