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

awesome_chat.py returns error about openai api key #63

Closed
HaroldMitts opened this issue Apr 6, 2023 · 8 comments
Closed

awesome_chat.py returns error about openai api key #63

HaroldMitts opened this issue Apr 6, 2023 · 8 comments

Comments

@HaroldMitts
Copy link

I have quadruple checked my openai api key is correct. I copied and pasted it to avoid typo, I even generated a new key after many attempts/fails. However, no matter what key I generate and write to config.yaml, when I run awesome_chat.py it insists that I have an incorrect openai key.

I also tried running npm run dev and the browser opens and I see the HuggingGPT page and text box, but anytime I submit any prompt, system returns "Something seems seems wrong". Interestingly, localhost is opened to port 9999 when running npm run dev, but in config.yaml it has localhost port set to 8003.

What is it I am doing wrong? I feel like I am so close, but so far. :)

@tricktreat
Copy link
Contributor

tricktreat commented Apr 6, 2023

@HaroldMitts Sorry for the trouble. Let me try to solve it for you. First, let me know if your OpenAI Key starts with 'sk-'? Also, what is the commit id of the JARVIS you are using?

@zzfoo
Copy link

zzfoo commented Apr 6, 2023

I have quadruple checked my openai api key is correct. I copied and pasted it to avoid typo, I even generated a new key after many attempts/fails. However, no matter what key I generate and write to config.yaml, when I run awesome_chat.py it insists that I have an incorrect openai key.

I also tried running npm run dev and the browser opens and I see the HuggingGPT page and text box, but anytime I submit any prompt, system returns "Something seems seems wrong". Interestingly, localhost is opened to port 9999 when running npm run dev, but in config.yaml it has localhost port set to 8003.

What is it I am doing wrong? I feel like I am so close, but so far. :)

maybe you need to modify lite.yaml instead. when running python awesome_chat.py --config lite.yaml the error message "Incrorrect OpenAI key. Please check your config.yaml file." is misleading, since it is actually using lite.yaml.

@HaroldMitts
Copy link
Author

@tricktreat The OpenAI API key does conform with the requirements and begins with sk- also, how do I check the commit ID?

@zzfoo I did try adding both keys to the lite.yaml and it is returning the same error

In general, I should be able to modify either yaml file key values, save the file(s), then rerun the commands to use either the browser or cli without restarting anything else, right?

@zzfoo
Copy link

zzfoo commented Apr 6, 2023

@HaroldMitts no, every time you change config.yaml, you need to run python awesome_chat.py --config config.yaml again, the same go with lite.yaml

@HaroldMitts
Copy link
Author

Have I setup my lite.yaml correctly? The config.yaml uses the same convention where I have my keys in environment variables. You can see in the terminal where I print the keys (masked in the screenshot), to show the environment variables are set.

image

You can also see in the screenshot the error message

python awesome_chat.py --config config. yaml

Traceback (most recent call last):
  File " /home/harold/Jarvis-4.6.2023/server/awesome_chat.py" , line 79, in <module>
    raise valueError("Incrorrect OpenAI key. Please check your config.yaml file.")
ValueError: Incrorrect OpenAI key. Please check your config.yaml file.

I tried downloading Jarvis again using the code as of April 6th, but getting the same issues regardless if I hard-code my OpenAI API key into the lite and config yaml files, or use the environment variables.

Anytime I make changes in these yaml files, I run the awesome_chat script again.

@tricktreat
Copy link
Contributor

tricktreat commented Apr 6, 2023

This is too strange. In fact, this error is only reported if the code is satisfied:

if not config["openai"]["key"].startswith("sk-") and config["openai"]["key"]!="gradio":
    raise ValueError("Incrorrect OpenAI key. Please check your config.yaml file.")

@HaroldMitts
Copy link
Author

I added the double quotes around the hard-coded OpenAI API key and also around the Huggingface token, and it seems to have gotten past this issue.

I don't know if it is true, but if true, it seems like should be in the documentation.

@HaroldMitts
Copy link
Author

Following this, I think I will close this ticket. I got it working. Thanks for the help.
image

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

3 participants