richardyc / Chrome-GPT

An AutoGPT agent that controls Chrome on your desktop
GNU General Public License v3.0
1.66k stars 208 forks source link

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) #14

Open arcturien opened 1 year ago

arcturien commented 1 year ago

It seems like the .env file I've copy-pasted from AutoGpt is not working.

Questions : 1 - Where is the template for the .env file ? 2 - How to pass the openai_api_key while running ChromeGPT ?

Thanks in advance.

Tomazazs commented 1 year ago

in cmd. $Env:OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxx"

arcturien2 commented 1 year ago

Thanks a lot,

I'll test this tomorrow !!!

arcturien commented 1 year ago

Oops, I got this error, any other option?

Error: Got unexpected extra argument ($Env:OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxx)

Thanks in advance.

arcturien commented 1 year ago

Got it !!!

In the following article I can see that the key can be set in sys var (Windows). https://korben.info/chrome-gpt-controle-session-chrome-auto-gpt-langchain.html

p6002 commented 1 year ago

in cmd. $Env:OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxx"

:OPENAI_API_KEY=: command not found

arcturien commented 1 year ago

Create and Modify Environment Variables on Windows : https://docs.oracle.com/en/database/oracle/machine-learning/oml4r/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0

p6002 commented 1 year ago

I use Ubuntu Server 22

arcturien commented 1 year ago

You can ask ChatGPT :

To add an environment variable on Ubuntu Server 22, you can follow these steps:

  1. Open a terminal on your Ubuntu Server.

  2. Run the following command to open the .bashrc file in a text editor:

    nano ~/.bashrc
  3. In the text editor, scroll to the end of the file and add the following line:

    export OPENAI_API_KEY="your_api_key_here"

    Replace "your_api_key_here" with your actual OpenAI API key.

  4. Press Ctrl+O to save the file, and then press Enter to confirm the filename.

  5. Press Ctrl+X to exit the text editor.

At this point, the OPENAI_API_KEY environment variable is added to your .bashrc file. However, to make it effective in the current terminal session, you need to run the following command:

source ~/.bashrc

Now, the OPENAI_API_KEY environment variable is available for the current session. You can access it in your scripts or use it directly in the terminal.

If you want the environment variable to be available globally for all users and across all sessions, you can add it to the /etc/environment file instead of the .bashrc file. However, modifying the global environment variables may require administrative privileges.

Remember to keep your API key secure and avoid sharing it publicly or committing it to version control repositories.