Learn R Programming

askgpt (version 0.1.3)

askgpt: Ask openai's GPT models a question

Description

Ask openai's GPT models a question

Usage

askgpt(prompt, chat = TRUE, progress = TRUE, return_answer = FALSE, ...)

Value

either an httr2 response from one of the APIs or a character vector (if return_answer).

Arguments

prompt

What you want to ask

chat

whether to use the chat API (i.e., the same model as ChatGPT) or the completions API.

progress

Show a progress spinner while the request to the API has not been fulfilled.

return_answer

Should the answer be returned as an object instead of printing it to the screen?

...

additional options forwarded to chat_api or completions_api respectively.

Examples

Run this code
if (FALSE) {
askgpt("What is an R function?")
askgpt("What is wrong with my last command?")
askgpt("Can you help me with the function aes() from ggplot2?")
}

Run the code above in your browser using DataLab