knitr::opts_chunk$set(echo = TRUE)
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"))
projectId <- Sys.getenv("GCVA_DEFAULT_PROJECT_ID") gcva_region_set(region = "us-central1") gcva_project_set(projectId = projectId)
https://cloud.google.com/vertex-ai/docs/generative-ai/text/test-text-prompts
result <- gcva_text_gen_predict( prompt="Give me ten interview questions for the role of a Python software engineer.", modelId="text-bison", rawResponse = TRUE ) # result$predictions # prediction response with safteyAttributes result$predictions$content # prediction response only
https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/text-chat https://github.com/GoogleCloudPlatform/generative-ai/blob/main/language/intro_palm_api.ipynb
# gcva_InputOutputTextPair( # input_text="How many moons does Mars have?", # output_text="The planet Mars has two moons, Phobos and Deimos." # )
# gcva_chat_predict( # modelId = "chat-bison@001", # context = "My name is Miles. You are an astronomer, knowledgeable about the solar system.", # examples = gcva_InputOutputTextPair( # input_text="How many moons does Mars have?", # output_text="The planet Mars has two moons, Phobos and Deimos." # ), # messages = "How many planets are there in the solar system?" # )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.