Comments (33)
@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?
from loopgpt.
seems like we might be able to close this now
from loopgpt.
@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
from loopgpt.
maybe its possible docker is messing it up. I can try to pull fresh
from loopgpt.
I'm using it w/o docker
from loopgpt.
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
agent.cli()
File "C:\Users\tumol\AppData\Local\Programs\Python\Python311\Lib\site-packages\loopgpt\agent.py", line 471, in cli
cli(self, continuous=continuous)
File "C:\Users\tumol\AppData\Local\Programs\Python\Python311\Lib\site-packages\loopgpt\loops\repl.py", line 114, in cli
resp = agent.chat()
^^^^^^^^^^^^
File "C:\Users\tumol\AppData\Local\Programs\Python\Python311\Lib\site-packages\loopgpt\utils\spinner.py", line 137, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tumol\AppData\Local\Programs\Python\Python311\Lib\site-packages\loopgpt\agent.py", line 173, in chat
resp = self.model.chat(
^^^^^^^^^^^^^^^^
File "C:\Users\tumol\AppData\Local\Programs\Python\Python311\Lib\site-packages\loopgpt\models\openai_.py", line 32, in chat
api_key = getkey(self.api_key)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tumol\AppData\Local\Programs\Python\Python311\Lib\site-packages\loopgpt\models\openai.py", line 12, in _getkey
raise ValueError(
ValueError: OpenAI API Key not found. Please set the OPENAI_API_KEY
environment variable. See https://github.com/farizrahman4u/loopgpt#-requirements for more details`
from loopgpt.
naw, python and the .env should be able to handle that for you
from loopgpt.
yes that passes the key
from loopgpt.
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!
from loopgpt.
@devsktlabs ♾️🕵️♂️
from loopgpt.
Inside loopgpt dir rename [.env.template] to [.env] and change the "REPLACE-THIS-WITH-YOUR-API-KEY" with your open ai api key
from loopgpt.
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?
from loopgpt.
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.
from loopgpt.
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?
from loopgpt.
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.
from loopgpt.
Using windows 11
from loopgpt.
@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 :-)
from loopgpt.
I've tried like this
OPENAI_API_KEY = "sk-mykey"
also like this
OPENAI_API_KEY=sk-mykey
from loopgpt.
Using autogpt daily and no issues on that one btw
from loopgpt.
same here but I'm not facing issues on either repo :-)
what does the CLI output or error look like? screenshot or something?
from loopgpt.
from loopgpt.
which directory is the .env file? is the name of the .env file exactly that without whitespace?
from loopgpt.
Same outcome with a fresh clone... hmm at a loss on this one
from loopgpt.
what directory are you within while trying to run your python command?
from loopgpt.
the fresh clone is in /looptest, .env is in /looptest and I am running "loopgpt run" in the same directory.
from loopgpt.
from loopgpt.
try python ./examples/research_gpt.py
from loopgpt.
is there supposed to be a specific path in my environment variables on windows that i'm missing?
from loopgpt.
its so strange that autogpt find .env in that directory but cannot with loop
from loopgpt.
@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/
from loopgpt.
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?
from loopgpt.
@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
from loopgpt.
This seems to still be an issue if downloaded via pip? Using git and pip install -e work fine, but pip install loopgpt and putting .env in the directory with my runagent.py can't find the openai key, even though the os.getenv works fine.
I think we might want users to optionally provide the agent with an environment (and propagate that to the tools, of course), so that the pip package can work without having to set environment variables.
from loopgpt.
Related Issues (20)
- How to get a Google Search API key? HOT 4
- Browser Issue: preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally HOT 4
- Running from notebook HOT 2
- agent = Agent(model="gpt-4") throws an error HOT 1
- Make this compatible with Marvin / Langchain HOT 1
- example usage with fastapi on the server HOT 1
- Spike in usage of tokens of Open AI API using gpt-4 model HOT 1
- It doesn't seem to read text files HOT 4
- AssertionError HOT 1
- Doesn't seem to notice when it hallucinates a command? HOT 1
- browser.py call to summarizer exceeds token limits
- Function call `agent.config()` throws an error if `agent.clear_state()` is called before it HOT 2
- Persistent Context Transfer Between Multiple Agents HOT 1
- Add SerpApi instead of direct Google Search
- Compatibility with Other Language Models
- Rate Limited Reached on Initial Install Running Example Script . . . HOT 2
- ImportError: cannot import name 'PROCEED_INPUT'
- Support More OpenAI Models Like gpt-3.5-turbo-16k
- bash:syntax error- Ubuntu pip install and install from source HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loopgpt.