Install packages and import libraries

Check my progress

/ 5

Load the Gemini models

Check my progress

/ 5

Run Set system instructions cell in notebook.

Check my progress

/ 5

Run Thinking level cell in notebook

Check my progress

/ 5

Run Configure the temperature parameter cell in notebook

Check my progress

/ 5

Run Generate content stream cell in notebook

Check my progress

/ 5

Run Thought summaries cell in notebook

Check my progress

/ 5

Run Multi-turn chat cell in notebook

Check my progress

/ 5

Run Safety filters cell in notebook

Check my progress

/ 5

Run Send asynchronous requests cell in notebook

Check my progress

/ 5

Run Multimodality cell in notebook

Check my progress

/ 5

Run Media resolution cell in notebook

Check my progress

/ 5

Run Structured output cell in notebook

Check my progress

/ 5

Run Search as a tool cell in notebook

Check my progress

/ 5

Run Code Execution cell in notebook

Check my progress

/ 5

Run URL context cell in notebook

Check my progress

/ 5

Run Function calling cell in notebook

Check my progress

/ 4

Run Streaming function calling cell in notebook

Check my progress

/ 4

Run Multimodal function responses cell in notebook

Check my progress

/ 4

Run Thought signatures cell in notebook

Check my progress

/ 4

Run Count tokens and compute tokens cell in notebook

Check my progress

/ 4

This lab may incorporate AI tools to support your learning.
注意:為確保體驗一致且效能優異,本實驗室可能會針對部分模型要求提供快取回應。

GSP1150

Google Cloud 自學實驗室

總覽

模型用途廣泛,可處理文字、程式碼和圖像,執行需進階推理和多模態分析的複雜工作。Gemini 擅長程式設計、STEM (科學、技術、工程、數學) 科目、網頁程式開發和偵錯,特別精於生成程式碼和解析細膩的提示詞。

模型快速且有效率,專為高頻率工作流程最佳化,可協助企業自動執行工作及建構回應式應用程式,同時兼顧品質。 這個模型可提供近乎即時的回應與優異的性價比,企業能用於提供互動性高的大規模商用體驗。

本實驗室中,您將執行範例,瞭解關鍵的模型功能,並體驗新的 API 功能。

事前準備

開始這個實驗室之前,您應已熟悉下列概念:

  • 基本 Python 程式設計。
  • 一般 API 概念。
  • Agent Platform Workbench 的 Jupyter 筆記本執行 Python 程式碼。

目標

本實驗室中,您將使用 模型執行下列操作:

  • 以不同思考程度,生成文字及控管推論過程。
  • 設定模型參數與系統指令。
  • 處理音訊、程式碼和影片等多模態資料。
  • 實作函式呼叫與執行程式碼等進階功能。

設定和需求

瞭解以下事項後,再點選「Start Lab」按鈕

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

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

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

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

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

  1. 按一下「Start Lab」按鈕。如果實驗室會產生費用,請在開啟的對話方塊中選取付款方式。右側的「Lab setup and access」面板會顯示下列項目:

    • 「Open Google Cloud console」按鈕
    • 此實驗室所需的臨時憑證 (使用者名稱和密碼)
    • 完成此實驗室所需的其他資訊 (如有)

    請注意,實驗室計時器位於頁面頂端附近,會顯示剩餘時間。

  2. 按一下「Open Google Cloud console」。如果使用 Chrome 瀏覽器,也可以按一下滑鼠右鍵,選取「在無痕視窗中開啟連結」

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

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

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

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

    您也可以在「Lab setup and access」面板找到「Username」。

  4. 點選「下一步」

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

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

    您也可以在「Lab setup and access」面板找到「Password」。

  6. 點選「下一步」

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

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

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

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

工作 1:設定環境

本節中,您將安裝套件並匯入程式庫。

在 Agent Platform Workbench 開啟筆記本

  1. 在 Google Cloud 控制台,依序點選「導覽選單」圖示 「導覽選單」圖示 >「Agent Platform」>「Notebooks」>「Workbench」

  2. 找出 執行個體,然後點選「Open JupyterLab」按鈕。

Workbench 執行個體的 JupyterLab 介面會在新瀏覽器分頁中開啟。

設定筆記本

  1. 開啟 檔案。

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

  3. 執行筆記本的「Getting Started」部分。專案 ID 和位置已預先設定完成。

注意:如果執行筆記本儲存格後出現 429 回應,請稍候一分鐘再重新執行儲存格,應該就能繼續操作。

點選「Check my progress」,確認目標已達成。 安裝套件並匯入程式庫。

工作 2:載入 Gemini 模型

  • 在筆記本,執行「Load the Gemini Models」區段中的儲存格,初始化 genai 用戶端並定義模型變數。

點選「Check my progress」,確認目標已達成。 一直執行至筆記本的「Load the Gemini 3 models」區段。

工作 3:探索 Gemini 的功能

本節中,您將瞭解 Gemini 3 Pro 模型和 API 的主要功能。探索筆記本中的功能後,系統會引導您返回本處的操作說明,檢查進度

設定系統指令

  • 前往「Set system instructions」區段,然後執行儲存格來定義模型行為 (將英文翻譯成西班牙文)。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Set system instructions」區段。

思考程度

  • 前往「Thinking level」區段。執行儲存格,觀察 thinking_level 參數經調整後,模型推論過程的深度會如何變化。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Thinking level」區段。

設定溫度參數

  • 在「Configure the temperature parameter」區段,執行程式碼來調整回覆生成的隨機程度。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Configure the temperature parameter」區段。

生成內容串流

  • 執行「Generate content stream」區段,瞭解模型如何分批回覆,而不是等待完整回覆。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Generate content stream」區段。

想法重點摘要

  • 執行「Thought summaries」儲存格,檢查模型生成最終答案前的中間推論步驟。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Thought summaries」區段。

多輪對話

  • 完成「Multi-turn chat」區段,即可啟動對話工作階段,並保留先前提示詞的脈絡。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Multi-turn chat」區段。

安全篩選機制

  • 前往「Safety filters」區段,執行儲存格來設定仇恨言論、騷擾和其他類別的封鎖門檻。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Safety filters」區段。

傳送非同步要求

  • 執行「Send asynchronous requests」區段,瞭解如何使用非同步方法傳送非封鎖要求。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Send asynchronous requests」區段。

多模態

  • 在「Multimodality」區段,執行程式碼來分析不同類型的媒體,包括圖片、影片及文字提示詞。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Multimodality」區段。

媒體解析度

  • 完成「Media resolution」區段,比較不同的解析度設定如何影響模型分析視覺細節。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Media resolution」區段。

結構化輸出內容

  • 執行「Structured output」儲存格,強制模型以特定格式 (例如 JSON) 回覆。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Structured output」區段。

以 Google 搜尋強化事實基礎

  • 執行「Grounding with Google Search」區段,使用 Google 搜尋查找資料,鞏固回覆的事實基礎。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Grounding with Google Search」區段。

程式碼執行

  • 前往「Code Execution」區段,然後執行儲存格,讓模型編寫及執行 Python 程式碼來解決數學問題。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Code Execution」區段。

網址背景資訊

  • 完成「URL context」區段,瞭解模型如何直接從所提供的網址處理及摘要內容。

點選「Check my progress」,確認目標已達成。 執行筆記本的「URL context」區段。

函式呼叫

  • 執行「Function calling」區段,定義模型可叫用的自訂工具,擷取外部資訊。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Function calling」區段。

串流函式呼叫

  • 執行「Streaming function calling」儲存格,處理串流回應中的工具輸出內容。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Streaming function calling」區段。

多模態函式回覆

  • 完成「Multimodal function responses」區段,瞭解函式如何傳回非文字資料,例如圖片或繪圖。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Multimodal function responses」區段。

想法簽名

  • 執行「Thought signatures」區段,驗證模型推論鏈的真實性。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Thought signatures」區段。

計算詞元數和運算詞元

  • 最後,執行「Count tokens and compute tokens」儲存格,分析提示詞和回覆的費用和大小。

點選「Check my progress」,確認目標已達成。 執行筆記本的「Count tokens and compute tokens」區段。

恭喜!

您已完成這個實驗室。本實驗室中,您使用了 Gemini API 和適用於生成式 AI 的 Google Gen AI SDK,順利在 Jupyter 筆記本操作 模型。

後續步驟/瞭解詳情

歡迎參考下列資源,進一步瞭解生成式 AI 和 Gemini Enterprise Agent Platform:

Google Cloud 教育訓練與認證

協助您瞭解如何充分運用 Google Cloud 的技術。我們的課程會介紹專業技能和最佳做法,讓您可以快速掌握要領並持續進修。我們提供從基本到進階等級的訓練課程,並有隨選、線上和虛擬課程等選項,方便您抽空參加。認證可協助您驗證及證明自己在 Google Cloud 技術方面的技能和專業知識。

使用手冊上次更新日期:2026 年 5 月 18 日

實驗室上次測試日期:2026 年 4 月 16 日

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.