Create Agent Platform Notebooks instance

Check my progress

/ 50

Clone a course repo within your Agent Platform Workbench instance

Check my progress

/ 50

This lab may incorporate AI tools to support your learning.

總覽

本實驗室說明如何檢查 Vertex AI Gemini API 回傳的安全評分,以及如何設定安全門檻來篩選回覆。

學習目標

  1. 呼叫 Vertex AI Gemini API,並檢查回覆的安全評分
  2. 依據需求定義門檻來篩選安全評分

工作 0:設定和需求

每個實驗室都會提供新的 Google Cloud 專案和一組資源,讓您在時限內免費使用。

  1. 請以無痕視窗登入 Google Skills。

  2. 請記下實驗室時間限制 (例如 1:15:00),務必在時限內完成作業。
    研究室不提供暫停功能。如有需要,您可以重新開始,但原先的進度恕無法保留。

  3. 準備就緒後,請按一下「Start lab」

  4. 請記下研究室憑證 (使用者名稱密碼),這組資訊將用於登入 Google Cloud 控制台。

  5. 按一下「Open Google Console」

  6. 按一下「Use another account」,然後複製這個研究室的憑證,並貼入提示訊息。
    如果使用其他憑證,系統會顯示錯誤或向您收取費用

  7. 接受條款,然後略過資源復原頁面。

啟用 Notebooks API

  1. 前往 Google Cloud 控制台,依序點選「導覽選單」>「API 和服務」>「程式庫」

  2. 搜尋「Notebooks API」並按下 Enter 鍵。

  3. 點選搜尋結果中的「Notebooks API」;若尚未啟用 API,請按一下「啟用」

啟用 Vertex AI API

  1. 前往 Google Cloud 控制台,依序點選「導覽選單」>「Vertex AI」>「資訊主頁」

  2. 點選「啟用所有建議的 API」

點選「Check my progress」確認目標已達成。 啟用 Notebooks API 和 Vertex AI API

工作 1:開啟 Vertex AI Workbench 執行個體

  1. 前往 Google Cloud 控制台,依序點選「導覽選單」>「Vertex AI」>「Workbench」

  2. 在「執行個體」頁面,點選「建立新項目」

  3. 請使用預設可用區和區域: 。 其他設定維持不變,然後點選「建立」。新的 VM 會在 2 到 3 分鐘內啟用。

  4. 點選「開啟 JupyterLab」。 JupyterLab 視窗會在新分頁開啟。

點選「Check my progress」確認目標已達成。 建立 Vertex AI Workbench 執行個體

工作 2:複製 Vertex AI Workbench 執行個體中的課程存放區

如要複製 JupyterLab 執行個體中的筆記本,請按照下列步驟操作:

  1. 在 JupyterLab 開啟新的終端機視窗。

  2. 在指令列提示詞中執行下列指令:

git clone https://github.com/GoogleCloudPlatform/asl-ml-immersion.git cd asl-ml-immersion export PATH=$PATH:~/.local/bin make install
  1. 如要確認是否已複製存放區,請按兩下 asl-ml-immersion 目錄,確認可以查看內容。 此課程會用到的所有 Jupyter 筆記本實驗室檔案,都放在這個目錄。

點選「Check my progress」確認目標已達成。 複製 Vertex AI 平台 Notebooks 執行個體中的課程存放區

工作 3:透過 Gemini API 採取保護措施

  1. 在筆記本介面中,依序前往「asl-ml-immersion」>「notebooks」>「responsible_ai」>「safety」>「solutions」,然後開啟「gemini_safety_ratings.ipynb」

  2. 如果出現「Select Kernel」對話方塊,請選取「Python 3」

  3. 在筆記本介面中,依序點選「Edit」>「Clear Outputs of All Cells」

  4. 詳閱筆記本操作說明,然後執行筆記本中的所有內容。

提示:如要執行目前的儲存格,請點選儲存格,然後按下 Shift + Enter 鍵。如需其他儲存格指令,請查看筆記本 UI 中的「Run」部分。

關閉研究室

完成實驗室後,請按一下「End Lab」。Google Skills 會移除您使用的資源,並清除所用帳戶。

您可以為實驗室的使用體驗評分。請選取合適的星級評等並提供意見,然後按一下「Submit」

星級評等代表您的滿意程度:

  • 1 星 = 非常不滿意
  • 2 星 = 不滿意
  • 3 星 = 普通
  • 4 星 = 滿意
  • 5 星 = 非常滿意

如果不想提供意見回饋,您可以直接關閉對話方塊。

如有任何想法、建議或指教,請透過「Support」分頁提交。

Copyright 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 will notify you via email when it becomes available

Great!

We will 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.

Complete this quick step to start your lab.