# \donttest{
if (interactive()) {
# Define a schema for the expected output
schema <- z_object(
title = z_string(description = "Title of the article"),
keywords = z_array(z_string()),
sentiment = z_enum(c("positive", "negative", "neutral"))
)
# Generate structured object
result <- generate_object(
model = "openai:gpt-4o",
prompt = "Analyze this article: 'R programming is great for data science!'",
schema = schema
)
print(result$object$title)
print(result$object$sentiment)
}
# }
Run the code above in your browser using DataLab