Mengintegrasikan dengan Platform Agen

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

  1. 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.
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Agent Platform API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. To initialize the gcloud CLI, run the following command:

    gcloud init
  8. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  9. Verify that billing is enabled for your Google Cloud project.

  10. Enable the Agent Platform API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. 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

  1. 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.

    Buka Selamat Datang

  2. Di Google Cloud konsol, buka halaman IAM.

    Buka IAM

  3. Pilih project yang perlu memanggil endpoint Agent Platform.

  4. Aktifkan Include Google-provided role grants.

  5. Klik Grant Access.

  6. Di kolom New principals, masukkan hal berikut:

        service-PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.com
        

    Ganti PROJECT_NUMBER dengan nomor project.

  7. Di kolom Role, masukkan Vertex AI User.

  8. 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

  1. Di Google Cloud konsol, buka halaman Clusters.

    Buka Cluster

  2. Untuk menampilkan halaman Overview cluster, klik nama cluster AlloyDB di kolom Resource name.

  3. Di menu navigasi, klik AlloyDB Studio.

  4. Di halaman Sign in to AlloyDB Studio, lakukan autentikasi menggunakan nama database, nama pengguna, dan sandi Anda.

  5. Di tab Editor 1, selesaikan langkah-langkah berikut:

    1. Verifikasi bahwa ekstensi google_ml_integration versi 1.4.2 atau yang lebih baru telah diinstal:

      SELECT extversion FROM pg_extension WHERE extname = 'google_ml_integration';
    2. Klik Run. Tunggu hingga versi ekstensi ditampilkan di panel Results.

psql

  1. Hubungkan klien psql ke instance utama cluster, seperti yang dijelaskan dalam Menghubungkan klien psql ke instance.

  2. Di command prompt psql, hubungkan ke database:

    \c DB_NAME

    Ganti DB_NAME dengan nama database tempat Anda ingin menginstal ekstensi.

  3. Verifikasi bahwa ekstensi google_ml_integration versi 1.4.2 atau yang lebih baru telah diinstal:

    SELECT extversion FROM pg_extension WHERE extname = 'google_ml_integration';

Langkah berikutnya