This function interfaces with Google Cloud Vertex AI to generate text using the Gemini model. It allows for specifying various parameters like project ID, location ID, model ID, and more, to customize the text generation process. https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/gemini#sample_requests

gcva_gemini_text(
  projectId = gcva_project_get(),
  locationId = gcva_region_get(),
  modelId = c("gemini-1.5-flash-001", "gemini-1.5-pro-001", "gemini-1.0-pro-001",
    "gemini-1.0-pro-vision-001", "gemini-1.0-pro", "gemini-1.0-pro-001",
    "gemini-1.0-pro-002"),
  stream = FALSE,
  role = c("user"),
  prompt,
  data = NULL,
  mimeType = NULL,
  fileUri = NULL,
  startOffsetSeconds = NULL,
  startOffsetNanos = NULL,
  endOffsetSeconds = NULL,
  endOffsetNanos = NULL,
  functionDeclarations = NULL,
  harmCategory = c("HARM_CATEGORY_SEXUALLY_EXPLICIT", "HARM_CATEGORY_HATE_SPEECH",
    "HARM_CATEGORY_HARASSMENT", "HARM_CATEGORY_DANGEROUS_CONTENT"),
  harmThreshold = "BLOCK_ONLY_HIGH",
  candidateCount = NULL,
  temperature = NULL,
  maxOutputTokens = NULL,
  topP = NULL,
  topK = NULL,
  stopSequences = NULL
)

Arguments

projectId

The ID of the Google Cloud project. Default is retrieved using `gcva_project_get()`.

locationId

The location ID for the AI model. Default is retrieved using `gcva_region_get()`.

modelId

Character vector specifying the model ID

stream

Logical; whether to stream the output. ALWAYS FALSE

prompt

Character string specifying the input prompt for text generation.

harmCategory

Categories of harmful content to be filtered, with defaults set.

harmThreshold

Threshold for blocking harmful content, default is "BLOCK_ONLY_HIGH".

temperature

Controls randomness in response generation, default is 0.5.

maxOutputTokens

Maximum number of tokens that can be generated in the response. A token is approximately four characters. 100 tokens correspond to roughly 60-80 words.

topP

Controls diversity of generated responses

topK

Limits the number of high probability tokens considered for each step

Value

A response object from the Google Cloud Vertex AI.