add error handling
If response code isn't 200, show warning message
diff --git a/R/chatgpt_single.R b/R/chatgpt_single.R
index c2497a6..798cc15 100644
--- a/R/chatgpt_single.R
+++ b/R/chatgpt_single.R
@@ -87,6 +87,11 @@
request_content = httr::content(request_base)
+ if(request_base$status_code != 200){
+ warning(paste0("Request completed with error. Code: ", request_base$status_code
+ , ", message: ", request_content$error$message))
+ }
+
if(n == 1){
core_output = data.table::data.table('n' = 1
, 'prompt_role' = prompt_role
diff --git a/R/gpt3_single_completion.R b/R/gpt3_single_completion.R
index f8df93a..1f7dcee 100644
--- a/R/gpt3_single_completion.R
+++ b/R/gpt3_single_completion.R
@@ -101,6 +101,11 @@
request_content = httr::content(request_base)
# request_content = httr::content(request_base, encoding = "Latin-ASCII")
+ if(request_base$status_code != 200){
+ warning(paste0("Request completed with error. Code: ", request_base$status_code
+ , ", message: ", request_content$error$message))
+ }
+
if(n == 1){
core_output = data.table::data.table('n' = 1
, 'prompt' = prompt_input