added error handling to embeddings
diff --git a/R/gpt3_single_completion.R b/R/gpt3_single_completion.R
index 1f7dcee..abe6bfb 100644
--- a/R/gpt3_single_completion.R
+++ b/R/gpt3_single_completion.R
@@ -99,7 +99,6 @@
, encode = "json")
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
diff --git a/R/gpt3_single_embedding.R b/R/gpt3_single_embedding.R
index 1e475c0..5f4dec0 100644
--- a/R/gpt3_single_embedding.R
+++ b/R/gpt3_single_embedding.R
@@ -40,6 +40,10 @@
, httr::add_headers(Authorization = paste("Bearer", api_key))
, encode = "json")
+ if(request_base$status_code != 200){
+ warning(paste0("Request completed with error. Code: ", request_base$status_code
+ , ", message: ", request_content$error$message))
+ }
output_base = httr::content(request_base)
diff --git a/README.md b/README.md
index 8500600..4375a02 100644
--- a/README.md
+++ b/README.md
@@ -242,6 +242,7 @@
## Changelog/updates
+- [small change] 24 Mar 2023: included error handling for httr requests as per [https://github.com/ben-aaron188/rgpt3/pull/7](https://github.com/ben-aaron188/rgpt3/pull/7)
- [new release] 5 Mar 2023: the package now supports ChatGPT
- [update] 30 Jan 2023: added error shooting for API call errors
- [update] 23 Dec 2022: the embeddings functions now default to the second generation embeddings "text-embedding-ada-002".