Hi,
can anyone help me figure this out?
My goal is to create a lambda function that uses Langchain with VertexAI. For this, I’ve created a zip file with the Python packages. The method used was by creating a temp Docker image from amazonlinux in which I’m installing Python3.8, PIP and a virtualenv.
Langchain works, but when I try to use VertexAI I get an error.
Here’s the code:
from langchain.llms import VertexAI
llm = VertexAI(model_name=“gemini-pro”,credentials=credentials)
and the error:
“errorMessage”: “Please, install or upgrade the google-cloud-aiplatform library: pip install google-cloud-aiplatform>=1.38.0”,
"errorType": "ImportError",
"stackTrace": \[
" File \\"/var/task/lambda\_function.py\\", line 12, in lambda\_handler\\n llm = VertexAI(model\_name=\\"gemini-pro\\",credentials=credentials)\\n",
" File \\"/opt/python/langchain\_core/load/serializable.py\\", line 107, in \_\_init\_\_\\n super().\_\_init\_\_(\*\*kwargs)\\n",
" File \\"/opt/python/pydantic/v1/main.py\\", line 339, in \_\_init\_\_\\n values, fields\_set, validation\_error = validate\_model(\_\_pydantic\_self\_\_.\_\_class\_\_, data)\\n",
" File \\"/opt/python/pydantic/v1/main.py\\", line 1102, in validate\_model\\n values = validator(cls\_, values)\\n",
" File \\"/opt/python/langchain\_community/llms/vertexai.py\\", line 226, in validate\_environment\\n cls.\_try\_init\_vertexai(values)\\n",
" File \\"/opt/python/langchain\_community/llms/vertexai.py\\", line 185, in \_try\_init\_vertexai\\n init\_vertexai(\*\*params)\\n",
" File \\"/opt/python/langchain\_community/utilities/vertexai.py\\", line 75, in init\_vertexai\\n raise\_vertex\_import\_error()\\n",
" File \\"/opt/python/langchain\_community/utilities/vertexai.py\\", line 49, in raise\_vertex\_import\_error\\n raise ImportError(\\n"
\]
I’ve tried to cut dig into this by cutting down the code and it seems only using this:
from google.cloud import aiplatform
generates an error like
{
“errorMessage”: “Unable to import module ‘lambda_function’: No module named ‘google.protobuf’”,
“errorType”: “Runtime.ImportModuleError”,
“stackTrace”:
}
Needless to say that the zip file uploaded contains:
langchain
google
protobuf
google-cloud-aiplatform
google-cloud-api-keys
What am I missing here?
thanks in advance,
John