Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to add API key #2

Closed
KangtanC opened this issue Apr 12, 2023 · 3 comments
Closed

failed to add API key #2

KangtanC opened this issue Apr 12, 2023 · 3 comments

Comments

@KangtanC
Copy link

KangtanC commented Apr 12, 2023

Traceback (most recent call last):
File "/Users/aquaticdwarf/Downloads/chatPDF-main/main.py", line 99, in
ask(file)
File "/Users/aquaticdwarf/Downloads/chatPDF-main/main.py", line 38, in ask
llm_predictor = LLMPredictor(llm=OpenAI(temperature=0, model_name="text-davinci-003"))
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for OpenAI
root
Did not find openai_api_key, please add an environment variable OPENAI_API_KEY which contains it, or pass openai_api_key as a named parameter. (type=value_error)

openai.api_key = os.environ["API_KEY"] = [REDACTED]

@gabacode
Copy link
Owner

Hello @KangtanC,
In order to load your API key from env, you should keep the code as it is and add a new file called .env in the root directory with the following content.

OPENAI_API_KEY=sk-therestofyourapikey

Also, I would suggest you not to publish your API key publicly, so please edit your comment or revoke your key and create a new one with OpenAI.

I hope this helps!

@gabacode
Copy link
Owner

Closing for now, feel free to reopen if needed.

@gabacode gabacode closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
@KangtanC
Copy link
Author

thank you very much, it's very helpful. The API key I've sent has deleted several numbers so it can't be used.

@gabacode gabacode mentioned this issue Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants