Mengintegrasikan AlloyDB untuk PostgreSQL dengan Gemini Enterprise Agent Platform memungkinkan Anda menjalankan kueri SQL yang meneruskan data database Anda langsung ke model Agent Platform untuk pembuatan embedding dan prediksi online.
Petunjuk ini khusus untuk menggunakan AlloyDB, bukan AlloyDB Omni. Untuk mengintegrasikan penginstalan lokal AlloyDB Omni menggunakan Agent Platform, lihat Menginstal AlloyDB Omni dengan AlloyDB AI.
Untuk mengetahui informasi selengkapnya tentang penggunaan model ML dengan AlloyDB, lihat Membangun aplikasi AI generatif menggunakan AlloyDB AI.
Untuk mengetahui informasi selengkapnya tentang Agent Platform, lihat Ringkasan Agent Platform.
Sebelum memulai
- Login ke akun Anda. Google Cloud Jika Anda baru menggunakan Google Cloud, buat akun untuk mengevaluasi performa produk kami dalam skenario dunia nyata. Pelanggan baru juga mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Agent Platform API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Agent Platform API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
Tentang agen layanan AlloyDB
Saat Anda menggunakan AlloyDB dengan layanan lain Google Cloud , AlloyDB menggunakan agen layanan Identity and Access Management (IAM) untuk melakukan autentikasi ke layanan tersebut. Agen layanan ini adalah akun utama IAM yang dikontrol oleh AlloyDB. Anda memberikan peran IAM kepada agen layanan ini agar dapat mengakses layanan Google Cloud lain atas nama Anda.
Memberikan peran Vertex AI User kepada agen layanan AlloyDB
Untuk mengaktifkan integrasi database dengan Agent Platform, Anda memberikan peran Vertex AI User kepada agen layanan AlloyDB. Hal ini memungkinkan agen layanan AlloyDB mengakses Agent Platform atas nama Anda.
Ikuti langkah-langkah berikut untuk memberikan peran Vertex AI User kepada agen layanan AlloyDB:
Tambahkan izin Agent Platform ke agen layanan AlloyDB untuk project tempat cluster database AlloyDB berada:
Konsol
Buka halaman Welcome di Google Cloud konsol, lalu salin nomor project yang memiliki cluster atau instance AlloyDB. Anda akan menggunakan nomor project ini pada langkah berikutnya.
Di Google Cloud konsol, buka halaman IAM.
Pilih project yang perlu memanggil endpoint Agent Platform.
Aktifkan Include Google-provided role grants.
Klik Grant Access.
Di kolom New principals, masukkan hal berikut:
service-PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.comGanti PROJECT_NUMBER dengan nomor project.
Di kolom Role, masukkan Vertex AI User.
Klik Save.
gcloud
Untuk menggunakan gcloud CLI, Anda dapat menginstal dan melakukan inisialisasi Google Cloud CLI, atau Anda dapat menggunakan Cloud Shell.
gcloud projects add-iam-policy-binding PROJECT_ID
--member="serviceAccount:service-PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.com"
--role="roles/aiplatform.user"
Ganti kode berikut:
- PROJECT_ID: ID project yang memiliki endpoint Agent Platform.
- PROJECT_NUMBER: Nomor project yang memiliki cluster atau instance AlloyDB.
Memverifikasi ekstensi yang diinstal
Verifikasi apakah google_ml_integration diinstal di database yang berisi data yang ingin Anda gunakan untuk menjalankan prediksi:
Konsol
Di Google Cloud konsol, buka halaman Clusters.
Untuk menampilkan halaman Overview cluster, klik nama cluster AlloyDB di kolom Resource name.
Di menu navigasi, klik AlloyDB Studio.
Di halaman Sign in to AlloyDB Studio, lakukan autentikasi menggunakan nama database, nama pengguna, dan sandi Anda.
Di tab Editor 1, selesaikan langkah-langkah berikut:
Verifikasi bahwa ekstensi
google_ml_integrationversi 1.4.2 atau yang lebih baru telah diinstal:SELECT extversion FROM pg_extension WHERE extname = 'google_ml_integration';
Klik Run. Tunggu hingga versi ekstensi ditampilkan di panel Results.
psql
Hubungkan klien
psqlke instance utama cluster, seperti yang dijelaskan dalam Menghubungkan klienpsqlke instance.Di command prompt
psql, hubungkan ke database:\c DB_NAME
Ganti
DB_NAMEdengan nama database tempat Anda ingin menginstal ekstensi.Verifikasi bahwa ekstensi
google_ml_integrationversi 1.4.2 atau yang lebih baru telah diinstal:SELECT extversion FROM pg_extension WHERE extname = 'google_ml_integration';