企業版網站資料來源

本頁說明企業法規遵循控制項的網頁基礎功能,以及如何使用企業適用的網頁基礎 API,根據網頁內容生成回應。編入索引的內容是 Google 搜尋提供的內容子集,適合金融、醫療照護和公部門等嚴格管制產業的客戶。

如果不需要法規遵循控管項,請使用「以 Google 搜尋結果為依據」,因為這項功能可存取更廣泛的網路索引。

總覽

企業版網頁基礎功能會使用網頁索引來生成有依據的回覆。這項服務不會記錄客戶資料,且支援 VPC Service Controls。 由於系統不會保留任何客戶資料,因此不適用客戶自行管理加密金鑰 (CMEK) 和資料存取透明化控管機制 (AxT)。

使用 API

本節提供使用 Vertex AI 上的 Generative AI API Gemini 2,透過 Gemini 建立有根據回覆的範例要求。如要使用這個 API,請務必設定下列欄位:

  • Contents.parts.text:使用者要傳送至 API 的文字查詢。
  • tools.enterpriseWebSearch:提供這項工具後,Gemini 就能使用 Web Grounding for Enterprise。

Python

安裝

pip install --upgrade google-genai

詳情請參閱 SDK 參考說明文件

設定環境變數,透過 Vertex AI 使用 Gen AI SDK:

# 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" https://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": {
      }
    }]
  }
  '

後續步驟