embeddings functions
diff --git a/R/make_embedding.R b/R/make_embedding.R
index afdb610..a916ac6 100644
--- a/R/make_embedding.R
+++ b/R/make_embedding.R
@@ -1,8 +1,38 @@
-gpt3.make_embedding = function(model_ = 'text-similarity-ada-001'
- , input_){
+#' Obtains text embeddings for a single character (string) from the GPT-3 API
+#'
+#' @description
+#' `gpt3_make_embedding()` sends a single [embedding request](https://beta.openai.com/docs/guides/embeddings) to the Open AI GPT-3 API.
+#' @details The function supports the text similarity embeddings for the four GPT-3 models as specified in the parameter list. The main difference between the four models is the sophistication of the embedding representation as indicated by the vector embedding size.
+#' - Ada (1024 dimensions)
+#' - Babbage (2048 dimensions)
+#' - Curie (4096 dimensions)
+#' - Davinci (12288 dimensions)
+#'
+#' Note that the dimension size (= vector length), speed and [associated costs](https://openai.com/api/pricing/) differ considerably.
+#'
+#' These vectors can be used for downstream tasks such as (vector) similarity calculations.
+#' @param input character that contains the text for which you want to obtain text embeddings from the GPT-3 model
+#' @param model a character vector that indicates the [similarity embedding model](https://beta.openai.com/docs/guides/embeddings/similarity-embeddings); one of "text-similarity-ada-001" (default), "text-similarity-curie-001", "text-similarity-babbage-001", "text-similarity-davinci-001"
+#' @return A numeric vector (= the embedding vector)
+#' @examples
+#' # First authenticate with your API key via `gpt3_authenticate('pathtokey')`
+#'
+#' # Once authenticated:
+#'
+#' ## Simple request with defaults:
+#' sample_string = "London is one of the most liveable cities in the world. The city is always full of energy and people. It's always a great place to explore and have fun."
+#' gpt3_make_embedding(input = sample_string)
+#'
+#' ## Change the model:
+#' #' gpt3_make_embedding(input = sample_string
+#' , model = 'text-similarity-curie-001')
+#' @export
+gpt3_make_embedding = function(input
+ , model = 'text-similarity-ada-001'
+ ){
- parameter_list = list(model = model_
- , input = input_)
+ parameter_list = list(model = model
+ , input = input)
request_base = httr::POST(url = url.embeddings
, body = parameter_list
@@ -12,7 +42,7 @@
output_base = httr::content(request_base)
- embedding_raw = toNumeric(unlist(output_base$data[[1]]$embedding))
+ embedding_raw = to_numeric(unlist(output_base$data[[1]]$embedding))
return(embedding_raw)