排解開發代理程式的問題

本文說明如何解決開發介面代理程式時可能遇到的錯誤。

內容產生錯誤

問題

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

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

可能的原因

這個錯誤可能是因為您使用了與 google-cloud-aiplatform 不相容的 langchain-google-vertexai 版本。必須使用 langchain-google-vertexai1.0.2 以上版本。如要查看您使用的版本,請在終端機中執行下列指令:

pip show langchain-google-vertexai

建議的解決方案

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

pip install langchain-google-vertexai --upgrade

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

pip show langchain-google-vertexai

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