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

From LemonWiki共筆
Jump to navigation Jump to search
Line 92: Line 92:




=== 排解:Discovery Engine 中的 "Search lite requests" 超出額度錯誤 ===
=== 疑難排解:Discovery Engine 中的 "Search lite requests" 超出額度錯誤 ===


'''問題描述''':   
'''問題描述''':   

Revision as of 23:28, 28 April 2025

Google Vertex AI API 疑難排解


icon_scale_pencil.png This article "Troubleshooting of Google Vertex AI Search in Mandarin" is still being written. If there are any incomplete parts, you are welcome to directly edit them. 這篇文章「Troubleshooting of Google Vertex AI Search in Mandarin」內容還在撰寫中,如果有不完整的部分,歡迎你直接動手修改


🌐 Switch language: EN, 漢字


問題

疑難排解:Vertex AI Search:資料儲存庫需啟用 Enterprise 版功能

錯誤: 建立應用程式時遇到錯誤訊息「這個應用程式目前無法使用 4 data stores are ...」 展開所有資料儲存庫清單,顯示「網站資料儲存庫只能連結至 Enterprise 版 Vertex AI Search 應用程式」

解決方式: 建立應用程式時,需啟用「Enterprise 版功能

疑難排解:Discovery Engine 中的「SearchLite API 被封鎖」錯誤

問題描述:當嘗試使用 Google Vertex AI API 取得搜尋結果時[1],發生以下錯誤:

curl -X POST -H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/engines/APP_ID/servingConfigs/default_search:searchLite?key=API_KEY" \
-d '{
"servingConfig": "projects/PROJECT_ID/locations/global/collections/default_collection/engines/APP_ID/servingConfigs/default_search",
"query": "QUERY",
}'

遇到錯誤

{
  "code" : 403,
  "message" : "Requests to this API discoveryengine.googleapis.com method google.cloud.discoveryengine.v1.SearchService.SearchLite are blocked.",
  "status" : "PERMISSION_DENIED",
  "details" : [
    {
      "@type" : "type.googleapis.com/google.rpc.ErrorInfo",
      "reason" : "API_KEY_SERVICE_BLOCKED",
      "domain" : "googleapis.com",
      "metadata" : {
        "service" : "discoveryengine.googleapis.com",
        "methodName" : "google.cloud.discoveryengine.v1.SearchService.SearchLite",
        "apiName" : "discoveryengine.googleapis.com",
        "consumer" : "projects/xxx"
      }
    },
    {
      "@type" : "type.googleapis.com/google.rpc.LocalizedMessage",
      "locale" : "en-US",
      "message" : "Requests to this API discoveryengine.googleapis.com method google.cloud.discoveryengine.v1.SearchService.SearchLite are blocked."
    }
  ]
}

解決步驟:檢查 API 金鑰限制

  • 確認金鑰是否限制特定 API:
    1. 前往 Google Cloud Console 的 API 金鑰管理頁面。
    2. 找到正在使用的 API 金鑰,並檢查是否限制特定 API。如果限制包含 discoveryengine.googleapis.com,請確保其設定正確。
    3. 移除不必要的限制:如果金鑰被限制在不相關的 IP 位址或應用程式,請移除這些限制。
  • 啟用 Discovery Engine API
    1. 前往 Google Cloud Console 的 API 與服務頁面。
    2. 搜尋 Discovery Engine API 並確保其已啟用。


疑難排解:儲存 Data Stores 時出現「Requested Entity Already Exists」錯誤

錯誤訊息: 儲存網站規則時,出現以下錯誤訊息:

Failed to save sites
Requested entity already exists
Tracking number: <mix of English and numeric characters>

問題原因: 在「Specify URL patterns to index」中同時存在衝突的 URL 模式:

example.com

''.example.com/''

這兩種模式相互衝突,導致系統將它們視為重複的實體。

解決方案: 只需移除其中一種模式即可解決此問題。建議保留較通用的模式 .example.com/,因為它已經包含了 example.com


疑難排解:Discovery Engine 中的 "Search lite requests" 超出額度錯誤

問題描述: 當使用 Discovery Engine API 來取得搜尋結果時,發生以下錯誤:

{
  "error" : {
    "code" : 429,
    "message" : "Quota exceeded for quota metric 'Search lite requests' and limit 'Search lite requests per minute' of service 'discoveryengine.googleapis.com' for consumer 'project_number:XXX'.",
    "status" : "RESOURCE_EXHAUSTED",
    ...
  }
}

根本原因:

錯誤回應中的 metadata 已標示該額度為 100 請求/分鐘

解決步驟:解決 API 配額限制超出問題

選項一:增加請求 (request) 之間的延遲時間

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

選項二:提高額度限制

  1. 前往 Google Cloud Console 的額度頁面並找到 "Search lite requests per minute"
  2. 選擇相關配額,點擊 "EDIT QUOTAS",並提交更高限制的申請
  3. 等待 Google Cloud Support 審核批准

選項三:實作指數退避重試機制

  1. 在應用程式中偵測 HTTP 429 錯誤並設置初始延遲(例如 1 秒)
  2. 每次重試失敗後增加延遲時間(例如 2 秒、4 秒、8 秒等)
  3. 持續重試直到請求成功或達到最大重試次數

相關頁面

參考資料