設定 Gemini Cloud Assist 的提示和回覆共用功能

本文說明如何使用 Google Cloud 控制台或 API,為專案設定 Gemini Cloud Assist 提示和回覆共用功能。

啟用後,Google 會處理專案中所有 Gemini Cloud Assist 使用者的提示詞和回覆,以改良產品,進而提升 Gemini Cloud Assist 的品質。Google 最多會儲存專案提交的匿名提示和回覆兩年。貴機構的提示和回覆絕不會用於訓練或微調任何 LLM 模型。

您隨時可以變更這項設定。

事前準備

如要取得設定 Gemini Cloud Assist 提示和回覆共用功能的必要權限,請要求系統管理員授予您「Gemini Cloud Assist 管理員」(roles/geminicloudassist.admin) Identity and Access Management (IAM) 預先定義角色,這個角色包含查看及修改 Gemini Cloud Assist 管理員設定所需的所有權限。

如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:

所需權限

  • cloudaicompanion.dataSharingWithGoogleSettings.create
  • cloudaicompanion.dataSharingWithGoogleSettings.update
  • cloudaicompanion.settingBindings.dataSharingWithGoogleSettingsCreate
  • cloudaicompanion.settingBindings.dataSharingWithGoogleSettingsUse
    • 如果您使用直接 API 要求,則必須具備這項權限,才能使用 TARGET_PROJECT

如果您使用 Google Cloud 控制台,則必須具備下列額外權限:

  • cloudaicompanion.instance.queryEffectiveSetting
  • cloudaicompanion.instance.queryEffectiveSettingBindings
  • cloudaicompanion.dataSharingWithGoogleSettings.list
  • cloudaicompanion.dataSharingWithGoogleSettings.get
  • cloudaicompanion.settingBindings.dataSharingWithGoogleSettingsGet
  • settingBindings.dataSharingWithGoogleSettingsUpdate
  • settingBindings.dataSharingWithGoogleSettingsDelete

您或許還可透過其他預先定義的角色自訂角色取得這些權限。

啟用 Gemini Cloud Assist 的提示詞和回覆分享功能

選取下列選項之一:

控制台

  1. 開啟 Google Cloud 控制台。

    前往 Google Cloud 控制台

  2. 在 Google Cloud 控制台的任何頁面中,點選「火花」「開啟或關閉 Gemini Cloud Assist 對話」

    「Cloud Assist」面板隨即開啟。

  3. 按一下「更多動作」圖示 (),然後在下拉式選單中點按「雲端輔助設定」

    「管理 Gemini Cloud Assist」設定面板隨即開啟。

  4. 在「Gemini Cloud Assist 資料共用」部分,確認已選取「分享提示詞和回覆,協助 Google 改良 Gemini Cloud Assist」

  5. 按一下 [儲存]

API

如要啟用 Gemini Cloud Assist 的資料共用功能,請使用 dataSharingWithGoogleSettings.create 方法建立設定,並使用相關聯的 settingBindings.create 方法套用設定。

  1. 建立設定和設定專屬值:

    1. 取得驗證權杖

      TOKEN=$(gcloud auth print-access-token)
      
    2. 執行下列指令來建立設定:

      curl -X POST \
        -H "Authorization: Bearer $TOKEN" \
        -H 'Content-Type: application/json' \
        -d '{
          "enablePreviewDataSharing": true
          }' \
        "https://cloudaicompanion.googleapis.com/v1/projects/CONTAINER_PROJECT_NAME/locations/global/dataSharingWithGoogleSettings?dataSharingWithGoogleSettingId=SETTING_ID"
      

      更改下列內容:

      • CONTAINER_PROJECT_NAME:輸入父項專案 ID。
      • SETTING_ID:輸入專屬設定名稱,例如 Data Sharing with Googledswg1

      如果指令成功執行,則會傳回回應主體,顯示 enablePreviewDataSharing 設為 true

      {
        "name": "projects/CONTAINER_PROJECT_NAME/locations/global/dataSharingWithGoogleSettings/SETTING_ID",
        "createTime": "2025-01-23T15:22:49.717166932Z",
        "updateTime": "2025-01-23T15:22:49.717166932Z",
        "enablePreviewDataSharing": true
      }
      

      如要進一步瞭解驗證,請參閱「使用 REST 進行驗證」。

  2. 建立設定繫結:

      curl -X POST \
        -H "Authorization: Bearer $TOKEN" \
        -H 'Content-Type: application/json' \
        -d '{
          "target": "projects/TARGET_PROJECT_NAME",
          "product": "GEMINI_CLOUD_ASSIST"
          }' \
        "https://cloudaicompanion.googleapis.com/v1/projects/CONTAINER_PROJECT_NAME/locations/global/dataSharingWithGoogleSettings/SETTING_ID/settingBindings?settingBindingId=BINDING_ID"
    

    更改下列內容:

    • TARGET_PROJECT_NAME:輸入要套用設定的目標專案。
    • SETTING_ID:使用建立設定時的 SETTING_ID,但請附加 b1。例如,使用 dswg1b1 代表 Data Sharing with Google

    如果指令成功執行,則會傳回下列格式的作業中繼資料:

    {
      "name": "projects/<var>CONTAINER_PROJECT_NAME</var>/locations/global/operations/operation-1737646069712-62c6140bb04bb-49261230-43701daf",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.cloudaicompanion.v1.OperationMetadata",
        "createTime": "2025-01-23T15:27:50.076075570Z",
        "target": "projects/<var>TARGET_PROJECT_NAME</var>/locations/global/dataSharingWithGoogleSettings/<var>SETTING_ID</var>/settingBindings/<var>BINDING_ID</var>",
        "verb": "create",
        "requestedCancellation": false,
        "apiVersion": "v1"
      },
      "done": false
    }
    

停用 Gemini Cloud Assist 的提示詞和回覆共用功能

選取下列選項之一:

控制台

  1. 開啟 Google Cloud 控制台。

    前往 Google Cloud 控制台

  2. 在 Google Cloud 控制台的任何頁面中,點選「火花」「開啟或關閉 Gemini Cloud Assist 對話」

    「Cloud Assist」面板隨即開啟。

  3. 按一下「更多動作」圖示 (),然後在下拉式選單中點按「雲端輔助設定」

    「管理 Gemini Cloud Assist」設定面板隨即開啟。

  4. 在「Data sharing for Gemini Cloud Assist」(Gemini Cloud Assist 資料共用) 部分,請確認未選取「Help Google improve Gemini Cloud Assist by sharing your prompts and response」(分享提示詞和回覆,協助 Google 改良 Gemini Cloud Assist)

  5. 按一下 [儲存]

API

如要停用 Gemini Cloud Assist 的提示詞和回覆共用功能,請使用 dataSharingWithGoogleSettings.patch 方法。

  1. 取得權杖:

    TOKEN=$(gcloud auth print-access-token)
    
  2. 執行下列指令即可停用這項設定:

    curl -X PATCH \
      -H "Authorization: Bearer $TOKEN" \
      -H 'Content-Type: application/json' \
      -d '{
        "enablePreviewDataSharing": false
        } ' \
      "https://cloudaicompanion.googleapis.com/v1/projects/CONTAINER_PROJECT_NAME/locations/global/dataSharingWithGoogleSettings?dataSharingWithGoogleSettingId=SETTING_ID"
    

    只有在您啟用提示和回覆分享功能時,設定資源已存在,這個 PATCH 指令才會成功。

    更改下列內容:

    • CONTAINER_PROJECT_NAME:輸入父項專案 ID。
    • SETTING_ID:輸入現有設定名稱,例如 dswg1 (適用於 Data Sharing with Google)。

    如果指令成功執行,則會傳回回應主體,顯示 enablePreviewDataSharing 設為 false

    {
      "name": "projects/CONTAINER_PROJECT_NAME/locations/global/dataSharingWithGoogleSettings/SETTING_ID",
      "createTime": "2025-01-23T15:22:49.717166932Z",
      "updateTime": "2025-01-23T15:22:49.717166932Z",
      "enablePreviewDataSharing": false
    }
    

後續步驟