本頁詳細說明如何設定 AlloyDB for PostgreSQL 與 Gemini Enterprise Agent Platform 的整合,讓您發出查詢,將資料傳遞至 Agent Platform 模型。
以下操作說明適用於 AlloyDB,而非 AlloyDB Omni。如要改用 Agent Platform 整合本機安裝的 AlloyDB Omni,請參閱「使用 AlloyDB AI 安裝 AlloyDB Omni」。
如要進一步瞭解如何搭配使用 AlloyDB 與 ML 模型,請參閱「使用 AlloyDB AI 建構生成式 AI 應用程式」。
如要進一步瞭解 Agent Platform,請參閱「Agent Platform 總覽」。
事前準備
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
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.
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.-
安裝 Google Cloud CLI。
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
執行下列指令,初始化 gcloud CLI:
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.
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.-
安裝 Google Cloud CLI。
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
執行下列指令,初始化 gcloud CLI:
gcloud init
關於 AlloyDB 服務代理
將 AlloyDB 與其他 Google Cloud 服務搭配使用時,AlloyDB 會使用 Identity and Access Management (IAM) 服務代理程式,向這些服務進行驗證。這項服務代理是 AlloyDB 控制的 IAM 主體。您可將 IAM 角色授予這個服務代理,允許該代理代表您存取其他 Google Cloud 服務。
將 Vertex AI User 角色授予 AlloyDB 服務代理
如要啟用資料庫與 Agent Platform 的整合功能,請將 Vertex AI User 角色授予 AlloyDB 服務代理程式。這樣一來,AlloyDB 服務代理程式就能代表您存取 Agent Platform。
請按照下列步驟,將 Vertex AI User 角色授予 AlloyDB 服務代理:
為 AlloyDB 資料庫叢集所在專案的 AlloyDB 服務代理人新增 Agent Platform 權限:
控制台
前往 Google Cloud 控制台的「Welcome」(歡迎使用) 頁面,然後複製含有 AlloyDB 集群或執行個體的專案編號。您將在後續步驟中使用這個專案編號。
前往 Google Cloud 控制台的「IAM」(身分與存取權管理) 頁面。
選取需要呼叫 Agent Platform 端點的專案。
啟用「包含 Google 提供的角色授權」。
按一下 「授予存取權」。
在「New principals」(新增主體) 欄位中輸入下列內容:
service-PROJECT_NUMBER@gcp-sa-alloydb.iam.gserviceaccount.com將 PROJECT_NUMBER 替換為專案編號。
在「Role」欄位中,輸入「Vertex AI User」。
按一下 [儲存]。
gcloud
如要使用 gcloud CLI,可以安裝並初始化 Google Cloud CLI,也可以使用 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"
更改下列內容:
- PROJECT_ID:具有 Agent Platform 端點的專案 ID。
- PROJECT_NUMBER:含有 AlloyDB 叢集或執行個體的專案編號。
確認已安裝擴充功能
確認 google_ml_integration 是否已安裝在包含要執行預測資料的資料庫中:
控制台
前往 Google Cloud 控制台的「Clusters」(叢集) 頁面。
如要顯示叢集「總覽」頁面,請按一下「資源名稱」欄中的 AlloyDB 叢集名稱。
按一下導覽選單中的「AlloyDB Studio」。
在「Sign in to AlloyDB Studio」(登入 AlloyDB Studio) 頁面,使用資料庫名稱、使用者名稱和密碼驗證身分。
在「Editor 1」(編輯器 1) 分頁中,完成下列步驟:
確認已安裝
google_ml_integration擴充功能 1.4.2 以上版本:SELECT extversion FROM pg_extension WHERE extname = 'google_ml_integration';
按一下「執行」。等待「結果」窗格顯示擴充功能版本。
psql
將
psql用戶端連線至叢集的主要執行個體,如「將psql用戶端連線至執行個體」一文所述。在
psql命令提示字元中,連線至資料庫:\c DB_NAME
將
DB_NAME替換為要安裝擴充功能的資料庫名稱。確認已安裝
google_ml_integration擴充功能 1.4.2 以上版本:SELECT extversion FROM pg_extension WHERE extname = 'google_ml_integration';