I am trying to make chatgpt comment the gapminder dataframe.
This is how I did:
My function:
library(openai)
function_chat <- function(prompt){
create_chat_completion(
model = "gpt-3.5-turbo",
messages = list(
list(
"role" = "system",
"content" = ''
),
list(
"role" = "user",
"content" = prompt
)
)
)
}
This is ok because is only text:
function_chat(prompt = 'please comment about the gapminder dataset') %>%
pluck('choices') %>% pluck('message.content')
But this one is not working:
prompt <- glue::glue("please comment about this dataframe: {gapminder}")
function_chat(prompt = prompt) %>%
pluck('choices') %>% pluck('message.content')
This is the error message that I got: “Erro: OpenAI API request failed [400]:
Invalid type for ‘messages[1].content[0]’: expected an object, but got a string instead.”