vignettes/large_language_models.Rmd
large_language_models.Rmd
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")
## 2024-07-08 12:35:39.784433> Region set to 'us-central1'
gcva_project_set(projectId = projectId)
## 2024-07-08 12:35:39.785023> ProjectId set to 'gc-vertex-ai-r'
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
## [1] " **1. What are the different data structures in Python?**\n\n**2. How do you handle exceptions in Python?**\n\n**3. What is the difference between a list and a tuple in Python?**\n\n**4. What is the purpose of the `self` parameter in Python methods?**\n\n**5. What is the difference between a class and an instance in Python?**\n\n**6. What is the purpose of the `__init__` method in Python classes?**\n\n**7. What is the difference between inheritance and composition in Python?**\n\n**8. What is the purpose of the `super()` keyword in Python?**\n\n**9. What is the difference between a module and a package in Python?**\n\n**10. What is the purpose of the `import` statement in Python?**"
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?"
# )