Halaman ini menjelaskan kontrol kepatuhan Web Grounding for Enterprise dan cara menggunakan Web Grounding for Enterprise API untuk menghasilkan respons yang di-grounding di web. Konten yang diindeks adalah subset dari konten yang tersedia di Google Penelusuran dan cocok untuk pelanggan di industri yang diatur dengan ketat, seperti keuangan, layanan kesehatan, dan sektor publik.
Jika Anda tidak memerlukan kontrol kepatuhan, gunakan Perujukan dengan Google Penelusuran, karena menawarkan akses ke indeks web yang lebih luas.
Ringkasan
Web Grounding for Enterprise menggunakan indeks web yang digunakan untuk menghasilkan respons yang berisi rujukan. Indeks web mendukung hal berikut:
- Pemrosesan ML di multi-region AS atau Eropa
- Tidak ada logging data pelanggan
- Kontrol Layanan VPC
Karena tidak ada data pelanggan yang dipertahankan, kunci enkripsi yang dikelola pelanggan (CMEK) dan Transparansi Akses (AxT) tidak berlaku.
Menggunakan API
Bagian ini memberikan contoh permintaan penggunaan Generative AI API Gemini 2 di Vertex AI untuk membuat respons yang berdasar dengan Gemini. Untuk menggunakan API, Anda harus menetapkan kolom berikut:
Contents.parts.text
: Kueri teks yang ingin dikirim pengguna ke API.tools.enterpriseWebSearch
: Jika alat ini disediakan, Web Grounding for Enterprise dapat digunakan oleh Gemini.
Pilih contoh kode untuk melihat cara menggunakan API:
Python
Ganti variabel berikut dengan nilai:
PROJECT_NUMBER
: Nomor project Anda.LOCATION
: Region tempat model Anda berjalan.MODEL_NAME
: Model Anda.
import requests
import subprocess
import json
def generate_content_with_gemini():
"""
Sends a request to the Gemini 2.0 Flash model to generate content using Google's AI Platform.
"""
# Replace with your actual project number and model name if different.
project_id = PROJECT_NUMBER
region = LOCATION
model_name = MODEL_NAME # Or the correct model ID, including any version specifier
endpoint = f"https://{region}-aiplatform.googleapis.com/v1/projects/{project_id}/locations/{region}/publishers/google/models/{model_name}:generateContent"
# Get the access token using gcloud. Requires gcloud to be installed and configured.
try:
result = subprocess.run(["gcloud", "auth", "print-access-token"], capture_output=True, text=True, check=True)
access_token = result.stdout.strip()
except subprocess.CalledProcessError as e:
print(f"Error getting access token: {e}")
return None
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
"x-server-timeout": "60" # in seconds
}
data = {
"contents": [{
"role": "user",
"parts": [{
"text": "Who won the 2024 Eurocup?"
}]
}],
"tools": [{
"enterpriseWebSearch": {
}
}]
}
try:
response = requests.post(endpoint, headers=headers, json=data)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
return response.json()
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
# Example usage:
if __name__ == "__main__":
result = generate_content_with_gemini()
if result:
print(json.dumps(result, indent=2))
else:
print("Failed to generate content.")
curl
Ganti variabel berikut dengan nilai:
PROJECT_NUMBER
: Nomor project Anda.TEXT
: Perintah Anda.
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -H "x-server-timeout: 60" https://us-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_NUMBER/locations/eu:generateGroundedContent -d '
{
"contents": [{
"role": "user",
"parts": [{
"text": TEXT
}]
}],
"tools": [{
"enterpriseWebSearch": {
}
}]
}
}
'
Langkah berikutnya
- Untuk mempelajari lebih lanjut cara me-ground model Gemini ke data Anda, lihat Me-ground ke data Anda.
- Untuk mempelajari lebih lanjut praktik terbaik responsible AI dan filter keamanan Vertex AI, lihat Responsible AI.