Mengintegrasikan dengan Platform Agen

Dengan mengintegrasikan AlloyDB untuk PostgreSQL dengan Gemini Enterprise Agent Platform, Anda dapat menjalankan kueri SQL yang meneruskan data database secara langsung ke model Agent Platform untuk pembuatan embedding dan prediksi online.

Petunjuk ini khusus untuk menggunakan AlloyDB, dan bukan AlloyDB Omni. Untuk mengintegrasikan penginstalan lokal AlloyDB Omni menggunakan Agent Platform, lihat Menginstal AlloyDB Omni dengan AlloyDB AI.

Untuk 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 Google Cloud Anda. 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 Google Cloud lain, 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 ke agen layanan ini agar dapat mengakses layanan Google Cloud lain atas nama Anda.

Memberikan peran Vertex AI User ke agen layanan AlloyDB

Untuk mengaktifkan integrasi database dengan Agent Platform, berikan peran Vertex AI User kepada agen layanan AlloyDB. Tindakan 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 konsol Google Cloud , lalu salin nomor project dari project yang memiliki cluster atau instance AlloyDB. Anda akan menggunakan nomor project ini di langkah berikutnya.

    Buka Sambutan

  2. Di konsol Google Cloud , buka halaman IAM.

    Buka IAM

  3. Pilih project yang perlu memanggil endpoint Agent Platform.

  4. Aktifkan Include Google-provided role grants.

  5. Klik Berikan Akses.

  6. Di kolom New principals, masukkan berikut ini:

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

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 dari project yang memiliki cluster atau instance AlloyDB.

Memverifikasi ekstensi yang diinstal

Pastikan google_ml_integration telah diinstal di database yang berisi data yang ingin Anda jalankan prediksinya:

Konsol

  1. Di konsol Google Cloud , 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. Pastikan 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. Pastikan 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