mshumer/gpt-prompt-engineer

Continue to Get GPT-4 Auth Error after Changing Model to GPT-3.5-Turbo

JakeTauerGA opened this issue · 1 comments

I keep getting the below authentication error even after I've changed the model to gpt-3.5-turbo:

`---------------------------------------------------------------------------
AuthenticationError Traceback (most recent call last)
in <cell line: 1>()
----> 1 generate_optimal_prompt(description, test_cases, NUMBER_OF_PROMPTS, use_wandb)

6 frames
in generate_optimal_prompt(description, test_cases, number_of_prompts, use_wandb)
108
109 def generate_optimal_prompt(description, test_cases, number_of_prompts=10, use_wandb=False):
--> 110 prompts = generate_candidate_prompts(description, test_cases, number_of_prompts)
111 prompt_ratings = test_candidate_prompts(test_cases, description, prompts)
112

in generate_candidate_prompts(description, test_cases, number_of_prompts)
1 def generate_candidate_prompts(description, test_cases, number_of_prompts):
----> 2 outputs = openai.ChatCompletion.create(
3 model=CANDIDATE_MODEL, # change this to gpt-3.5-turbo if you don't have GPT-4 access
4 messages=[
5 {"role": "system", "content": system_gen_system_prompt},

/usr/local/lib/python3.10/dist-packages/openai/api_resources/chat_completion.py in create(cls, *args, **kwargs)
23 while True:
24 try:
---> 25 return super().create(*args, **kwargs)
26 except TryAgain as e:
27 if timeout is not None and time.time() > start + timeout:

/usr/local/lib/python3.10/dist-packages/openai/api_resources/abstract/engine_api_resource.py in create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)
151 )
152
--> 153 response, _, api_key = requestor.request(
154 "post",
155 url,

/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py in request(self, method, url, params, headers, files, stream, request_id, request_timeout)
296 request_timeout=request_timeout,
297 )
--> 298 resp, got_stream = self._interpret_response(result, stream)
299 return resp, got_stream, self.api_key
300

/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py in _interpret_response(self, result, stream)
698 else:
699 return (
--> 700 self._interpret_response_line(
701 result.content.decode("utf-8"),
702 result.status_code,

/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py in _interpret_response_line(self, rbody, rcode, rheaders, stream)
761 stream_error = stream and "error" in resp.data
762 if stream_error or not 200 <= rcode < 300:
--> 763 raise self.handle_error_response(
764 rbody, rcode, resp.data, rheaders, stream_error=stream_error
765 )

AuthenticationError: You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.`

Here is the cell that sets the models:

`# K is a constant factor that determines how much ratings change
K = 32

CANDIDATE_MODEL = 'gpt-3.5-turbo'
CANDIDATE_MODEL_TEMPERATURE = 0.9

GENERATION_MODEL = 'gpt-3.5-turbo'
GENERATION_MODEL_TEMPERATURE = 0.8
GENERATION_MODEL_MAX_TOKENS = 60

N_RETRIES = 3 # number of times to retry a call to the ranking model if it fails
RANKING_MODEL = 'gpt-3.5-turbo'
RANKING_MODEL_TEMPERATURE = 0.5

NUMBER_OF_PROMPTS = 10 # this determines how many candidate prompts to generate... the higher, the more expensive, but the better the results will be`

IlianP commented

Well, from what I'm reading, it says right there:

AuthenticationError: You didn't provide an API key. You need to provide your API key ...

In the README, it says:

Add your OpenAI API key to the line openai.api_key = "ADD YOUR KEY HERE".