本文說明如何解決開發代理程式時可能遇到的錯誤。
生成內容時發生錯誤
問題:
您會收到類似以下的錯誤訊息:
ValueError: Cannot get the Candidate text.
Response candidate content part has no text.
可能原因:
如果使用的 langchain-google-vertexai 版本與 google-cloud-aiplatform 不相容,就可能發生這項錯誤。必須使用 langchain-google-vertexai 1.0.2 以上版本。如要查看您使用的版本,請在終端機中執行下列指令:
pip show langchain-google-vertexai建議解決方案:
安裝 langchain-google-vertexai 的 1.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),可能需要重新啟動執行階段,才能使用更新的套件。