Comments (16)
You have to rename the file to just .env
π
from auto-gpt.
I've found the solution: open the folder in Visual Studio Code and rename the .env.template file from there. It remains as .env.template when I first opened it in VS Code. It seems that Finder on Mac doesn't actually change the file name.
from auto-gpt.
from auto-gpt.
Make sure you copy the entre key in, sometimes they have a "-" in them that can make you miss a section of it when highlighting.
from auto-gpt.
I have a .env file in the root directory, with python-dotenv library installed, with the full key "sk-XYZ..." without quotes, but I'm still getting this:
Traceback (most recent call last):
File "C:\Users\PC\Auto-GPT\scripts\main.py", line 286, in <module>
assistant_reply = chat.chat_with_ai(
File "C:\Users\PC\Auto-GPT\scripts\chat.py", line 110, in chat_with_ai
assistant_reply = create_chat_completion(
File "C:\Users\PC\Auto-GPT\scripts\llm_utils.py", line 9, in create_chat_completion
response = openai.ChatCompletion.create(
File "C:\Python310\lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
File "C:\Python310\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "C:\Python310\lib\site-packages\openai\api_requestor.py", line 226, in request
resp, got_stream = self._interpret_response(result, stream)
File "C:\Python310\lib\site-packages\openai\api_requestor.py", line 619, in _interpret_response
self._interpret_response_line(
File "C:\Python310\lib\site-packages\openai\api_requestor.py", line 682, in _interpret_response_line
raise self.handle_error_response(
openai.error.AuthenticationError: Incorrect API key provided: null. You can find your API key at https://platform.openai.com/account/api-keys.
from auto-gpt.
You have to rename the file to just
.env
π
Might still not work properly
I added some print() to debug and I'm getting this:
PS C:\Users\PC\Auto-GPT> python scripts/main.py continuous-mode
env_path: .env
.env file exists: True
OPENAI_API_KEY: null
Config openai_api_key: null
from auto-gpt.
So you have a file called .env
that contains the keys? π€
from auto-gpt.
So you have a file called
.env
that contains the keys? π€
Yes, tried having it in both root and /scripts directory, with or without quotations marks around the key, to no avail
Does it works on your end?
from auto-gpt.
Yep, must be in the root directory and no quotes.
from auto-gpt.
I'm unable to reproduce this.. Sorry!
Is anyone else experiencing this?
Try cloning a fresh copy and setup the .env file again.
Are you using a virtual environment?
from auto-gpt.
(trying unmodified config.py made no change to output)
from auto-gpt.
I'm unable to reproduce this.. Sorry! Is anyone else experiencing this?
Try cloning a fresh copy and setup the .env file again.
Are you using a virtual environment?
No venv and on windows 11 22H2
Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
What about you?
from auto-gpt.
Name: NextJS-13-Developer
Role: You are a skilled and experienced developer with a strong background in web development and experience in building e-commerce sites using Next.js 13. You have an eye for design and are able to change the style and layout of the site as needed to meet the client's needs. You have excellent communication skills and are able to ask questions when needed to ensure that the project is completed to the highest standard.
Goals: ['Increase net worth', 'Grow Twitter Account', 'Develop and manage multiple businesses autonomously']
Continue (y/n): y
Traceback (most recent call last):
File "C:\Users\strau\Downloads\Auto-GPT\scripts\main.py", line 279, in
assistant_reply = chat.chat_with_ai(
^^^^^^^^^^^^^^^^^^
File "C:\Users\strau\Downloads\Auto-GPT\scripts\chat.py", line 110, in chat_with_ai
assistant_reply = create_chat_completion(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\strau\Downloads\Auto-GPT\scripts\llm_utils.py", line 9, in create_chat_completion
response = openai.ChatCompletion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
return super().create(*args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 226, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 619, in _interpret_response
self._interpret_response_line(
File "C:\Python311\Lib\site-packages\openai\api_requestor.py", line 682, in _interpret_response_line
raise self.handle_error_response(
openai.error.AuthenticationError: Incorrect API key provided: <sk-JW3R***************************************Caq>. You can find your API key at https://platform.openai.com/account/api-keys.
PS C:\Users\strau\Downloads\Auto-GPT>
still broke Ive done everything you all spoke about to no avail HELP
from auto-gpt.
Hey, I just found a solution.
As you can see, python scripts use os.getenv
that allows you to retrieve the value of an environment variable. So even if you set OPENAI_API_KEY
to .env
, it's impossible to retrieve it when the same key is registered as an environment variable.
First, check your value in a console.
$ python
>>> import os
>>> api_key = os.getenv("OPENAI_API_KEY")
>>> print("OPENAI_API_KEY:", api_key)
OPENAI_API_KEY: <your API key>
If the value is different from the value in the .env file, there might be a high possibility that an environment variable has already been set.
$ printenv
...
OPENAI_API_KEY=<your API key>
So by unsetting the value in OPENAI_API_KEY
, the value of the .env file becomes available temporarily.
$ unset OPENAI_API_KEY
However, it is probably due to the fact that the environment variable values are fixed in the shell settings, so the best way is to update the value to the correct one. In my case, I used the wrong value that had been set up in ~/.zshrc
.
// .zshrc
source "$HOME/.openai_key.zsh"
// .openai_key.zsh
export OPENAI_API_KEY=<wrong key>
from auto-gpt.
Hey, I just found a solution.
As you can see, python scripts use
os.getenv
that allows you to retrieve the value of an environment variable. So even if you setOPENAI_API_KEY
to.env
, it's impossible to retrieve it when the same key is registered as an environment variable.First, check your value in a console.
$ python >>> import os >>> api_key = os.getenv("OPENAI_API_KEY") >>> print("OPENAI_API_KEY:", api_key) OPENAI_API_KEY: <your API key>If the value is different from the value in the .env file, there might be a high possibility that an environment variable has already been set.
$ printenv ... OPENAI_API_KEY=<your API key>So by unsetting the value in
OPENAI_API_KEY
, the value of the .env file becomes available temporarily.$ unset OPENAI_API_KEY
However, it is probably due to the fact that the environment variable values are fixed in the shell settings, so the best way is to update the value to the correct one. In my case, I used the wrong value that had been set up in
~/.zshrc
.// .zshrc source "$HOME/.openai_key.zsh" // .openai_key.zsh export OPENAI_API_KEY=<wrong key>
Which code should I type to fix the issue?
from auto-gpt.
Make sure that there's the value of OPENAI_API_KEY
between .env file under the Auto-GPT directory and environment variables. Run the following command in your shell.
$ printenv
...
OPENAI_API_KEY=<your API key>
Remember the above key. If the different variable in OPENAI_API_KEY
is set as an environment variable, you have to consider unsetting or changing it.
// temporary solution
$ unset OPENAI_API_KEY
The way of changing an environment variable depends on your environment, so I can't propose you a proper answer.
from auto-gpt.
Related Issues (20)
- How to solve this problem
- how to remove login accesse page
- Add support for Image, Video, and Audio input into Forge and AutoGPT
- The discord link is expired. HOT 1
- ./run setup quits at Setup initiated... HOT 17
- support for gpt-4o? HOT 2
- after login agent and create a task but dosen't work
- cant setup HOT 5
- GPT4O HOT 1
- Auto GPT not connect to AzureOPEN AI
- Error when trying to run AutoGPT once pointed at Local AI instance on localhost
- getting error while running HOT 2
- Running the ./run agent start agent name error HOT 15
- Connexion serveur locale http://localhost:8000 erreur clΓ©e API pour le service "docker-compose run --rm auto-gpt serve" HOT 1
- Macbook intel chip the instructions not clear at all.
- Windows support on releases after 0.4.7 HOT 6
- Install Issue
- Error loading ASGI app. Could not import module "forge.app". HOT 12
- File paths for images in forge docs are out of date HOT 2
- Web_search doesnβt work and needs replaced HOT 4
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 auto-gpt.