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

Fetch image/video from cloud bucket and send it+prompt to Gemini vision in Go

Hello hello

I am trying to get an image from my cloud bucket and send it + a user prompt to gemini vision. I managed to do it for locally stored images but cannot see how to do it when bickets are involved.

Below is the local version:

 

 

client, err := genai.NewClient(ctx, option.WithAPIKey(string(API_KEY)))
if err != nil {
log.Fatal(err)
}
defer client.Close()
modelfile, err := client.UploadFileFromPath(ctx, filepath.Join(uploadPath, dtf+".jpg"), nil)
if err != nil {
log.Fatal(err)
}
defer client.DeleteFile(ctx, modelfile.Name)
// ----------------------------- THIS ONE
model := client.GenerativeModel("gemini-1.5-flash")
resp, err := model.GenerateContent(ctx,
genai.FileData{URI: modelfile.URI},
genai.Text(prompt))

 

 

Thanks in advance for your help!

0 1 582
1 REPLY 1