loopgpt
loopgpt copied to clipboard
Enviroment file
Hi, Could you include and inviroment file that can be edited directly?
Inside loopgpt dir rename [.env.template] to [.env] and change the "REPLACE-THIS-WITH-YOUR-API-KEY" with your open ai api key
even after adding .env file with open_api_key I receive environment variable error. api key not found. i've placed it in root directory as well as /loopgpt directory and still the same error. Anyone else running into this?
even after adding .env file with open_api_key I receive environment variable error. api key not found. i've placed it in root directory as well as /loopgpt directory and still the same error. Anyone else running into this?
OPENAI_API_KEY should be all caps. it seems to work for me.
even after adding .env file with open_api_key I receive environment variable error. api key not found. i've placed it in root directory as well as /loopgpt directory and still the same error. Anyone else running into this?
Hey @devsktlabs, can you tell me if you are using windows?
even after adding .env file with open_api_key I receive environment variable error. api key not found. i've placed it in root directory as well as /loopgpt directory and still the same error. Anyone else running into this?
Hey @devsktlabs, can you tell me if you are using windows?
I recognize you are addressing @devsktlabs directly but to clarify on my end, I am on Windows 10 and it is working for me.
Using windows 11
@devsktlabs can you copy/paste your .env
here? Please hide any sensitive data.
more detail would be good on the commands you're running, which cli you're using, etc. give us the ability to reproduce :-)
I've tried like this
OPENAI_API_KEY = "sk-mykey"
also like this
OPENAI_API_KEY=sk-mykey
Using autogpt daily and no issues on that one btw
same here but I'm not facing issues on either repo :-)
what does the CLI output or error look like? screenshot or something?

which directory is the .env file? is the name of the .env file exactly that without whitespace?
@tylerlindell Thanks for confirming its working on your end.
@devsktlabs Have you enabled "show file extension" on windows? The env file in our repo is .env.template
, so if the "show file extension" is not enabled, the .template
will be hidden. If this is the case, you need to change it so that the file name is just .env

maybe its possible docker is messing it up. I can try to pull fresh
I'm using it w/o docker
Same outcome with a fresh clone... hmm at a loss on this one
what directory are you within while trying to run your python command?
the fresh clone is in /looptest, .env is in /looptest and I am running "loopgpt run" in the same directory.

try python ./examples/research_gpt.py
PS C:\looptest> python ./examples/research_gpt.py WARNING: OpenAI API Key not found. Please set the
OPENAI_API_KEY` environment variable. LoopGPT cannot work without it. See https://github.com/farizrahman4u/loopgpt#-requirements for more details
+------------------------------------------------------------+ | ██╗░░░░░░█████╗░░█████╗░██████╗░░██████╗░██████╗░████████╗ | | ██║░░░░░██╔══██╗██╔══██╗██╔══██╗██╔════╝░██╔══██╗╚══██╔══╝ | | ██║░░░░░██║░░░░██░░░░██║██████╔╝██║░░██╗░██████╔╝░░░██║░░░ | | ██║░░░░░██║░░██║██║░░██║██╔═══╝░██║░░╚██╗██╔═══╝░░░░██║░░░ | | ███████╗╚█████╔╝╚█████╔╝██║░░░░░╚██████╔╝██║░░░░░░░░██║░░░ | | ╚══════╝░╚════╝░░╚════╝░╚═╝░░░░░░╚═════╝░╚═╝░░░░░░░░╚═╝░░░ | +------------------------------------------------------------+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Traceback (most recent call last):
File "C:\looptest\examples\research_gpt.py", line 16, in OPENAI_API_KEY
environment variable. See https://github.com/farizrahman4u/loopgpt#-requirements for more details`
is there supposed to be a specific path in my environment variables on windows that i'm missing?
naw, python and the .env should be able to handle that for you
its so strange that autogpt find .env in that directory but cannot with loop
@devsktlabs From your directory, can you open up python and run the following commands:
from dotenv import load_dotenv
import os
load_dotenv()
os.getenv("OPENAI_API_KEY")
Does that give you your api key?
yes that passes the key
@devsktlabs That makes it even worse because this is the same code we use in the repo 😨 Let me do all the steps just like you did and get back to you. In the meantime, you can set your environment variable OPENAI_API_KEY
to your key and that will definitely work. See how to set environment variables on windows here: https://www.architectryan.com/2018/08/31/how-to-change-environment-variables-on-windows-10/
yes that passes the key
looks like you're using vscode! you could try a breakpoint in the code you have there and inspect for more details.
also, I'm not as familiar with powershell - do you have git bash as a terminal option for vscode?
@devsktlabs I tried the exact same steps and it worked:
git clone https://github.com/farizrahman4u/loopgpt.git looptest
cd looptest
pip install -e .
rename .env.template -> .env replace api-key
loopgpt run
ok I removed the entire directory again including .git. started over and went the process @FayazRahman suggested and it is now working. thank you for walking me through this issue. Agents releasing!