Merge pull request #12 from chriscarrollsmith/main

Implemented .env file API key storage
pull/13/head
biobootloader 2023-04-14 13:59:44 -07:00 zatwierdzone przez GitHub
commit f2d21e7b93
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 12 dodań i 6 usunięć

1
.env.sample 100644
Wyświetl plik

@ -0,0 +1 @@
OPENAI_API_KEY=your_api_key

3
.gitignore vendored
Wyświetl plik

@ -1,2 +1,3 @@
venv
openai_key.txt
.venv
.env

Wyświetl plik

@ -13,8 +13,11 @@ For a quick demonstration see my [demo video on twitter](https://twitter.com/bio
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.sample .env
Add your openAI api key to `openai_key.txt` - _warning!_ by default this uses GPT-4 and may make many repeated calls to the api.
Add your openAI api key to `.env`
_warning!_ By default wolverine uses GPT-4 and may make many repeated calls to the api.
## Example Usage

Wyświetl plik

@ -13,6 +13,7 @@ multidict==6.0.4
openai==0.27.2
pycodestyle==2.10.0
pyflakes==3.0.1
python-dotenv==1.0.0
requests==2.28.2
six==1.16.0
termcolor==2.2.0

Wyświetl plik

@ -5,13 +5,14 @@ import os
import shutil
import subprocess
import sys
import openai
from termcolor import cprint
from dotenv import load_dotenv
# Set up the OpenAI API
with open("openai_key.txt") as f:
openai.api_key = f.read().strip()
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
def run_script(script_name, script_args):
@ -51,7 +52,6 @@ def send_error_to_gpt(file_path, args, error_message, model):
)
# print(prompt)
response = openai.ChatCompletion.create(
model=model,
messages=[