Closed b9Joker108 closed 11 months ago
The config in ~/.config/shell_gpt/.sgptrc is generated by sgpt if you run sgpt without an API key, you don't need to create it yourself, as it contains other vars too not just the api key.
Try renaming/removing ~/.config/shell_gpt/.sgptrc then run sgpt and you will be prompted for a key, then the .sgptrc config will be generated.
Thank you. I will give that a go.
I gave that instruction a go twice, and after I deleted the ShellGPT config file. I exited the shell session. I then started a new shell session and entered the sgpt command, but it didn't prompt me for the key, it just gave me the same error output response as in my pastebin above. Should I just uninstall and reinstall, generate a new API key, and start from scratch?
I just gave it a go. I uninstalled ShellGPT and reinstalled it. I then asked a question with the sgpt command, but I wasn't asked for an API key, I got the same error as I had posted previously in my pastebin. But it did create a new ShellGPT config file as you said.
If it did not prompt you for the key, maybe you set it in the environment variable, in which case it will not use the config. Can you echo $OPENAI_API_KEY?
According to the readme:
If the $OPENAI_API_KEY environment variable is set it will be used, otherwise, you will be prompted for your key which will then be stored in ~/.config/shell_gpt/.sgptrc.
Try the API outside of shell_gpt to check if the API key works, and it's not a case of some limit reached on openai (like no credits available for example).
curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_KEY" -d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
I started from scratch. I generated a new API key, then deleted the others. I deleted the ShellGPT config file. I reset the environment variable: export OPENAI_API_KEY=
Glad I could help!
I have installed shell-gpt in my Zsh Termux shell. I generated an API key from my OpenAI account. I added the following code with my generated API key inserted within (without the <> brackets) to my Zsh config file:
export OPENAI_API_KEY=
I added my generated API key to the ShellGPT config file where it specified. I exited the shell terminal session. I started a new shell session in Termux and asked ShellGPT the question:
sgpt "what is the mass of the sun"
I got the following error from Termux in my Zsh shell session, which I have pasted to Pastbin:
https://pastebin.com/97gMCESu
At the end of the pastebin code above, there was a hypertext linkage ( https://api.openai.com/v1/chat/completions ) in the Termux shell response. When I went to the site, it read:
{ "error": { "message": "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.", "type": "invalid_request_error", "param": null, "code": null } }
Any pointers as to how I may progress this?