使用 Gemini 輔助功能說明程式碼儲存格

本文說明如何使用 Gemini in Colab Enterprise (Gemini for Google Cloud 產品之一),輔助您在 Colab Enterprise 筆記本中說明程式碼儲存格。

瞭解 Gemini for Google Cloud 如何使用您的資料

本文件適用於使用 Colab Enterprise 的資料分析師、資料科學家和資料開發人員。本文假設您已瞭解如何在筆記本環境中編寫程式碼。

總覽

Gemini in Colab Enterprise 可協助您說明 Colab Enterprise 筆記本中的程式碼儲存格。如果您正在使用他人的筆記本,並想快速瞭解程式碼的用途,建議您這麼做。或者,您可能需要提醒自己筆記本各部分的運作方式,因為您已有一段時間沒有處理筆記本。

取得程式碼儲存格的說明後,您可以瀏覽任何內含的程式碼片段,並查看來源。您也可以使用「說明程式碼」對話方塊討論程式碼,並提出後續問題。詳情請參閱「說明程式碼儲存格」。

事前準備

  1. 確認您已為 Google Cloud 使用者帳戶和專案設定 Gemini 版 Colab Enterprise。
  2. 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
  3. Enable the Vertex AI, Gemini for Google Cloud, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  4. Enable the Vertex AI, Gemini for Google Cloud, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

必要的角色

如要取得在 Colab Enterprise 中使用 Gemini 的權限,請要求管理員在專案中授予您下列 IAM 角色:

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

說明程式碼儲存格

如要使用 Gemini for Google Cloud說明程式碼儲存格,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的 Colab Enterprise「我的筆記本」頁面。

    前往「我的筆記本」

  2. 在「Region」(區域) 選單中,選取包含筆記本的區域。

  3. 按一下要開啟的筆記本。

  4. 在筆記本中,按一下含有程式碼的程式碼儲存格。

  5. 依序點選「可用的 AI 功能」和「說明程式碼」

    如果尚未授權資料科學代理,Colab Enterprise 會在驗證 Google 帳戶與資料科學代理時,顯示簡短的對話方塊。

  6. 系統會顯示「說明程式碼」對話方塊,其中包含程式碼說明。

    詳閱說明、瀏覽程式碼片段範例, 並查看來源。使用這個對話方塊討論程式碼,並提出後續問題。

  7. 如要關閉「說明程式碼」對話方塊,請按一下「關閉」

停用 Gemini in Colab Enterprise

如要為 Google Cloud 專案停用 Gemini in Colab Enterprise,管理員必須停用 Gemini for Google Cloud API。請參閱「停用服務」。

如要為特定使用者停用 Gemini in Colab Enterprise,管理員必須撤銷該名使用者的「Gemini for Google Cloud 使用者」 (roles/cloudaicompanion.user) 角色。詳情請參閱撤銷單一 IAM 角色

後續步驟