ben-aaron188 | 3818e7c | 2022-09-08 17:49:01 +0200 | [diff] [blame] | 1 | #' Make a test request to the GPT-3 API |
| 2 | #' |
| 3 | #' @description |
ben-aaron188 | 5bcd911 | 2022-09-10 21:33:50 +0200 | [diff] [blame] | 4 | #' `gpt3_test_request()` sends a basic [completion request](https://beta.openai.com/docs/api-reference/completions) to the Open AI GPT-3 API. |
ben-aaron188 | 3818e7c | 2022-09-08 17:49:01 +0200 | [diff] [blame] | 5 | #' @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-aaron188 | 5bcd911 | 2022-09-10 21:33:50 +0200 | [diff] [blame] | 8 | #' gpt3_test_request() |
ben-aaron188 | 3818e7c | 2022-09-08 17:49:01 +0200 | [diff] [blame] | 9 | #' @export |
ben-aaron188 | 5bcd911 | 2022-09-10 21:33:50 +0200 | [diff] [blame] | 10 | gpt3_test_request = function(verbose=F){ |
ben-aaron188 | 3818e7c | 2022-09-08 17:49:01 +0200 | [diff] [blame] | 11 | |
| 12 | check_apikey_form() |
| 13 | |
| 14 | test_prompt = 'Write a story about R Studio:' |
ben-aaron188 | 2b89c2a | 2022-09-11 16:54:25 +0200 | [diff] [blame] | 15 | test_outout = gpt3_single_request(prompt_ = test_prompt |
ben-aaron188 | 3818e7c | 2022-09-08 17:49:01 +0200 | [diff] [blame] | 16 | , 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 | } |