Hi Team,
I am trying the below code in cloud function to call and it fails while Building function sources
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 62
If I remove following one line
vertexai.init(project='project', location='us-central1')
it builds but fails at runtime due to not finding the google cloud project set
Please help me to fix this.
import functions_framework
import vertexai
from vertexai.preview.generative_models import GenerativeModel, Part
from google.cloud import aiplatform
@functions_framework.http
def hello_http(request):
"""HTTP Cloud Function.
Args:
request (flask.Request): The request object.
<https://flask.palletsprojects.com/en/1.1.x/api/#incoming-request-data>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<https://flask.palletsprojects.com/en/1.1.x/api/#flask.make_response>.
"""
print("Request received")
vertexai.init(project='project', location='us-central1')
request_json = request.get_json(silent=True)
request_args = request.args
model = GenerativeModel("gemini-pro-vision")
responses = model.generate_content(
"What is life?",
generation_config={
"max_output_tokens": 2048,
"temperature": 0.4,
"top_p": 1,
"top_k": 32
},
)
print(responses)
return 'Hello {}!'.format("name")