if (FALSE) {
api_key <- get_credentials()$openai$secret_key
# Open question:
gpt_ask("Can you write an R function to plot a dummy histogram?", api_key)
##### The following examples return dataframes:
# Classify each element based on categories:
gpt_classify(1:10, c("odd", "even"))
# Add all tags that apply to each element based on tags:
gpt_tag(
c("I love chocolate", "I hate chocolate", "I like Coke"),
c("food", "positive", "negative", "beverage")
)
# Extract specific information:
gpt_extract(
c("My mail is 123@test.com", "30 Main Street, Brooklyn, NY, USA", "+82 2-312-3456", "$1.5M"),
c("email", "full state name", "country of phone number", "amount as number")
)
# Format values
gpt_format(
c("March 27th, 2021", "12-25-2023 3:45PM", "01.01.2000", "29 Feb 92"),
format = "ISO Date getting rid of time stamps"
)
# Convert temperature units
gpt_convert(c("50C", "300K"), "Fahrenheit")
# Create a table with data
gpt_table("5 random people's address in South America, email, phone, age between 18-30")
gpt_table(
ask = "5 largest cities, their countries, and population",
cols = c("city_name", "where", "POP")
)
# Translate text to any language
gpt_translate(
rep("I love you with all my heart", 5),
language = c("spanish", "chinese", "japanese", "russian", "german")
)
# Now let's read the historical prompts, replies, ano more from current session
gpt_history()
}
Run the code above in your browser using DataLab