广东专家领衔国际研究团队发现晚期肠癌化疗新方案

百度 2017年全年共实现营业收入2269亿元,同比增长%,实现归属于上市公司股东净利润亿元,同比增长126.%。

本页介绍了 Web Grounding for Enterprise 合规性控制,以及如何使用 Web Grounding for Enterprise API 生成基于网络信息的回答。编入索引的内容是 Google 搜索中可用的内容的一部分,适合金融、医疗保健和公共部门等受严格监管的行业的客户。

如果您不需要合规性控制,请使用使用 Google 搜索接地,因为它可以访问更广泛的 Web 索引。

概览

企业版 Web Grounding 使用 Web 索引来生成有依据的回答。Web 索引支持以下功能:

由于系统不会保留任何客户数据,因此客户管理的加密密钥 (CMEK) 和 Access Transparency (AxT) 不适用。

使用 API

本部分提供了一些示例请求,展示了如何使用 Vertex AI 上的 Generative AI API Gemini 2 通过 Gemini 创建有事实依据的回答。如需使用该 API,您必须设置以下字段:

  • Contents.parts.text:用户要发送给 API 的文本查询。
  • tools.enterpriseWebSearch:提供此工具后,Gemini 即可使用企业版 Web Grounding。

Python

安装

pip install --upgrade google-genai

如需了解详情,请参阅 SDK 参考文档

设置环境变量以将 Gen AI SDK 与 Vertex AI 搭配使用:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True

from google import genai
from google.genai.types import (
    EnterpriseWebSearch,
    GenerateContentConfig,
    HttpOptions,
    Tool,
)

client = genai.Client(http_options=HttpOptions(api_version="v1"))

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="When is the next total solar eclipse in the United States?",
    config=GenerateContentConfig(
        tools=[
            # Use Enterprise Web Search Tool
            Tool(enterprise_web_search=EnterpriseWebSearch())
        ],
    ),
)

print(response.text)
# Example response:
# 'The next total solar eclipse in the United States will occur on ...'

REST

将以下变量替换为值:

  • PROJECT_NUMBER:您的项目编号。
  • LOCATION:您的区域。
  • TEXT:您的提示。
  curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -H "x-server-timeout: 60" http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/publishers/google/models/gemini-2.0-flash:generateContent -d '
  {
    "contents": [{
      "role": "user",
      "parts": [{
        "text": TEXT
      }]
    }],
    "tools": [{
      "enterpriseWebSearch": {
      }
    }]
  }
  '

后续步骤

  • 如需详细了解如何使用您的数据为 Gemini 模型建立依据,请参阅使用您的数据建立依据
  • 如需详细了解 Responsible AI 最佳实践和 Vertex AI 的安全过滤条件,请参阅 Responsible AI