From cffe083ff2a1a688531e23844aec9ca13dd646f1 Mon Sep 17 00:00:00 2001 From: "James C. Palmer" Date: Sun, 2 Apr 2023 05:44:45 -0400 Subject: [PATCH 1/3] Move requirements.txt to root directory. --- README.md | 2 +- scripts/requirements.txt => requirements.txt | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/requirements.txt => requirements.txt (100%) diff --git a/README.md b/README.md index 65ac6c6c..c183b97c 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ git clone https://github.com/Torantulino/Auto-GPT.git 2. Navigate to the project directory: *(Type this into your CMD window, you're aiming to navigate the CMD window to the "scripts" folder you just downloaded)* ``` -$ cd 'Auto-GPT/scripts' +$ cd 'Auto-GPT' ``` 3. Install the required dependencies: diff --git a/scripts/requirements.txt b/requirements.txt similarity index 100% rename from scripts/requirements.txt rename to requirements.txt From ef656a0f778ef7803f26164aa6484aba5c001ece Mon Sep 17 00:00:00 2001 From: "James C. Palmer" Date: Sun, 2 Apr 2023 06:11:04 -0400 Subject: [PATCH 2/3] Remove `keys.py` and replace with `python-dotenv`. - Removed `keys.py`. - Added `.env.template`. - Added `.env` to `.gitignore`. - Updated various files that imported `keys` to use `os.getenv` instead. - Updated `requirements.txt` dependencies. - Updated README.md with instructions on setting up environment variables. This change improves security, flexibility, and makes it easier to use Auto-GPT in notebooks. Environment variables are stored in `.env` and loaded via `load_dotenv()` in `scripts/main.py`. --- .env.template | 2 ++ .gitignore | 3 ++- README.md | 17 +++++++++-------- requirements.txt | 11 ++++++----- scripts/chat.py | 4 ++-- scripts/keys.py | 5 ----- scripts/main.py | 5 +++++ scripts/speak.py | 4 ++-- 8 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 .env.template delete mode 100644 scripts/keys.py diff --git a/.env.template b/.env.template new file mode 100644 index 00000000..a598aa7b --- /dev/null +++ b/.env.template @@ -0,0 +1,2 @@ +OPENAI_API_KEY=your-openai-api-key +ELEVENLABS_API_KEY=your-elevenlabs-api-key diff --git a/.gitignore b/.gitignore index 4d084445..1313d98b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ scripts/__pycache__/keys.cpython-310.pyc package-lock.json *.pyc scripts/auto_gpt_workspace/* -*.mpeg \ No newline at end of file +*.mpeg +.env diff --git a/README.md b/README.md index c183b97c..e399caca 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ git clone https://github.com/Torantulino/Auto-GPT.git ``` 2. Navigate to the project directory: -*(Type this into your CMD window, you're aiming to navigate the CMD window to the "scripts" folder you just downloaded)* +*(Type this into your CMD window, you're aiming to navigate the CMD window to the repository you just downloaded)* ``` $ cd 'Auto-GPT' ``` @@ -76,22 +76,23 @@ $ cd 'Auto-GPT' pip install -r requirements.txt ``` -4. Edit the file named "keys.py" in the "scripts" directory to add your OpenAI API key (and eleven labs key if you want speech): -*(Open the keys.py file in a text editor and follow the instructions inside, save it after)* +4. Rename `.env.template` to `.env` and fill in your `OPENAI_API_KEY`. If you plan to use Speech Mode, fill in your `ELEVEN_LABS_API_KEY` as well. + - Obtain your OpenAI API key from: https://platform.openai.com/account/api-keys. + - Obtain your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website. ## 🔧 Usage -1. Run the Python script in your terminal: +1. Run the `main.py` Python script in your terminal: *(Type this into your CMD window)* ``` -python main.py +python scripts/main.py ``` 2. After each of AUTO-GPT's actions, type "NEXT COMMAND" to authorise them to continue. 3. To exit the program, type "exit" and press Enter. ## 🗣️ Speech Mode ``` -python main.py speach-mode +python scripts/main.py speach-mode ``` ## 💀 Continuous Mode ⚠️ @@ -100,9 +101,9 @@ Continuous mode is not recommended. It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise. Use at your own risk. -1. Run the Python script in your terminal: +1. Run the `main.py` Python script in your terminal: ``` -python main.py continuous-mode +python scripts/main.py continuous-mode ``` 2. To exit the program, press Ctrl + C diff --git a/requirements.txt b/requirements.txt index 0e2e52a7..6ae3a1ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ beautifulsoup4==4.9.3 colorama==0.4.6 -googlesearch_python==1.1.0 -openai==0.27.0 -playsound==1.2.2 -readability_lxml==0.8.1 +docker==5.0.3 +googlesearch-python==1.1.0 +openai==0.27.2 +playsound==1.3.0 +python-dotenv==1.0.0 +readability-lxml==0.8.1 requests==2.25.1 -docker==6.0.1 diff --git a/scripts/chat.py b/scripts/chat.py index a406812d..f2a5a51b 100644 --- a/scripts/chat.py +++ b/scripts/chat.py @@ -1,9 +1,9 @@ +import os import time import openai -import keys # Initialize the OpenAI API client -openai.api_key = keys.OPENAI_API_KEY +openai.api_key = os.getenv("OPENAI_API_KEY") def create_chat_message(role, content): diff --git a/scripts/keys.py b/scripts/keys.py deleted file mode 100644 index 1cd439cd..00000000 --- a/scripts/keys.py +++ /dev/null @@ -1,5 +0,0 @@ -# Get yours from: https://beta.openai.com/account/api-keys -OPENAI_API_KEY = "YOUR-OPENAI-KEY" -# To access your ElevenLabs API key, head to https://elevenlabs.io, you -# can view your xi-api-key using the 'Profile' tab on the website. -ELEVENLABS_API_KEY = "YOUR-ELEVENLABS-KEY" diff --git a/scripts/main.py b/scripts/main.py index d51ad0fc..e80bf5d0 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -11,6 +11,11 @@ import speak from enum import Enum, auto import sys from config import Config +from dotenv import load_dotenv + + +# Load environment variables from .env file +load_dotenv() class Argument(Enum): diff --git a/scripts/speak.py b/scripts/speak.py index 13ceb8d9..405c100f 100644 --- a/scripts/speak.py +++ b/scripts/speak.py @@ -1,13 +1,13 @@ import os from playsound import playsound import requests -import keys + voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"] tts_headers = { "Content-Type": "application/json", - "xi-api-key": keys.ELEVENLABS_API_KEY + "xi-api-key": os.getenv("ELEVENLABS_API_KEY") } From 5e746afef8eb3f5bdb515eb918978abaf6276ea9 Mon Sep 17 00:00:00 2001 From: "James C. Palmer" Date: Sun, 2 Apr 2023 09:32:25 -0400 Subject: [PATCH 3/3] Use `load_dotenv()` in `chat.py` and `speak.py`. --- scripts/chat.py | 4 ++++ scripts/speak.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/scripts/chat.py b/scripts/chat.py index f2a5a51b..e6aa2781 100644 --- a/scripts/chat.py +++ b/scripts/chat.py @@ -1,6 +1,10 @@ import os import time import openai +from dotenv import load_dotenv + +# Load environment variables from .env file +load_dotenv() # Initialize the OpenAI API client openai.api_key = os.getenv("OPENAI_API_KEY") diff --git a/scripts/speak.py b/scripts/speak.py index 405c100f..a0f29fc5 100644 --- a/scripts/speak.py +++ b/scripts/speak.py @@ -1,8 +1,12 @@ import os from playsound import playsound import requests +from dotenv import load_dotenv +# Load environment variables from .env file +load_dotenv() + voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"] tts_headers = {