您可以通过 Google Cloud 控制台或 API 为Google Cloud 项目配置 Gemini Cloud Assist 提示与回答共享功能。启用后,Google 会处理并存储项目中所有 Gemini Cloud Assist 用户的匿名提示和回答,最长存储两年,以便改进产品,但绝不会使用您的输入内容来训练或微调基础 LLM。 您可以随时修改此设置。
准备工作
如需获得为 Gemini Cloud Assist 配置提示和回答共享所需的权限,请让您的管理员向您授予 Gemini Cloud Assist Admin (roles/geminicloudassist.admin) Identity and Access Management (IAM) 预定义角色,该角色包含查看和修改 Gemini Cloud Assist 管理员设置所需的所有权限。
如需查看所需的确切权限,请展开所需权限部分:
所需权限
cloudaicompanion.dataSharingWithGoogleSettings.createcloudaicompanion.dataSharingWithGoogleSettings.updatecloudaicompanion.settingBindings.dataSharingWithGoogleSettingsCreatecloudaicompanion.settingBindings.dataSharingWithGoogleSettingsUse-
如果您使用的是直接 API 请求,则必须为
TARGET_PROJECT提供此权限。
-
如果您使用的是直接 API 请求,则必须为
如果您使用的是 Google Cloud 控制台,则还需要以下权限:
cloudaicompanion.instances.queryEffectiveSettingcloudaicompanion.instances.queryEffectiveSettingBindingscloudaicompanion.dataSharingWithGoogleSettings.listcloudaicompanion.dataSharingWithGoogleSettings.getcloudaicompanion.settingBindings.dataSharingWithGoogleSettingsGetcloudaicompanion.settingBindings.dataSharingWithGoogleSettingsUpdatecloudaicompanion.settingBindings.dataSharingWithGoogleSettingsDelete
为 Gemini Cloud Assist 启用提示与回答共享功能
从下列选项中选择一项:
控制台
打开 Google Cloud 控制台。
在 Google Cloud 控制台的任意页面中,点击星光图标 打开或关闭 Gemini Cloud Assist 对话。
系统将打开 Cloud Assist 面板。
点击更多操作 (),然后从下拉菜单中点击 Cloud Assist 设置。
系统会打开管理 Gemini Cloud Assist 设置面板。
在 Gemini Cloud Assist 的数据共享部分,确保已选择通过共享提示和回答来帮助 Google 改进 Gemini Cloud Assist。
点击保存。
API
如需为 Gemini Cloud Assist 启用数据共享,请使用 dataSharingWithGoogleSettings.create 方法创建设置,并使用关联的 settingBindings.create 方法应用该设置。
设置项及其专用值:
获取身份验证令牌:
TOKEN=$(gcloud auth print-access-token)运行以下命令以创建设置:
curl -X POST \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "enablePreviewDataSharing": true }' \ "https://cloudaicompanion.googleapis.com/v1/projects/CONTAINER_PROJECT/locations/global/dataSharingWithGoogleSettings?dataSharingWithGoogleSettingId=SETTING_ID"替换以下内容:
CONTAINER_PROJECT:输入父项目 ID。SETTING_ID:输入唯一的设置名称,例如输入dswg1作为Data Sharing with Google的名称。
如果命令成功,则会返回一个回答正文,其中显示
enablePreviewDataSharing已设置为true:{ "name": "projects/CONTAINER_PROJECT/locations/global/dataSharingWithGoogleSettings/SETTING_ID", "createTime": "2025-01-23T15:22:49.717166932Z", "updateTime": "2025-01-23T15:22:49.717166932Z", "enablePreviewDataSharing": true }如需详细了解身份验证,请参阅使用 REST 时进行身份验证。
创建设置绑定:
curl -X POST \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "target": "projects/TARGET_PROJECT", "product": "GEMINI_CLOUD_ASSIST" }' \ "https://cloudaicompanion.googleapis.com/v1/projects/CONTAINER_PROJECT/locations/global/dataSharingWithGoogleSettings/SETTING_ID/settingBindings?settingBindingId=BINDING_ID"替换以下内容:
TARGET_PROJECT:输入应应用该设置的目标项目。SETTING_ID:在创建设置时使用相同的 SETTING_ID,但在其后附加b1。例如,对于Data Sharing with Google,使用dswg1b1。
如果命令成功,则会采用以下格式返回操作元数据:
{ "name": "projects/CONTAINER_PROJECT/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/TARGET_PROJECT/locations/global/dataSharingWithGoogleSettings/SETTING_ID/settingBindings/BINDING_ID", "verb": "create", "requestedCancellation": false, "apiVersion": "v1" }, "done": false }
停用 Gemini Cloud Assist 的提示与回答共享功能
从下列选项中选择一项:
控制台
打开 Google Cloud 控制台。
在 Google Cloud 控制台的任意页面中,点击星光图标 打开或关闭 Gemini Cloud Assist 对话。
系统将打开 Cloud Assist 面板。
点击更多操作 (),然后从下拉菜单中点击 Cloud Assist 设置。
系统会打开管理 Gemini Cloud Assist 设置面板。
在 Gemini Cloud Assist 的数据共享部分,确保未选中通过共享提示和回答来帮助 Google 改进 Gemini Cloud Assist。
点击保存。
API
如需停用 Gemini Cloud Assist 的提示与回答共享功能,请使用 dataSharingWithGoogleSettings.patch 方法。
获取令牌:
TOKEN=$(gcloud auth print-access-token)运行以下命令以停用该设置:
curl -X PATCH \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "enablePreviewDataSharing": false } ' \ "https://cloudaicompanion.googleapis.com/v1/projects/CONTAINER_PROJECT/locations/global/dataSharingWithGoogleSettings?dataSharingWithGoogleSettingId=SETTING_ID"只有在您启用提示和回答共享时该设置资源就已存在的情况下,此
PATCH命令才会成功执行。替换以下内容:
CONTAINER_PROJECT:输入父项目 ID。SETTING_ID:输入现有设置名称,例如输入dswg1作为Data Sharing with Google的名称。
如果命令成功,则会返回一个回答正文,其中显示
enablePreviewDataSharing已设置为false:{ "name": "projects/CONTAINER_PROJECT/locations/global/dataSharingWithGoogleSettings/SETTING_ID", "createTime": "2025-01-23T15:22:49.717166932Z", "updateTime": "2025-01-23T15:22:49.717166932Z", "enablePreviewDataSharing": false }