Open gacott opened 1 year ago
The error message is saying you have not provided an API key for the OpenAI library.
Since you said you have the OpenAI API key in your file, I suggest the following steps:
Please pull from this repository if you haven't recently.
I am assuming you mean your .env
file when you say in the doc
. If so, skip to step 7. If NOT, or if you don't know what I mean by .env
file, or if you're simply unsure whether you did it right, then follow all these steps.
Please use .env.template
below (it also exists as .env.template
in your repo if you've pulled recently):
OPENAI_API_KEY= ELEVENLABS_API_KEY= FAST_LLM_MODEL="gpt-3.5-turbo" SMART_LLM_MODEL="gpt-3.5-turbo" GOOGLE_API_KEY= CUSTOM_SEARCH_ENGINE_ID= SEARX_URL= SEARX_USERNAME= SEARX_PASSWORD= BASE_AUTO_GPT="/working/directory/goes/here"
If you have not already, generate an API key from the OpenAI web interface. You can find this in your OpenAI account settings or API settings on the platform (https://platform.openai.com/account/api-keys)
Fill out the .env
template. DO NOT FORGET TO RENAME your .env.template
file to .env
and save it in /AutoGPT/
. I cannot stress this enough.**
ALTERNATIVE SOLUTIONS:
set OPENAI_API_KEY=<your_api_key>
from a Windows command prompt, THEN run the scriptsetx OPENAI_API_KEY "<your_api_key>"
, THEN run the script[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "<your_api_key>", "User")
will
permanently add the OpenAI API key to your environment only for your current username. Don't change User
.If all else fails, then I need you to hardcode your API key on line 39
of AutoGPT/scripts/config.py
and change it to equal:
self.openai_api_key = "YOUR_KEY_HERE"
and replace OPENAI_API_KEY
with your key.
Please let me know when you've tried the above steps.
Perfect, yes I was speaking of the .env.template. The set command worked great, thanks.
The next issue is this Searx URL is not configured. Even though I used the URL of one of the servers listed. Do I need to fire one of these up myself, go a "have" to have a user account for Searx? Or is the URL supposed to be good enough?
Thanks so much, I am glad somebody is actually making this work. :-)
Just curious, did you rename .env.template
to .env
? It will not be recognized, otherwise. The file I provided is only a template :p
I highly recommend using the .env
file as otherwise you will have to manually set each variable in the terminal each session (unless you permanently change your environment variables). Thus, I think we should focus on getting that working, if we can. To do that, I'd need a little more information, but please try these steps:
Go to config.py
At the very top of the file, you should see line 5, load_dotenv()
Please pass your .env
file - named correctly and located in /AutoGPT/ - as a parameter like so:
"path/to/.env/"
So the line should look like:
load_dotenv("/home/dev/Auto-GPT/scripts/.env)
if you're me on Linux.
On Windows, it may look a little more like:
load_dotenv("C:\Users\Administrator\.env")
where the actual path there is your precise path (I'm unsure of your file structure. NOTE: you may have to escape the backslashes with an extra backslash. I apologize, it's been some time since I've used Windows.)
Please verify whether the .env
file information is being loaded properly. Since you've already run the set
command, it may be hard to verify whether that properly loaded the .env
file, but it likely did.
Now, please remove the SearX
line from the .env
file, as well as the SearX username and password line.
Now go to lines 104
and 105
of commands.py
and remove (or comment out) the following lines completely:
elif command_name == "searx":
return searx_search(arguments["input"]) # SearX search, added by Alex
This will, essentially, remove the option from the list of available commands for GPT to choose from. For the record, this is how you can add any command :) (or remove!)
In regards to the SearX issue in terms of replacing search functionality -
Since I recommend removing the functionality if you don't have a SearX server setup, I instead recommend going and setting up a Google search API. It can be a hassle to set it up a SearX server on your own machine. Because of this, I recommend avoiding it. I added this functionality as an alternative to Google's search API which actually costs money after a certain amount of use, though, so if you're willing to put in the effort, I recommend, but if not, then please follow the below steps to use Google (which also needs to have its information deposited into the .env
file or you will have to set it manually using setx:
Create an API key on https://console.cloud.google.com/welcome?project=vocal-collector-382718 after making an account
As seen in the image, click on the top left hamburger/dropdown menu and then go to APIs & Services > Credentials
At the top, press + Create Credentials > API key
Use your API key and put it either into the .env
file or copy the .env
variable format and use setx
again like you did with the OPENAI_API_KEY
Finally, create a new custom search engine at cse.google.com and then do the same thing as step 4 but with the custom search engine ID. (located at https://programmablesearchengine.google.com/controlpanel/all)
Report back with any issues.
Apologies for formatting errors, my markdown isn't up to par. Should be good now.
Update - thank you for bringing a new issue to my attention. I'll have the full fix pushed in ~20 mins. Discovered a lack of Google functionality, lol, oops. Disabled it during testing and never re-added it! I am going to also add an option to disable search entirely using the --no-search
flag. I will edit this again when I've pushed.
Update #2 Alright, changes are up. The README has been updated with new instructions.
Features released:
/Auto-GPT/
if people don't wanna run it from /scripts/ (also has flags)Thanks so much; I'll dig in ASAP. :-)
OpenAPI key in in the doc, and I am getting this
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\openai\util.py", line 186, in default_api_key raise openai.error.AuthenticationError( openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key =', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '. You can generate API keys in the OpenAI web interface. See https://onboard.openai.com for details, or email support@openai.com if you have any questions.