#' Retrieves text embeddings for character input from a vector from the GPT-3 API
#'
#' @description
#' `gpt3_embeddings()` extends the single embeddings function `gpt3_single_embedding()` to allow for the processing of a whole vector
#' @details The returned data.table contains the column `id` which indicates the text id (or its generic alternative if not specified) and the columns `dim_1` ... `dim_{max}`, where `max` is the length of the text embeddings vector that the different models (see below) return. For the default "Ada 2nd gen." model, these are 1536 dimensions (i.e., `dim_1`... `dim_1536`).
#'
#' The function supports the text similarity embeddings for the [five GPT-3 embeddings models](https://beta.openai.com/docs/guides/embeddings/embedding-models) as specified in the parameter list. It is strongly advised to use the second generation model "text-embedding-ada-002". The main difference between the five models is the size of the embedding representation as indicated by the vector embedding size and the pricing. The newest model (default) is the fastest, cheapest and highest quality one.
#'   - Ada 2nd generation `text-embedding-ada-002` (1536 dimensions)
#'   - 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_var character vector that contains the texts for which you want to obtain text embeddings from the GPT-3 model
#' #' @param id_var (optional) character vector that contains the user-defined ids of the prompts. See details.
#' @param param_model a character vector that indicates the [embedding model](https://beta.openai.com/docs/guides/embeddings/embedding-models); one of "text-embedding-ada-002" (default), "text-similarity-ada-001", "text-similarity-curie-001", "text-similarity-babbage-001", "text-similarity-davinci-001"
#' @return A data.table with the embeddings as separate columns; one row represents one input text. See details.
#' @examples
#' # First authenticate with your API key via `gpt3_authenticate('pathtokey')`
#'
#' # Use example data:
#' ## The data below were generated with the `gpt3_single_request()` function as follows:
#' ##### DO NOT RUN #####
#' # travel_blog_data = gpt3_single_request(prompt_input = "Write a travel blog about a dog's journey through the UK:", temperature = 0.8, n = 10, max_tokens = 200)[[1]]
#' ##### END DO NOT RUN #####
#'
#' # You can load these data with:
#' data("travel_blog_data") # the dataset contains 10 completions for the above request
#'
#' ## Obtain text embeddings for the completion texts:
#' emb_travelblogs = gpt3_embeddings(input_var = travel_blog_data$gpt3)
#' dim(emb_travelblogs)
#' @export
gpt3_embeddings = function(input_var
                                , id_var
                                , param_model = 'text-embedding-ada-002'){

  data_length = length(input_var)
  if(missing(id_var)){
    data_id = paste0('prompt_', 1:data_length)
  } else {
    data_id = id_var
  }

  empty_list = list()

  for(i in 1:data_length){

    print(paste0('Embedding: ', i, '/', data_length))

    row_outcome = gpt3_single_embedding(model = param_model
                                      , input = input_var[i])

    empty_df = data.frame(t(row_outcome))
    names(empty_df) = paste0('dim_', 1:length(row_outcome))
    empty_df$id = data_id[i]

    empty_list[[i]] = empty_df


  }

  output_data = data.table::rbindlist(empty_list)

  return(output_data)

}
