排解使用 Agent Runtime 建立代理程式時發生的問題

本文說明如何解決建立代理程式時可能遇到的錯誤。

內容生成錯誤

問題

您會收到類似以下的錯誤訊息:

ValueError: Cannot get the Candidate text.
Response candidate content part has no text.

可能原因

如果使用的 langchain-google-vertexai 版本與 google-cloud-aiplatform 不相容,就可能發生這項錯誤。必須使用 1.0.2 以上版本的 langchain-google-vertexai。如要查看目前使用的版本,請在終端機中執行下列指令:

pip show langchain-google-vertexai

建議解決方案

安裝 langchain-google-vertexai1.0.2 版本。這個版本包含LangChain 工具呼叫更新,必須使用這些更新才能與 google-cloud-aiplatform 搭配運作。如要更新 langchain-google-vertexai 版本,請在終端機中執行下列指令:

pip install langchain-google-vertexai --upgrade

執行更新指令後,請在終端機中執行下列指令,確認您使用的是 1.0.2 以上版本:

pip show langchain-google-vertexai

如果您位於筆記本執行個體 (例如 Jupyter、Colab 或 Workbench),可能需要重新啟動執行階段,才能使用更新的套件。

首次建立自備容器 (BYOC) 時發生錯誤

問題

您在所在區域的 Google Cloud 專案中,首次透過BYOC部署代理程式,並收到類似以下的錯誤訊息:

Reasoning Engine resource <reasoning-engine-id> failed to start and cannot serve traffic.

可能原因

失敗原因可能是 Gemini Enterprise Agent Platform 內部 IAM 佈建。變更需要一段時間才會完成並生效。

建議解決方案

重新嘗試相同的代理程式部署要求,就會成功。