Troubleshooting of Google Vertex AI Search in Mandarin: Difference between revisions

Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
[https://cloud.google.com/enterprise-search?hl=zh_tw Google Vertex AI Search] API 疑難排解
解決 [https://cloud.google.com/enterprise-search?hl=zh_tw Google Vertex AI Search] 及其 API 的問題


{{LanguageSwitcher | content = [[Troubleshooting of Google Vertex AI API | EN]], [[Troubleshooting of Google Vertex AI API in Mandarin | 漢字]] }}
{{LanguageSwitcher | content = [[Troubleshooting of Google Vertex AI Search | EN]], [[Troubleshooting of Google Vertex AI Search in Mandarin | 漢字]] }}


== 問題 ==
== 問題 ==
Line 123: Line 123:
選項一:增加請求 (request) 之間的延遲時間
選項一:增加請求 (request) 之間的延遲時間


# 在程式碼中實作此延遲時間以避免 429 錯誤,例如:在每次請求之間添加 1 秒的暫停以符合速率限制
# 在程式碼中實作延遲時間,以避免 429 錯誤。60 秒 ÷ 100 個請求 = 每個請求 0.6 秒,例如:在每個請求之間添加 0.6 ~ 1 秒的暫停,以符合速率限制。
# 根據配額和請求模式,動態調整延遲時間
# 根據配額和請求模式,動態調整延遲時間


Line 137: Line 137:
# 每次重試失敗後增加延遲時間(例如 2 秒、4 秒、8 秒等)
# 每次重試失敗後增加延遲時間(例如 2 秒、4 秒、8 秒等)
# 持續重試直到請求成功或達到最大重試次數
# 持續重試直到請求成功或達到最大重試次數
=== 疑難排解:Vertex AI Search: Engine 404 錯誤 ===
'''錯誤:'''
使用 Vertex AI Search API 時,遇到 404 錯誤:
<pre>
{
  "error": {
    "code": 404,
    "message": "Engine projects/<YOUR_PROJECT_ID>/locations/global/collections/default_collection/engines/<YOUR_APP_ID> not found.",
    "status": "NOT_FOUND"
  }
}
</pre>
解決方案:
1. 確認正確的 APP ID (引擎 ID):
開啟瀏覽器,將網址中的 {{kbd | key=<nowiki><YOUR_APP_ID></nowiki>}} 替換為實際的 APP ID:
<pre>
https://console.cloud.google.com/gen-app-builder/locations/global/engines/<YOUR_APP_ID>/overview
</pre>
2. 更新程式碼中的 app_id:
3. 驗證 API 端點:確保 curl 請求使用正確的引擎 ID:
<pre>
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1alpha/projects/<YOUR_PROJECT_ID>/locations/global/collections/default_collection/engines/<YOUR_APP_ID>/servingConfigs/default_search:search" \
-d '{"query":"<QUERY>","pageSize":10,"queryExpansionSpec":{"condition":"AUTO"},"spellCorrectionSpec":{"mode":"AUTO"},"languageCode":"zh-TW","userInfo":{"timeZone":"Asia/Taipei"}}'
</pre>
=== 疑難排解:Vertex AI Search:啟用 Grounding 遇到路徑格式錯誤 ===
「[https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-vertex-ai-search?hl=zh-TW 利用 Vertex AI Search 建立基準]」時遇到錯誤:
'''錯誤訊息:'''
<pre>
路徑必須採用下列格式:
projects/{project_id}/locations/{location}/collections/{collection_name}/dataStores/{datastore_name}
</pre>
'''解決方案:''' 如何找到正確的路徑參數:
# 前往 https://console.cloud.google.com/gen-app-builder/engines
# 選擇要套用的資料儲存庫
# 點擊「整合」分頁
# 查看「在 Cloud Shell 執行範例要求」下方的範例指令
範例 curl 指令:
<pre>
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1alpha/projects/987654321000/locations/global/collections/default_collection/engines/vertex-search_123/servingConfigs/default_search:search" \
-d '{"query":"<QUERY>","pageSize":10,"queryExpansionSpec":{"condition":"AUTO"},"spellCorrectionSpec":{"mode":"AUTO"},"languageCode":"zh-TW","userInfo":{"timeZone":"Asia/Taipei"}}'
</pre>
從 URL 中擷取參數:
{{kbd | key=<nowiki>/projects/987654321000/locations/global/collections/default_collection/engines/vertex-search_123/</nowiki>}}
# {project_id}:`987654321000`(`/projects/` 之後的數字)
# {location}:`global`(`/locations/` 之後的字串){{exclaim}} 注意:請勿輸入 GCP 伺服器的[https://cloud.google.com/compute/docs/regions-zones?hl=zh-tw 地理區域],將會遇到錯誤訊息「Invalid location in serving config: asia-east1」
# {collection_name}:`default_collection`(`/collections/` 之後的字串)
# {datastore_name}:在資料儲存庫總覽頁面顯示為「資料儲存庫 ID」(例如:`XXX_1234567890123`){{exclaim}} 注意:datastore_name 在 engine URL 中找不到,需要到資料儲存庫總覽頁面查看「資料儲存庫 ID」。


== 相關頁面 ==
== 相關頁面 ==

Navigation menu