與 Gemini 討論筆記本內容
本文說明如何使用 Gemini in Colab Enterprise (Gemini for Google Cloud 系列產品之一),與筆記本進行對話。
瞭解 Gemini for Google Cloud 如何使用您的資料。
本文件適用於使用 Colab Enterprise 的資料分析師、資料科學家和資料開發人員。本文假設您已瞭解如何在筆記本環境中編寫程式碼。
總覽
你可以與 Gemini 討論可能的程式碼解決方案,或瞭解如何在筆記本中執行特定工作。您也可以在筆記本中取得程式碼說明。
例如,您可以從下列類似的提示著手:
- 如何篩選 Pandas DataFrame?
- 如何在 Colab Enterprise 中建立繪圖?
- 顯示公開資料集清單。
- 總結這個筆記本的用途。
Gemini 會使用筆記本做為脈絡資訊。你可以討論相關細節、取得程式碼改善建議,或瞭解下一步該怎麼做。
事前準備
- 確認您已為 Google Cloud 使用者帳戶和專案設定 Gemini 版 Colab Enterprise。
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
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 theserviceusage.services.enablepermission. Learn how to grant roles. -
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 theserviceusage.services.enablepermission. Learn how to grant roles. -
Colab Enterprise 使用者 (
roles/aiplatform.colabEnterpriseUser) -
Gemini 版 Google Cloud 使用者 (
roles/cloudaicompanion.user) -
前往 Google Cloud 控制台的 Colab Enterprise「我的筆記本」頁面。
-
在「Region」(區域) 選單中,選取包含筆記本的區域。
-
按一下要開啟的筆記本。
-
按一下「開啟/關閉 Gemini in Colab」按鈕,開啟對話方塊。
-
在 Gemini 對話方塊中輸入提示,即可開始對話。
-
Gemini 會根據提示回覆。回覆內容可能包括程式碼片段、筆記本的一般建議,或有助於解答問題的一般資訊。
評估內容後,您可以採取下列動作:
- 如要複製建議的程式碼片段,請按一下「複製」按鈕。然後將程式碼貼到筆記本的程式碼儲存格。
- 如要將建議的程式碼片段新增為筆記本中的新程式碼儲存格,請點按「新增程式碼儲存格」按鈕。
- 視需要提出後續問題,繼續討論。
-
如要關閉「Gemini」對話方塊,請按一下「關閉」。
如要進一步瞭解如何使用 Gemini 輔助功能撰寫及編輯程式碼,請參閱下列文章:
必要的角色
如要取得使用 Gemini in Colab Enterprise 的必要權限,請要求管理員在專案中授予您下列 IAM 角色:
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
使用即時通訊
如要與 Gemini 討論筆記本內容,請按照下列步驟操作:
停用 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 角色。
按鈕。然後將程式碼貼到筆記本的程式碼儲存格。
按鈕。