ben-aaron188 / rgpt3

Making requests from R to the GPT models
GNU General Public License v3.0
101 stars 16 forks source link

First example doesn't work #1

Closed vonjd closed 1 year ago

vonjd commented 1 year ago

The first example gpt3_single_completionthrows the following error:

To avoid an `invalid_request_error`, `best_of` was set to equal `n`
Error in core_output$gpt3[i] <- request_content$choices[[i]]$text : 
  replacement has length zero
ben-aaron188 commented 1 year ago

It works for me. Could you check two things?

  1. did you run the authentication properly to your API key? gpt3_authenticate("/Users/.../access_key.txt") (the path can take any form as long as you point it to a file (here called: access_key.txt) where your API key is located.
  2. Does gpt3_test_completion() work for you?

If the error persists, can you provide a reproducible example?

ben-aaron188 commented 1 year ago

@vonjd Did this work? Two other potential things to check are:

  1. are you still within your API limit (or has it expired)?
  2. does the gpt3_authenticate("/Users/.../access_key.txt") work without issues? Here a potential hiccup can be a missing newline after the actual key.
supernole1 commented 1 year ago

I get the same error when i try to execute the first example: my_prompts = data.frame('prompts' = c('Complete this sentence: universities are' , 'Write a poem about music:' , 'Which colour is better and why? Red or blue?') ,'prompt_id' = c(LETTERS[1:3]))

example_2 = gpt3_completions(prompt_var = my_prompts$prompts , id_var = my_prompts$prompt_id , param_model = 'text-ada-001' , param_max_tokens = 100 , param_n = 5 , param_temperature = 0.4)

returns: To avoid an invalid_request_error, best_of was set to equal n Error in core_output$gpt3[i] <- request_content$choices[[i]]$text : replacement has length zero

I dont have a paid account with OpenAI but should be well within my API free usage limit.

supernole1 commented 1 year ago

i upgraded to a paid account on OpenAI and this now works!