From db4ddbbdf94f479d13b906807ebd330f113dfc01 Mon Sep 17 00:00:00 2001 From: Paillat Date: Fri, 20 Jan 2023 13:38:37 +0100 Subject: [PATCH] Some things --- .env.example | 3 +++ README.md | 13 +++---------- code/main.py | 5 +---- 3 files changed, 7 insertions(+), 14 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..53cb6b4 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +TOKEN=YOUR DISCORD BOT TOKEN HERE +OPENAI=YOUR OPENAI API KEY HERE +USE_IMAGES=No \ No newline at end of file diff --git a/README.md b/README.md index a00c04e..c81dfcf 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,7 @@ irm get.scoop.sh | iex scoop install marp ``` - Restart your computer -- Create a file named `key.env` and put your openai api key in it -- Create a file named `token.env` and put your discord bot token in it -- In the main.py file, at the first line, enable or disable the image generation (by default it's disabled) -```python -# Enable or disable image generation -use_images = False -``` +- Put your openai api key and discord bot token in the `.env.example` file and rename it to `.env` ## Image generation (optional) ### With Stable Diffusion UI (powerful gpu option) @@ -51,10 +45,9 @@ use_images = False pip install uvicorn pip install fastapi ``` -- In the file `main.py`, at the first line, enable or disable the `sd` image generation. +- In the file `.env`, set the `USE_IMAGES` variable to `sd` ### With DALLĀ·E 2 (costs dalle credits) -- In the file `main.py`, at the first line, enable or disable the dalle image generation. - +- In the file `.env`, set the `USE_IMAGES` variable to `dalle` # Running - Run the `main.py` file with : ``` diff --git a/code/main.py b/code/main.py index 510a0a3..1028ecf 100644 --- a/code/main.py +++ b/code/main.py @@ -1,7 +1,3 @@ -#Uncomment you prefered images generation method -#use_images = "dalle" # generate images remotely with dalle 2 in your openai account -use_images = "sd" # generate images locally with stable diffusion sdkit ui (instructions in the readme) -#use_images = "No" # no images import openai # from openai import api_key import discord @@ -15,6 +11,7 @@ import datetime import base64 import requests from dotenv import load_dotenv +use_images = os.getenv("USE_IMAGES") if use_images != "No": import imagesGeneration logging.basicConfig(level=logging.INFO) imageint = ""