1. 簡介
在本程式碼實驗室中,您將瞭解如何結合向量搜尋和 Gemini Enterprise Agent Platform 嵌入,使用 PostgreSQL 適用的 Cloud SQL AI 整合功能。

必要條件
- 對 Google Cloud 和 Google Cloud 控制台有基本瞭解
- 熟悉指令列介面和 Cloud Shell 的基本操作
學習內容
- 部署 PostgreSQL 適用的 Cloud SQL 執行個體
- 建立資料庫並啟用 Cloud SQL AI 整合
- 將資料載入資料庫
- 使用 Cloud SQL Studio
- 在 Cloud SQL 中使用 Gemini Enterprise Agent Platform 生成嵌入
- 使用 Agent Platform Studio
- 使用 Gemini Enterprise Agent Platform 生成模型豐富查詢結果
- 使用 HNSW 向量索引提升查詢效能
軟硬體需求
- Google Cloud 帳戶和 Google Cloud 專案
- 網路瀏覽器,例如 Chrome
2. 設定和需求條件
專案設定
- 登入 Google Cloud 控制台。如果沒有 Google 帳戶 (Gmail 或 Google Workspace),請建立 Google 帳戶。
請改用個人帳戶,而非公司或學校帳戶。
- 建立新專案或重複使用現有專案。如要在 Google Cloud 控制台中建立新專案,請按一下工具列中的「選取專案」。

在「選取專案」對話方塊中,按一下「New Project」(新增專案)。

在對話方塊中輸入「專案名稱」,然後選取「位置」。

- 專案名稱是這個專案參與者的顯示名稱。Google API 不會使用專案名稱,且專案名稱隨時可以變更。
- 專案 ID 在所有 Google Cloud 專案中不得重複,且設定後即無法變更。Google Cloud 控制台會自動產生專屬 ID,但您可以自訂。如果不喜歡系統產生的 ID,可以產生另一個隨機 ID,或提供自己的 ID 並檢查是否可用。在大多數程式碼研究室中,您會參照專案 ID,通常是以
預留位置識別。 - 部分 API 會使用第三個值,也就是「專案編號」。如要進一步瞭解這三個值,請參閱「建立及管理專案」說明文件。
啟用計費功能
設定個人帳單帳戶
如果使用 Google Cloud 抵免額設定帳單,可以略過這個步驟。
如要設定個人帳單帳戶,請在 Google Cloud Billing 控制台中啟用帳單功能。
注意:
- 完成本實驗室的 Google Cloud 資源費用不到 $5 美元。
- 請按照本實驗室結尾的步驟刪除資源,避免產生額外費用。
- 新使用者可享有價值 $300 美元的免費試用期。
啟動 Cloud Shell
您可以透過電腦遠端操作 Google Cloud,但本程式碼實驗室會使用 Google Cloud Shell,這是雲端執行的指令列環境。
在 Google Cloud 控制台工具列中,點選「啟用 Cloud Shell」:

或者,您也可以在 Google Cloud 控制台中依序按下 g 和 s 鍵,或開啟 Cloud Shell。
佈建並連線至環境的作業,應該很快就能完成。完成後,您應該會看到已連線的終端機:

這個虛擬機器已預先安裝所有必要的開發工具,並提供永久的 5 GB 主目錄,而且可在 Google Cloud 運作,提升網路效能並強化驗證功能。您可以在瀏覽器中完成本程式碼研究室的所有作業。
3. 啟用 API
如要使用 Cloud SQL、Compute Engine、Service Networking 和 Gemini Enterprise Agent Platform,請在 Google Cloud 雲端專案中啟用各自的 API。
在 Cloud Shell 終端機中,確認專案 ID 已設定完畢:
gcloud config set project <PROJECT_ID>
設定 PROJECT_ID 環境變數:
PROJECT_ID=$(gcloud config get-value project)
啟用所有必要服務:
gcloud services enable sqladmin.googleapis.com \
compute.googleapis.com \
cloudresourcemanager.googleapis.com \
servicenetworking.googleapis.com \
aiplatform.googleapis.com
預期輸出內容:
student@cloudshell:~ (test-project-001-402417)$ gcloud config set project test-project-001-402417
Updated property [core/project].
student@cloudshell:~ (test-project-001-402417)$ PROJECT_ID=$(gcloud config get-value project)
Your active configuration is: [cloudshell-14650]
student@cloudshell:~ (test-project-001-402417)$
student@cloudshell:~ (test-project-001-402417)$ gcloud services enable sqladmin.googleapis.com \
compute.googleapis.com \
cloudresourcemanager.googleapis.com \
servicenetworking.googleapis.com \
aiplatform.googleapis.com
Operation "operations/acat.p2-4470404856-1f44ebd8-894e-4356-bea7-b84165a57442" finished successfully.
如要瞭解各項已啟用的 API,請參閱說明文件。
4. 建立 Cloud SQL 執行個體
建立與 Gemini Enterprise Agent Platform 資料庫整合的 Cloud SQL 執行個體。
建立資料庫密碼
定義預設資料庫使用者的密碼。您可以自行定義密碼,也可以使用隨機函式產生密碼:
export CLOUDSQL_PASSWORD=$(openssl rand -hex 16)
顯示產生的密碼值:
echo $CLOUDSQL_PASSWORD
請記下產生的密碼,稍後會用到。
建立 PostgreSQL 適用的 Cloud SQL 執行個體
您可以使用多種方法建立 Cloud SQL 執行個體,包括 Google Cloud 控制台、Terraform 或 Google Cloud CLI (gcloud)。在本程式碼研究室中,您將使用 gcloud。如要瞭解如何使用其他工具建立執行個體,請參閱「建立執行個體」說明文件。
在 Cloud Shell 中執行下列指令,建立執行個體:
gcloud sql instances create my-cloudsql-instance \
--database-version=POSTGRES_18 \
--tier=db-custom-1-3840 \
--region=us-central1 \
--edition=ENTERPRISE \
--enable-google-ml-integration \
--database-flags cloudsql.enable_google_ml_integration=on
建立執行個體後,請為預設使用者 (postgres) 設定密碼,並確認您可以連線:
gcloud sql users set-password postgres \
--instance=my-cloudsql-instance \
--password=$CLOUDSQL_PASSWORD
使用 gcloud sql connect 連線至執行個體。系統提示時,請輸入密碼:
gcloud sql connect my-cloudsql-instance --user=postgres
按下 Ctrl+D 或輸入 exit,即可結束 psql 工作階段:
exit
啟用 Gemini Enterprise Agent Platform 整合功能
將必要的 IAM 角色授予 Cloud SQL 服務帳戶,以啟用 Gemini Enterprise Agent Platform 整合。
擷取 Cloud SQL 服務帳戶電子郵件地址,並匯出為環境變數:
SERVICE_ACCOUNT_EMAIL=$(gcloud sql instances describe my-cloudsql-instance --format="value(serviceAccountEmailAddress)")
echo $SERVICE_ACCOUNT_EMAIL
將 roles/aiplatform.user 角色授予 Cloud SQL 服務帳戶:
PROJECT_ID=$(gcloud config get-value project)
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_EMAIL" \
--role="roles/aiplatform.user"
如要進一步瞭解如何建立及設定執行個體,請參閱「整合 Cloud SQL 與 Gemini Enterprise Agent Platform」。
5. 準備資料庫
建立資料庫並啟用向量支援功能。
建立資料庫
建立名為 quickstart_db 的資料庫。您可以使用資料庫用戶端 (例如 psql)、Google Cloud CLI 或 Cloud SQL Studio 建立資料庫。在這個步驟中,請使用 gcloud。
在 Cloud Shell 中執行下列指令,建立資料庫:
gcloud sql databases create quickstart_db --instance=my-cloudsql-instance
啟用擴充功能
如要使用 Gemini Enterprise Agent Platform 和向量,請在 quickstart_db 資料庫中啟用 google_ml_integration 和 vector 這兩項擴充功能。
在 Cloud Shell 中連線至資料庫:
gcloud sql connect my-cloudsql-instance --database quickstart_db --user=postgres
按照系統提示輸入資料庫密碼。
在 SQL 工作階段中,執行下列指令:
CREATE EXTENSION IF NOT EXISTS google_ml_integration CASCADE;
CREATE EXTENSION IF NOT EXISTS vector CASCADE;
結束 SQL 工作階段:
exit;
6. 載入資料
在資料庫中建立資料表,並使用以 CSV 格式儲存在公開 Cloud Storage bucket 中的虛構 Cymbal Store 資料集檔案載入資料。
首先,請建立必要的結構定義物件。執行 gcloud sql connect 和 gcloud storage,下載並匯入結構定義:
在 Cloud Shell 中執行下列指令 (系統提示時,請輸入為執行個體建立的密碼):
gcloud storage cat gs://cloud-training/gcc/gcc-tech-004/cymbal_demo_schema.sql | gcloud sql connect my-cloudsql-instance --database quickstart_db --user=postgres
這項指令會連線至資料庫,並執行下載的 SQL 程式碼,建立資料表、索引和序列。
接著,從 Cloud Storage 下載 CSV 資料檔案:
gcloud storage cp gs://cloud-training/gcc/gcc-tech-004/cymbal_products.csv .
gcloud storage cp gs://cloud-training/gcc/gcc-tech-004/cymbal_inventory.csv .
gcloud storage cp gs://cloud-training/gcc/gcc-tech-004/cymbal_stores.csv .
連線至資料庫:
gcloud sql connect my-cloudsql-instance --database quickstart_db --user=postgres
從 CSV 檔案匯入資料:
\copy cymbal_products from 'cymbal_products.csv' csv header
\copy cymbal_inventory from 'cymbal_inventory.csv' csv header
\copy cymbal_stores from 'cymbal_stores.csv' csv header
如果您使用自有資料,且 CSV 檔案與 Google Cloud 控制台的 Cloud SQL 匯入工具相容,則可使用控制台,不必透過指令列操作。
7. 建立嵌入
使用 Gemini Enterprise Agent Platform 的 text-embedding-005 模型,為產品說明建立嵌入,並以向量資料形式儲存。
如果工作階段已中斷連線,請連線至資料庫:
gcloud sql connect my-cloudsql-instance --database quickstart_db --user=postgres
使用 embedding 函式,在 cymbal_products 資料表中建立名為 embedding 的產生資料欄。這項指令會建立儲存的產生資料欄,其中包含資料表中所有資料列的 product_description 資料欄所產生的向量嵌入。模型會指定為第一個參數,來源文字欄則指定為第二個參數:
ALTER TABLE cymbal_products ADD COLUMN embedding vector(768) GENERATED ALWAYS AS (google_ml.embedding('text-embedding-005', product_description)) STORED;
如果資料列數介於 900 到 1000 之間,這項程序通常需要 1 到 5 分鐘。
在資料表中插入新資料列,或更新現有資料列的 product_description 時,embedding 欄會自動更新。
8. 執行相似度搜尋
比較產品說明計算出的向量嵌入與搜尋查詢的嵌入,執行相似度搜尋。
您可以使用 gcloud sql connect 從指令列執行 SQL 查詢,也可以透過 Cloud SQL Studio 執行。Cloud SQL Studio 提供更便利的方式,可編輯及執行輸出中有多列的長 SQL 陳述式。
啟動 Cloud SQL Studio

- 按一下導覽選單中的「Cloud SQL Studio」。

- 在驗證對話方塊中,輸入資料庫名稱和憑證:
- 資料庫:
quickstart_db - 使用者:
postgres - 密碼:
- 資料庫:
- 按一下「Authenticate」(驗證)。

- 按一下「編輯器」分頁標籤,開啟 SQL 編輯器。

執行查詢
執行查詢,擷取與顧客查詢最相關的前 10 項產品:「這裡適合種植哪種果樹?」
SELECT
cp.product_name,
left(cp.product_description,80) as description,
cp.sale_price,
cs.zip_code,
(cp.embedding <=> embedding('text-embedding-005','What kind of fruit trees grow well here?')::vector) as distance
FROM
cymbal_products cp
JOIN cymbal_inventory ci on
ci.uniq_id=cp.uniq_id
JOIN cymbal_stores cs on
cs.store_id=ci.store_id
AND ci.inventory>0
AND cs.store_id = 1583
ORDER BY
distance ASC
LIMIT 10;
在 Cloud SQL Studio 中輸入查詢,然後點選「執行」 (或在 psql 工作階段中執行查詢):

查詢會傳回依餘弦距離排序的相符產品:
product_name | description | sale_price | zip_code | distance -------------------------+----------------------------------------------------------------------------------+------------+----------+--------------------- Cherry Tree | This is a beautiful cherry tree that will produce delicious cherries. It is an d | 75.00 | 93230 | 0.43922018972266397 Meyer Lemon Tree | Meyer Lemon trees are California's favorite lemon tree! Grow your own lemons by | 34 | 93230 | 0.4685112926118228 Toyon | This is a beautiful toyon tree that can grow to be over 20 feet tall. It is an e | 10.00 | 93230 | 0.4835677149651668 California Lilac | This is a beautiful lilac tree that can grow to be over 10 feet tall. It is an d | 5.00 | 93230 | 0.4947204525907498 California Peppertree | This is a beautiful peppertree that can grow to be over 30 feet tall. It is an e | 25.00 | 93230 | 0.5054166905547247 California Black Walnut | This is a beautiful walnut tree that can grow to be over 80 feet tall. It is a d | 100.00 | 93230 | 0.5084219510932597 California Sycamore | This is a beautiful sycamore tree that can grow to be over 100 feet tall. It is | 300.00 | 93230 | 0.5140519790508755 Coast Live Oak | This is a beautiful oak tree that can grow to be over 100 feet tall. It is an ev | 500.00 | 93230 | 0.5143126438081371 Fremont Cottonwood | This is a beautiful cottonwood tree that can grow to be over 100 feet tall. It i | 200.00 | 93230 | 0.5174774727252058 Madrone | This is a beautiful madrona tree that can grow to be over 80 feet tall. It is an | 50.00 | 93230 | 0.5227400803389093 (10 rows)
9. 使用檢索到的資料提升 LLM 回覆品質
將查詢結果做為提示中的基礎內容,傳遞至 Gemini Enterprise Agent Platform 基礎語言模型,藉此改善用戶端應用程式的生成式 AI 回覆。
為了達到這個目的:
- 從 Cloud SQL 的向量搜尋結果產生 JSON 酬載。
- 在 Agent Platform Studio 測試提示。
- 使用
google_ml整合功能,直接從 SQL 執行端對端提示。
以 JSON 格式產生輸出內容
修改查詢,將結果格式設為 JSON 並傳回一列:
WITH trees as (
SELECT
cp.product_name,
left(cp.product_description,80) as description,
cp.sale_price,
cs.zip_code,
cp.uniq_id as product_id
FROM
cymbal_products cp
JOIN cymbal_inventory ci on
ci.uniq_id=cp.uniq_id
JOIN cymbal_stores cs on
cs.store_id=ci.store_id
AND ci.inventory>0
AND cs.store_id = 1583
ORDER BY
(cp.embedding <=> embedding('text-embedding-005','What kind of fruit trees grow well here?')::vector) ASC
LIMIT 1)
SELECT json_agg(trees) FROM trees;
預期的 JSON 輸出內容:
[{"product_name":"Cherry Tree","description":"This is a beautiful cherry tree that will produce delicious cherries. It is an d","sale_price":75.00,"zip_code":93230,"product_id":"d536e9e823296a2eba198e52dd23e712"}]
在 Agent Platform Studio 執行提示詞
在 Agent Platform Studio 中,將生成的 JSON 做為提示的背景資訊提供給生成模型。
- 在 Google Cloud 控制台中,開啟 Agent Platform Studio。

- 在 Agent Platform Studio 中輸入下列提示:

You are a friendly advisor helping to find a product based on the customer's needs.
Based on the client request we have loaded a list of products closely related to search.
The list in JSON format with list of values like {"product_name":"name","description":"some description","sale_price":10,"zip_code": 10234, "product_id": "02056727942aeb714dc9a2313654e1b0"}
Here is the list of products:
<JSON_OUTPUT>
The customer asked "What tree is growing the best here?"
You should give information about the product, price and some supplemental information.
Do not ask any additional questions and assume location based on the zip code provided in the list of products.
將 替換為查詢傳回的 JSON 回應:
You are a friendly advisor helping to find a product based on the customer's needs.
Based on the client request we have loaded a list of products closely related to search.
The list in JSON format with list of values like {"product_name":"name","description":"some description","sale_price":10,"zip_code": 10234, "product_id": "02056727942aeb714dc9a2313654e1b0"}
Here is the list of products:
[{"product_name":"Cherry Tree","description":"This is a beautiful cherry tree that will produce delicious cherries. It is an d","sale_price":75.00,"zip_code":93230,"product_id":"d536e9e823296a2eba198e52dd23e712"}]
The customer asked "What tree is growing the best here?"
You should give information about the product, price and some supplemental information.
Do not ask any additional questions and assume location based on the zip code provided in the list of products.

- 然後輸入提示詞。

答案會包含價格、說明,以及模型根據樹木和地點資訊從外部來源取得的補充資訊。
在 psql 中執行提示
您也可以使用 Cloud SQL AI 整合 Gemini Enterprise Agent Platform,直接在 SQL 中取得生成模型的相關回應。首先,註冊模型。
- 如有需要,請將擴充功能升級至 1.4.3 以上版本。連線至
quickstart_db並執行:
SELECT extversion from pg_extension where extname='google_ml_integration';
如果傳回的版本低於 1.4.3,請執行下列指令:
ALTER EXTENSION google_ml_integration UPDATE TO '1.4.3';
- 檢查
google_ml_integration.enable_model_support資料庫旗標:
SHOW google_ml_integration.enable_model_support;
如果旗標為 off,請在 Cloud Shell 中更新資料庫旗標:
gcloud sql instances patch my-cloudsql-instance \
--database-flags google_ml_integration.enable_model_support=on,cloudsql.enable_google_ml_integration=on
這項作業需要 1 到 3 分鐘才能完成。再次驗證設定:
SHOW google_ml_integration.enable_model_support;
- 註冊
gemini-3.5-flash模型以產生回覆 (將替換為專案 ID):
CALL
google_ml.create_model(
model_id => 'gemini-3.5-flash',
model_request_url => 'https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/global/publishers/google/models/gemini-3.5-flash:generateContent',
model_provider => 'google',
model_auth_type => 'cloudsql_service_agent_iam');
驗證已註冊的型號:
SELECT model_id, model_type FROM google_ml.model_info_view WHERE model_id='gemini-3.5-flash';
- 執行完整的 SQL 查詢,擷取向量搜尋結果並直接傳遞至
gemini-3.5-flash:
WITH trees AS (
SELECT
cp.product_name,
cp.product_description AS description,
cp.sale_price,
cs.zip_code,
cp.uniq_id AS product_id
FROM
cymbal_products cp
JOIN cymbal_inventory ci ON
ci.uniq_id = cp.uniq_id
JOIN cymbal_stores cs ON
cs.store_id = ci.store_id
AND ci.inventory>0
AND cs.store_id = 1583
ORDER BY
(cp.embedding <=> embedding('text-embedding-005',
'What kind of fruit trees grow well here?')::vector) ASC
LIMIT 1),
prompt AS (
SELECT
'You are a friendly advisor helping to find a product based on the customer''s needs.
Based on the client request we have loaded a list of products closely related to search.
The list in JSON format with list of values like {"product_name":"name","product_description":"some description","sale_price":10}
Here is the list of products:' || json_agg(trees) || 'The customer asked "What kind of fruit trees grow well here?"
You should give information about the product, price and some supplemental information' AS prompt_text
FROM
trees),
response AS (
SELECT
google_ml.predict_row( model_id =>'gemini-3.5-flash',
request_body => json_build_object('contents',
json_build_object('role',
'user',
'parts',
json_build_object('text',
prompt_text))))->'candidates'->0->'content'->'parts'->0->'text' AS resp
FROM
prompt)
SELECT
REPLACE(resp::text, '\n', CHR(10))
FROM
response;
預期輸出內容:
"Hello there! If you're looking for a wonderful fruit tree to plant, I have a fantastic option for you: ### **Cherry Tree** * **Price:** $75.00 * **Product ID:** `d536e9e823296a2eba198e52dd23e712` --- ### **Why it's a great choice:** * **Fruit & Shade:** Not only will it produce delicious, sweet cherries, but it also grows into a beautiful 15-foot deciduous tree that provides excellent shade and privacy for your yard. * **Seasonal Beauty:** Its leaves are a lovely dark green throughout the summer and transition into a striking red during the fall. * **Ideal Growing Conditions:** Cherry trees thrive best in cool, moist climates with sandy soil and are suitable for **USDA hardiness zones 4–9**. If your local climate matches these conditions, this Cherry Tree would make a beautiful and tasty addition to your garden! Let me know if you'd like more details or help placing an order."
10. 建立最近鄰索引
如果資料集包含數百萬個向量,向量搜尋可能需要大量運算資源。如要提高查詢效能,請在向量嵌入上建立索引。
建立 HNSW 索引
階層式可導覽小世界 (HNSW) 是以圖表為基礎的向量索引。
如要在 embedding 欄上建構 HNSW 索引,請指定距離函式 (vector_cosine_ops) 和選用參數,例如 m 和 ef_construction。詳情請參閱「使用向量嵌入」。
CREATE INDEX cymbal_products_embeddings_hnsw ON cymbal_products
USING hnsw (embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 64);
預期輸出內容:
quickstart_db=> CREATE INDEX cymbal_products_embeddings_hnsw ON cymbal_products USING hnsw (embedding vector_cosine_ops) WITH (m = 16, ef_construction = 64); CREATE INDEX quickstart_db=>
比較查詢效能
使用 EXPLAIN (ANALYZE) 執行向量搜尋查詢,確認查詢規劃工具使用索引:
EXPLAIN (ANALYZE)
WITH trees as (
SELECT
cp.product_name,
left(cp.product_description,80) as description,
cp.sale_price,
cs.zip_code,
cp.uniq_id as product_id
FROM
cymbal_products cp
JOIN cymbal_inventory ci on
ci.uniq_id=cp.uniq_id
JOIN cymbal_stores cs on
cs.store_id=ci.store_id
AND ci.inventory>0
AND cs.store_id = 1583
ORDER BY
(cp.embedding <=> embedding('text-embedding-005','What kind of fruit trees grow well here?')::vector) ASC
LIMIT 1)
SELECT json_agg(trees) FROM trees;
預期輸出內容:
Aggregate (cost=779.12..779.13 rows=1 width=32) (actual time=1.066..1.069 rows=1 loops=1)
-> Subquery Scan on trees (cost=769.05..779.12 rows=1 width=142) (actual time=1.038..1.041 rows=1 loops=1)
-> Limit (cost=769.05..779.11 rows=1 width=158) (actual time=1.022..1.024 rows=1 loops=1)
-> Nested Loop (cost=769.05..9339.69 rows=852 width=158) (actual time=1.020..1.021 rows=1 loops=1)
-> Nested Loop (cost=768.77..9316.48 rows=852 width=945) (actual time=0.858..0.859 rows=1 loops=1)
-> Index Scan using cymbal_products_embeddings_hnsw on cymbal_products cp (cost=768.34..2572.47 rows=941 width=941) (actual time=0.532..0.539 rows=3 loops=1)
...
Planning Time: 112.398 ms
Execution Time: 1.221 ms
執行計畫會顯示 Index Scan using cymbal_products_embeddings_hnsw。
直接執行查詢,不使用「EXPLAIN」:
WITH trees as (
SELECT
cp.product_name,
left(cp.product_description,80) as description,
cp.sale_price,
cs.zip_code,
cp.uniq_id as product_id
FROM
cymbal_products cp
JOIN cymbal_inventory ci on
ci.uniq_id=cp.uniq_id
JOIN cymbal_stores cs on
cs.store_id=ci.store_id
AND ci.inventory>0
AND cs.store_id = 1583
ORDER BY
(cp.embedding <=> embedding('text-embedding-005','What kind of fruit trees grow well here?')::vector) ASC
LIMIT 1)
SELECT json_agg(trees) FROM trees;
預期輸出內容:
[{"product_name":"Cherry Tree","description":"This is a beautiful cherry tree that will produce delicious cherries. It is an d","sale_price":75.00,"zip_code":93230,"product_id":"d536e9e823296a2eba198e52dd23e712"}]
如要進一步瞭解 LangChain 和向量索引,請參閱 Cloud SQL AI 總覽說明文件。
11. 清理資源
完成程式碼研究室後,請刪除 Cloud SQL 執行個體。
如果工作階段中斷,請在 Cloud Shell 中設定專案和環境變數:
export INSTANCE_NAME=my-cloudsql-instance
export PROJECT_ID=$(gcloud config get-value project)
刪除執行個體:
gcloud sql instances delete $INSTANCE_NAME --project=$PROJECT_ID
預期輸出內容:
student@cloudshell:~$ gcloud sql instances delete $INSTANCE_NAME --project=$PROJECT_ID All of the instance data will be lost when the instance is deleted. Do you want to continue (Y/n)? y Deleting Cloud SQL instance...done. Deleted [https://sandbox.googleapis.com/v1beta4/projects/test-project-001-402417/instances/my-cloudsql-instance].
12. 恭喜
恭喜!您已完成程式碼研究室。
這個實驗室屬於「Google Cloud 學習路徑:打造可用於正式環境的 AI」的一部分。
- 探索完整課程,從設計原型開始,一步步把專案投入正式環境。
- 使用主題標記
#ProductionReadyAI分享進度。
摘要
您學到了下列內容:
- 部署 PostgreSQL 適用的 Cloud SQL 執行個體
- 建立資料庫並啟用 Cloud SQL AI 整合
- 將資料載入資料庫
- 使用 Cloud SQL Studio
- 在 Cloud SQL 中使用 Gemini Enterprise Agent Platform 嵌入模型
- 使用 Agent Platform Studio
- 使用 Gemini Enterprise Agent Platform 生成模型豐富查詢結果
- 使用向量索引提升查詢效能
請試試 AlloyDB AI 向量嵌入程式碼實驗室,並使用 ScaNN 索引,而非 HNSW。