knitr::opts_chunk$set(echo = TRUE)

Setup

library(googleAuthR)
library(googleCloudVertexAIR)

options(googleAuthR.scopes.selected = "https://www.googleapis.com/auth/cloud-platform")

gar_auth_service(json_file = Sys.getenv("GAR_SERVICE_JSON"))

Set global arguements

projectId <- Sys.getenv("GCVA_DEFAULT_PROJECT_ID")
gcva_region_set(region = "us-central1")
gcva_project_set(projectId = projectId)

Text

## set verbose log for debugging assistance
# options(googleAuthR.verbose = 0)
result_gemini <- gcva_gemini_text(
  prompt="Give me ten interview questions for the role of a data scientist related to the R language.",
  modelId="gemini-1.5-pro-002",
  stream=FALSE)

result_gemini

refs:

notes:

2024-02-21 - see potential bug here: https://www.googlecloudcommunity.com/gc/AI-ML/Gemini-s-safety-config-400-error-from-today/m-p/712922/highlight/true and references: https://cloud.google.com/vertex-ai/docs/generative-ai/multimodal/configure-safety-attributes#gemini-TASK-samples-drest

# request_debug <- readRDS("request_debug.rds")
# request_debug$body_json
# result_gemini <- gcva_gemini_generate_content(
#   prompt="Give me ten interview questions for the role of a data scientist related to the R language.",
#   modelId="gemini-1.0-pro",
#   stream=FALSE)
# 
# result_gemini


justinjm/googleCloudVertexAIR documentation built on April 17, 2025, 5:04 p.m.