blob: 673f1c002a968af10861ec90780e0d88b92eed9b [file] [log] [blame]
ben-aaron1883818e7c2022-09-08 17:49:01 +02001#' Make a test request to the GPT-3 API
2#'
3#' @description
ben-aaron1885bcd9112022-09-10 21:33:50 +02004#' `gpt3_test_request()` sends a basic [completion request](https://beta.openai.com/docs/api-reference/completions) to the Open AI GPT-3 API.
ben-aaron1883818e7c2022-09-08 17:49:01 +02005#' @param verbose (boolean) if TRUE prints the actual prompt and GPT-3 completion of the test request (default: FALSE).
6#' @return A message of success or failure of the connection.
7#' @examples
ben-aaron1885bcd9112022-09-10 21:33:50 +02008#' gpt3_test_request()
ben-aaron1883818e7c2022-09-08 17:49:01 +02009#' @export
ben-aaron1885bcd9112022-09-10 21:33:50 +020010gpt3_test_request = function(verbose=F){
ben-aaron1883818e7c2022-09-08 17:49:01 +020011
12 check_apikey_form()
13
14 test_prompt = 'Write a story about R Studio:'
ben-aaron1882b89c2a2022-09-11 16:54:25 +020015 test_outout = gpt3_single_request(prompt_ = test_prompt
ben-aaron1883818e7c2022-09-08 17:49:01 +020016 , max_tokens = 100)
17 print(paste0('.. test successful ..'))
18
19 if(verbose==T){
20 print(paste0('Requested completion for this prompt --> ', test_prompt))
21 print(paste0('GPT-3 completed --> ', test_outout))
22 }
23
24}