Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

cant use langchain on vertex ai

below is my code, so i used to work in different GCP account now im running this same code in another GCP account and another project, i have followed the same steps but im getting this error

! pip install -Uq pip
! pip install langchain==0.0.340 --quiet 
!pip install -qU langchain-google-vertexai

! pip install chromadb==0.4.13 --quiet 

! pip install google-cloud-bigquery[pandas] --quiet 
! pip install --upgrade google-cloud-aiplatform --quiet 
! pip install google-auth==2.15.0 --quiet
! pip install google-cloud-core==1.7.3 --quiet
! pip install --upgrade google-cloud-translate --quiet 

import vertexai
import os

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "keys.json"
vertexai.init(project=VERTEX_PROJECT, location=VERTEX_REGION)

 

from langchain.chat_models import ChatVertexAI
from langchain.llms import VertexAI

query_model = ChatVertexAI(model_name="codechat-bison", max_output_tokens=2048)
interpret_data_model = ChatVertexAI(max_output_tokens=2048)
agent_model = ChatVertexAI(max_output_tokens=1024)
translation_model = ChatVertexAI(model_name="chat-bison@002", max_output_tokens=1024)
classification_model = VertexAI( model_name="text-bison@002", max_output_tokens=1024)

ConfigError: field "client" not yet prepared so type is still a ForwardRef, you might need to call ChatVertexAI.update_forward_refs().

0 2 1,064
2 REPLIES 2

Hello,

Thank you for contacting Google Cloud Community!

The error message ConfigError: field "client" not yet prepared so type is still a ForwardRef, you might need to call ChatVertexAI.update_forward_refs() indicates that there's a configuration issue within the langchain library, specifically related to the ChatVertexAI model.
Ensure you're using the latest version of the langchain library. You can update it using the following command: pip install -U langchain

Regards,
Jai Ade

Hello,

Thank you for your engagement regarding this issue. We haven’t heard back from you regarding this issue for sometime now. Hence, I'm going to close this issue which will no longer be monitored. However, if you have any new issues, Please don’t hesitate to create a new issue. We will be happy to assist you on the same.

Regards,
Jai Ade