ben-aaron188 | 3818e7c | 2022-09-08 17:49:01 +0200 | [diff] [blame] | 1 | gpt3.make_embedding = function(model_ = 'text-similarity-ada-001' |
| 2 | , input_){ |
| 3 | |
| 4 | parameter_list = list(model = model_ |
| 5 | , input = input_) |
| 6 | |
| 7 | request_base = httr::POST(url = url.embeddings |
| 8 | , body = parameter_list |
| 9 | , httr::add_headers(Authorization = paste("Bearer", api_key)) |
| 10 | , encode = "json") |
| 11 | |
| 12 | |
| 13 | output_base = httr::content(request_base) |
| 14 | |
| 15 | embedding_raw = toNumeric(unlist(output_base$data[[1]]$embedding)) |
| 16 | |
| 17 | return(embedding_raw) |
| 18 | |
| 19 | } |