Kav-K / GPTDiscord

A robust, all-in-one GPT interface for Discord. ChatGPT-style conversations, image generation, AI-moderation, custom indexes/knowledgebase, youtube summarizer, and more!
MIT License
1.81k stars 306 forks source link

[BUG] Unable to set ALLOWED_GUILDS #41

Closed cooperlees closed 1 year ago

cooperlees commented 1 year ago

Describe the bug I added the new params to env and hit:

cooper@us:~$ docker run --name gpt3discord -v /containers/gpt3discord/env:/bin/.env -v /containers/gpt3discord/data:/data gpt3discord:latest
Traceback (most recent call last):
  File "/bin/gpt3discord", line 10, in <module>
    from cogs.draw_image_generation import DrawDallEService
  File "/usr/local/lib/python3.9/site-packages/cogs/draw_image_generation.py", line 18, in <module>
    ALLOWED_GUILDS = EnvService.get_allowed_guilds()
  File "/usr/local/lib/python3.9/site-packages/models/env_service_model.py", line 23, in get_allowed_guilds
    raise ValueError(
ValueError: ALLOWED_GUILDS is not defined properly in the environment file!Please copy your server's guild ID and put it into ALLOWED_GUILDS in the .env file.For example a line should look like: `ALLOWED_GUILDS="971268468148166697"`f

My env:

cooper@us:~/repos/GPT3Discord$ cat /containers/gpt3discord/env
DATA_DIR="/data"

OPENAI_TOKEN="NO"

DISCORD_TOKEN="NONO"

ALLOWED_GUILDS="811050810460078100"
ALLOWED_ROLES="Admin,gpt"
DEBUG_GUILD="811050810460078100"
DEBUG_CHANNEL="1058174617287663689"

To Reproduce Run from trunk with my config

Expected behavior Start and download the files ...

Close away if you're working on this. I found this trying to move to latest published docker containers via ansible.

Kav-K commented 1 year ago

Hey cooper, I'm not sure why this is happening and apologies for this. I have a feeling it may be due to my use of os.getenv, but then again, it seems to be getting your DEBUG_GUILD and DEBUG_CHANNEL correctly..

The snippet responsible for retrieving the allowed guilds is:

        try:
            allowed_guilds = os.getenv("ALLOWED_GUILDS")
        except:
            allowed_guilds = None

        if allowed_guilds is None:
            raise ValueError(
                "ALLOWED_GUILDS is not defined properly in the environment file!"
                "Please copy your server's guild ID and put it into ALLOWED_GUILDS in the .env file."
                'For example a line should look like: `ALLOWED_GUILDS="971268468148166697"`'
            )

However, this snippet is inside the models folder, I'm thinking that this may be causing issues with where it's searching for the .env file when run in a docker environment (it works without docker)? What do you think?

cooperlees commented 1 year ago

Yeah, I was confused. I'll debug more tonight / tomorrow and see if you can work it out. I'd expect all the params not to work if it was a Docker env issue.

I've just rolled back to my previous commit that was working and running that for now.

Kav-K commented 1 year ago

Sounds good, I'll be looking into it.

If you don't mind, can you give me a bit verbose instructions on how to run this locally on docker so I can recreate it? I've been having troubles and am confused by the command syntax:

docker run --name gpt3discord -v /containers/gpt3discord/env:/bin/.env -v /containers/gpt3discord/data:/data gpt3discord:latest

When I run this command, where does it pull the container from, does it directly pull the latest from dockerhub? Do I need to do anything before this command? Where do I define the .env file, is it in /bin/.env?

jphccfc commented 1 year ago

FYI I'm also getting this bugb since updating the latest release

Kav-K commented 1 year ago

@jphccfc Hey, are you also using Docker?

jphccfc commented 1 year ago

@jphccfc Hey, are you also using Docker?

No docker, I did a standard install yesterday and then ran a git update this morning to get the latest version with /commands. I'm not very familiar with docker or Linux so there's a fair bit of guesswork going in... But when i updated the env file i got the exact same error as OP

Kav-K commented 1 year ago

Can you show what your env file looks like here? With any sensitive stuff removed and replaced with placeholder data. Can you also confirm how you run the bot (the commands you use) and your OS and python version?

jphccfc commented 1 year ago

Here is the error

Traceback (most recent call last): File "/usr/local/bin/gpt3discord", line 5, in from gpt3discord import init File "/usr/local/lib/python3.10/dist-packages/gpt3discord.py", line 10, in from cogs.draw_image_generation import DrawDallEService File "/usr/local/lib/python3.10/dist-packages/cogs/draw_image_generation.py", line 15, in from models.check_model import Check File "/usr/local/lib/python3.10/dist-packages/models/check_model.py", line 6, in ALLOWED_ROLES = EnvService.get_allowed_roles() File "/usr/local/lib/python3.10/dist-packages/models/env_service_model.py", line 46, in get_allowed_roles raise ValueError( ValueError: ALLOWED_ROLES is not defined properly in the environment file!Please copy your server's role and put it into ALLOWED_ROLES in the .env file.For example a line should look like: ALLOWED_ROLES="Admin"

and here is a copy of the env file - ive changed the numbers and removed the token for obvious reasons

OPENAI_TOKEN="token here"

DISCORD_TOKEN="token here"

DEBUG_GUILD="123403763979151234"

DEBUG_CHANNEL="4321387819392941234"

ALLOWED_GUILDS="123403763979151234"

ALLOWED_ROLES="Admin,bot_gpt" ``

Kav-K commented 1 year ago

I notice that at the end of the .env that there are two apostrophes/backticks at the end, can you make sure those aren’t present in the actual .env file? Also, can you get rid of the new lines between each item and make sure there’s no extraneous newlines anywhere and try again? Let me know what happens

jphccfc commented 1 year ago

@Kav-K I removed the new lines and tried again and it presented the same error I could change the Allowed_Roles to IDs if that is another approach?

Kav-K commented 1 year ago

It looks for role names instead of IDs, so I don’t think that will work. This is odd, I was able to set the bot up on a fresh Ubuntu 20.04 instance, can you confirm what OS you’re using? I’ll be looking into this problem as soon as I get home as a top priority again

jphccfc commented 1 year ago

Ubuntu 20.04 (LTS) x 64

Kav-K commented 1 year ago

Got it! As one final attempt, could you try with python3.9?

jphccfc commented 1 year ago

Im running 3.10.6 0 how do I run gpt3discord using 3.9?

Kav-K commented 1 year ago

And also, can you try exporting ALLOWED_GUILDS as a system environment variable and see if that fixes anything?

export ALLOWED_GUILDS=“guildid” I believe

jphccfc commented 1 year ago

And also, can you try exporting ALLOWED_GUILDS as a system environment variable and see if that fixes anything?

export ALLOWED_GUILDS=“guildid” I believe

I ran that command from the GPT3Discord directory then ran gpt3discord - got the same error

alueError: ALLOWED_ROLES is not defined properly in the environment file!Please copy your server's role and put it into ALLOWED_ROLES in the .env file.For example a line should look like: `ALLOWED_ROLES="Admin"

Kav-K commented 1 year ago

Can you try running the bot with python3.10 gpt3discord.py instead of the gpt3discord binary?

jphccfc commented 1 year ago

OK - different error with python3.10 get3discord.py

File "/root/GPT3Discord/gpt3discord.py", line 10, in from cogs.draw_image_generation import DrawDallEService File "/root/GPT3Discord/cogs/draw_image_generation.py", line 19, in ALLOWED_GUILDS = EnvService.get_allowed_guilds() File "/root/GPT3Discord/models/env_service_model.py", line 32, in get_allowed_guilds allowed_guilds = [int(guild) for guild in allowed_guilds] File "/root/GPT3Discord/models/env_service_model.py", line 32, in allowed_guilds = [int(guild) for guild in allowed_guilds] ValueError: invalid literal for int() with base 10: '“guildid”'

Kav-K commented 1 year ago

You didn’t replace the guildid with the actual guildID in export ALLOWED_GUILDS=“guildid” Try setting it to the actual guild ID and try again, and hopefully it should work

@cooperlees since it’s starting to pick up when run directly with python it makes me think the binary version that pyproject builds might not be compatible with the way that I do .env, what do you think?

jphccfc commented 1 year ago

so I updated to this line in the .env file

export ALLOWED_GUILDS=“guildid”

and i get this error when i try and run it

Traceback (most recent call last): File "/usr/local/bin/gpt3discord", line 5, in from gpt3discord import init File "/usr/local/lib/python3.10/dist-packages/gpt3discord.py", line 10, in from cogs.draw_image_generation import DrawDallEService File "/usr/local/lib/python3.10/dist-packages/cogs/draw_image_generation.py", line 15, in from models.check_model import Check File "/usr/local/lib/python3.10/dist-packages/models/check_model.py", line 6, in ALLOWED_ROLES = EnvService.get_allowed_roles() File "/usr/local/lib/python3.10/dist-packages/models/env_service_model.py", line 46, in get_allowed_roles raise ValueError( ValueError: ALLOWED_ROLES is not defined properly in the environment file!Please copy your server's role and put it into ALLOWED_ROLES in the .env file.For example a line should look like: `ALLOWED_ROLES="Admin"

Kav-K commented 1 year ago

Interesting, i think the problem may be the fact that I’m calling load_dotenv() twice in separate files, I’ll try to have a possible fix up in a couple hours when I get home to see if we can make some progress

after you updated the line you ran it with the python3.10 command right? For now, to get it to work, you can run the same export command as earlier but for ALLOWED_ROLES and it should work for now

jphccfc commented 1 year ago

I tried that but still getting the same error message

jphccfc commented 1 year ago

On the off chance the .env file maybe corrupted I did redo the whol .env file again using cp sample.env .env

but got the same error

Kav-K commented 1 year ago

Got it, looking into it now, am home

Kav-K commented 1 year ago

@cooperlees and @jphccfc

I've confirmed that the issue lies in the gpt3discord executable, seemingly, when running gpt3discord with a valid .env file in the root folder, it will error out and say that ALLOWED_ROLES cannot be found. I think this is due to the way that I load my environment variables, so I'm going to try changing how I do that and see if it fixes things.

In the meanwhile, I can confirm that running the bot normally with python3.9 gpt3discord.py works for sure.

On an Ubuntu 20.04 instance, from startup to bot run, here were the commands that I ran. The commands in bold were attempts to use the gpt3discord executable, which didn't work, but the python command at the end successfully starts the bot with everything loaded:

    1  passwd
    2  ls
    3  git clone https://github.com/Kav-K/GPT3Discord.git
    4  cd GPT3Discord/
    5  sudo apt-get update
    6  sudo apt install software-properties-common
    7  sudo add-apt-repository ppa:deadsnakes/ppa
    8  sudo apt install python3.9
    9  curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
   10  python3.9 get-pip.py
   11  python3.9 -m pip install -r requirements.txt
   12  python3.9 -m pip install .python3.9 -m pip install -r requirements.txt
   13  python3.9 -m pip install .
   14  mv /home/.env .
   15  nano .env
   16  screen gpt3discord
   17  gpt3discord
   18  python3.9 gpt3discord.py
   19  history

My .env file is exactly (minus tokens):

DISCORD_TOKEN="DTK"
OPENAI_TOKEN="OTK"
DEBUG_GUILD="971268468148166697"
DEBUG_CHANNEL="971269959596515378"
ALLOWED_GUILDS="971268468148166697,1056388223078768660,1050348392544489502,706657592578932797"
ALLOWED_ROLES="Admin,gpt,gpt-optin,Verified"
Kav-K commented 1 year ago

Seems like when using the executable, it can't pick up any of the environment variables,

root@api:/home/gptbot# gpt3discord
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
Wrote PID to file the file bot.pid
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/gpt3discord.py", line 169, in init
    asyncio.get_event_loop().run_until_complete(main())
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.9/dist-packages/gpt3discord.py", line 107, in main
    debug_guild = int(os.getenv("DEBUG_GUILD"))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Removing PID file

root@api:/home/gptbot# python3.9 gpt3discord.py
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
Wrote PID to file the file bot.pid
Allowed guilds: [971268468148166697, 1056388223078768660, 1050348392544489502, 706657592578932797]
Allowed roles: ['Admin', 'gpt', 'gpt-optin', 'Verified']
Kav-K commented 1 year ago

I think I've fixed this now, I've just tested on a fresh instance with the executable and it seems to work perfectly. Try from a fresh VPS install if you still have issues @jphccfc

My commands from start to finish (they also match the README)

    1  ls
    2  git clone https://github.com/Kav-K/GPT3Discord.git
    3  cd GPT3Discord/
    4  sudo apt-get update
    5  sudo apt install software-properties-common
    6  sudo add-apt-repository ppa:deadsnakes/ppa
    7  sudo apt install python3.9
    8  curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    9  python3.9 get-pip.py
   10  python3.9 -m pip install -r requirements.txt
   11  python3.9 -m pip install .
   12  python3.9 -m pip install -r requirements.txt
   13  python3.9 -m pip install . (accidentally duplicated these lol)
   14  ls
   15  nano .env (I copied over my .env from another server)
   16  screen gpt3discord
   17  screen -r
   18  history

My .env file

DISCORD_TOKEN="TK"
OPENAI_TOKEN="TK"
DEBUG_GUILD="971268468148166697"
DEBUG_CHANNEL="971269959596515378"
ALLOWED_GUILDS="971268468148166697,1056388223078768660,1050348392544489502,706657592578932797"
ALLOWED_ROLES="Admin,gpt,gpt-optin,Verified"

Release 2.1.3 will have these changes, soon.

@cooperlees Can you confirm at your convenience if this works for Docker as well?

jphccfc commented 1 year ago

OK I tried this on my current droplet/VM and it didnt work, so I destroyed the droplet and have recreated from scartch. at step 9 I get the following error

Traceback (most recent call last): File "/root/GPT3Discord/get-pip.py", line 32207, in main() File "/root/GPT3Discord/get-pip.py", line 135, in main bootstrap(tmpdir=tmpdir) File "/root/GPT3Discord/get-pip.py", line 111, in bootstrap monkeypatch_for_cert(tmpdir) File "/root/GPT3Discord/get-pip.py", line 92, in monkeypatch_for_cert from pip._internal.commands.install import InstallCommand File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/commands/init.py", line 9, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/cli/base_command.py", line 15, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/cli/cmdoptions.py", line 24, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/cli/parser.py", line 12, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/configuration.py", line 26, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/utils/logging.py", line 29, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/utils/misc.py", line 42, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/locations/init.py", line 67, in File "", line 259, in load_module File "/tmp/tmp92sp4itb/pip.zip/pip/_internal/locations/_distutils.py", line 20, in ModuleNotFoundError: No module named 'distutils.cmd'

if i run the following steps i can continue:

sudo apt install python3-distutils Then run - python3 get-pip.py

managed to complete the rest of the commands and this is my history of commands

1  ls
2  git clone https://github.com/Kav-K/GPT3Discord.git
3  cd GPT3Discord/
4  sudo apt-get update
5  sudo apt install software-properties-common
6  sudo add-apt-repository ppa:deadsnakes/ppa
7  sudo apt install python3.9
8  curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
9  python3.9 get-pip.py

10 sudo apt install python3-distutils 11 python3 get-pip.py 12 python3.9 -m pip install -r requirements.txt 13 python3 -m pip install -r requirements.txt 14 python3.9 -m pip install 15 python3 -m pip install 16 python3 -m pip install -r requirements.txt 17 ls 18 cp sample.env .env 19 nano .env 20 screen gpt3discord 21 ls 22 screen python3 gpt3discord.py

QUESTION: For an update to the git, will this process have to be followed every time or is there a simpler way to update from git?

Kav-K commented 1 year ago

That's weird that distutils didn't come packaged in your droplet but it did for me, what type of droplet did you create?

But sounds good, so this worked after you installed distutils and the bot started up?

I will update the README to include distutils

For an update to git, you don't need to repeat this process, this only happened because there was something broken, from now on, you should be able to just pull the code and run it right away without problem

jphccfc commented 1 year ago

I'm running a standard droplet on Ubuntu 20.04 (LTS) x 64. So In future i can just do a git pull from the GPT3Discord directory and then restart the gpt3discord?

Kav-K commented 1 year ago

Yeah, that's correct

jphccfc commented 1 year ago

Thanks for all your help, 👍

Kav-K commented 1 year ago

My pleasure! I will close this issue after cooper confirms that it works on Docker//after I figure out how to confirm myself, feel free to reopen or create another issue if there's future problems

justinmcp commented 1 year ago

Changing load_dotenv to look in the cwd wont work for the docker case as mentioned in readme; path to .env is defined as /bin/.env.

Kav-K commented 1 year ago

Changing load_dotenv to look in the cwd wont work for the docker case as mentioned in readme; path to .env is defined as /bin/.env.

I see, yeah that makes sense, thank you for the clarification, do you have any suggestions on how to get around this? I want to add some sort of selector that changes the load_dotenv param to /bin/.env if docker is detected, is there a way to check if execution of the program is happening in Docker?

Kav-K commented 1 year ago

I’m thinking: we can pass an environment variable when running this with docker, and then some code that checks the environment variable would make load_dotenv look in /bin/.env, is this a viable approach?

justinmcp commented 1 year ago

load_dotenv seems to travel back up from dir hierarchy from the src python. Quickest (but not nicest) thing would be to add WORKDIR /bin before CMD in the Docker file.

Might be nicer if we made an /opt/gpt3discord, dropped everything in there (instead of bin). Could also copy the static data (various *.txt) into there, and leave DATA_DIR for downloads/images etc.

justinmcp commented 1 year ago

@Kav-K Something like; https://github.com/Kav-K/GPT3Discord/pull/53. Not working, but I am not sure if not working because it never worked (in my env) or the changes, this is my first time through here. Please check.

cooperlees commented 1 year ago

Happy to change the layout of docker. I was just going for something "working" with my first diffs, then wanted to cleanup some thing. Especially the env config CWD expectation. Ideally I'd love to explicitly pass (which we can now) to gpt3discord where it's env/conf file is so we don't have to put it in CWD and workout where that is.

/opt will work, but why? A docker container is built for the software of purpose, so we can just use /bin and /etc ... But I can like with #53 if others like it.

Kav-K commented 1 year ago

I've commented on #53, apologies for getting back on here so late, I thought I replied here earlier. Running #53 seems to error locally, I will try testing myself and attempt to fix it shortly but my docker expertise is incredibly lacking

cooperlees commented 1 year ago

So I haven't had time - But tried again to move to latest gpt3discord via docker:

ModuleNotFoundError: No module named 'cogs'
Traceback (most recent call last):
  File "/bin/gpt3discord", line 10, in <module>
    from cogs.draw_image_generation import DrawDallEService
ModuleNotFoundError: No module named 'cogs'

So we've regressed more. I was hoping it worked, but I've rolled back to my super old version again as I don't have time to debug right now.

As for verbose docker instructions - I put them into the README.md with my PRs.

jphccfc commented 1 year ago

I also upgraded to the latest version and got the same error as @cooperlees . I ended up building from scratch again as in destroying then droplet and rebuilding one to get it working again

Kav-K commented 1 year ago

I'm working on this but unfortunately not having much luck, but will continue going at it

I also upgraded to the latest version and got the same error as @cooperlees . I ended up building from scratch again as in destroying then droplet and rebuilding one to get it working again

For now, can you use the plain python version instead of docker to run it @jphccfc? I know the base python version has no issues currently

YinXiangz commented 1 year ago

i also upgraded to the latest version Non-Docker:

PS C:\Users\USER> cd "D:\owo discord bot\GPT3Discord-main"
PS D:\owo discord bot\GPT3Discord-main> python "gpt3discord.py"
The environment file is located at D:\owo discord bot\GPT3Discord-main\.env
Traceback (most recent call last):
  File "D:\owo discord bot\GPT3Discord-main\gpt3discord.py", line 19, in <module>
    from cogs.draw_image_generation import DrawDallEService
  File "D:\owo discord bot\GPT3Discord-main\cogs\draw_image_generation.py", line 18, in <module>
    ALLOWED_GUILDS = EnvService.get_allowed_guilds()
  File "D:\owo discord bot\GPT3Discord-main\models\env_service_model.py", line 23, in get_allowed_guilds
    raise ValueError(
ValueError: ALLOWED_GUILDS is not defined properly in the environment file!Please copy your server's guild ID and put it into ALLOWED_GUILDS in the .env file.For example a line should look like: `ALLOWED_GUILDS="971268468148166697"`
PS D:\owo discord bot\GPT3Discord-main> python
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32

My env:

OPENAI_TOKEN = "TK"
DISCORD_TOKEN = "TK"
DEBUG_GUILD = "1046141980926820462"  # discord_server_id
DEBUG_CHANNEL = "1059046332821671996"  # discord_chanel_id
ALLOWED_GUILDS = "1046141980926820462"

# People with the roles in ADMIN_ROLES can use admin commands like /clear-local, and etc
ADMIN_ROLES = "beta"
# People with the roles in DALLE_ROLES can use commands like /dalle draw or /dalle imgoptimize
DALLE_ROLES = "beta"
# People with the roles in GPT_ROLES can use commands like /gpt ask or /gpt converse
GPT_ROLES = "beta"

WELCOME_MESSAGE = "Hi There! Welcome to our Discord server. We hope you'll enjoy our server and we look forward to engaging with you!"
Kav-K commented 1 year ago

i also upgraded to the latest version Non-Docker:

PS C:\Users\USER> cd "D:\owo discord bot\GPT3Discord-main"
PS D:\owo discord bot\GPT3Discord-main> python "gpt3discord.py"
The environment file is located at D:\owo discord bot\GPT3Discord-main\.env
Traceback (most recent call last):
  File "D:\owo discord bot\GPT3Discord-main\gpt3discord.py", line 19, in <module>
    from cogs.draw_image_generation import DrawDallEService
  File "D:\owo discord bot\GPT3Discord-main\cogs\draw_image_generation.py", line 18, in <module>
    ALLOWED_GUILDS = EnvService.get_allowed_guilds()
  File "D:\owo discord bot\GPT3Discord-main\models\env_service_model.py", line 23, in get_allowed_guilds
    raise ValueError(
ValueError: ALLOWED_GUILDS is not defined properly in the environment file!Please copy your server's guild ID and put it into ALLOWED_GUILDS in the .env file.For example a line should look like: `ALLOWED_GUILDS="971268468148166697"`
PS D:\owo discord bot\GPT3Discord-main> python
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32

My env:

OPENAI_TOKEN = "TK"
DISCORD_TOKEN = "TK"
DEBUG_GUILD = "1046141980926820462"  # discord_server_id
DEBUG_CHANNEL = "1059046332821671996"  # discord_chanel_id
ALLOWED_GUILDS = "1046141980926820462"

# People with the roles in ADMIN_ROLES can use admin commands like /clear-local, and etc
ADMIN_ROLES = "beta"
# People with the roles in DALLE_ROLES can use commands like /dalle draw or /dalle imgoptimize
DALLE_ROLES = "beta"
# People with the roles in GPT_ROLES can use commands like /gpt ask or /gpt converse
GPT_ROLES = "beta"

WELCOME_MESSAGE = "Hi There! Welcome to our Discord server. We hope you'll enjoy our server and we look forward to engaging with you!"

Hi there, I'm not able to reproduce your errors on my local windows environment. I cloned the repo, installed the requirements.txt (with the same python version as you), placed my .env file in the same directory as I was running the python command, and it seems to work correctly. Can you please double check that the token is correct?

Kav-K commented 1 year ago

image

This is how I ran it locally on windows, and this is what my .env file looks like:

DISCORD_TOKEN="MTAVH5OybnQgbiLu-gKt4"
OPENAI_TOKEN="sk-cobNReT"
DEBUG_GUILD="971268468148166697"
DEBUG_CHANNEL="971269959596515378"
ALLOWED_GUILDS = "971268468148166697"
ADMIN_ROLES="Admin"
MODERATIONS_ALERT_CHANNEL="971269959596515378"
PINECONE_TOKEN=""
MX10-AC2N commented 1 year ago

I try the last docker release but same problem with ALLOWED_GUILDS

Traceback (most recent call last):
  File "/bin/gpt3discord", line 22, in <module>
    from cogs.draw_image_generation import DrawDallEService
  File "/usr/local/lib/python3.9/site-packages/cogs/draw_image_generation.py", line 18, in <module>
    ALLOWED_GUILDS = EnvService.get_allowed_guilds()
  File "/usr/local/lib/python3.9/site-packages/models/env_service_model.py", line 23, in get_allowed_guilds
    raise ValueError(
ValueError: ALLOWED_GUILDS is not defined properly in the environment file!Please copy your server's guild ID and put it into ALLOWED_GUILDS in the .env file.For example a line should look like: `ALLOWED_GUILDS="971268468148166697"`

but my .env is correctly configured with ALLOWED_GUILDS="myserver#ID"

jphccfc commented 1 year ago

I'm working on this but unfortunately not having much luck, but will continue going at it

I also upgraded to the latest version and got the same error as @cooperlees . I ended up building from scratch again as in destroying then droplet and rebuilding one to get it working again

For now, can you use the plain python version instead of docker to run it @jphccfc? I know the base python version has no issues currently

HI @Kav-K apologies I should have clarified, my issue occurred post a "git pull" update in the python version, Im not using docker.

cherryroots commented 1 year ago

While a little hacky, I had it working just fine with passing --env-file to docker and removing quotes from the .env file on the current main branch. So can't notice any other docker specific regressions other than opener files not being able to be opened from the shared data directory. So it looked a little something like docker run -d --name gpt3discord --env-file ./.env -v /home/bots/discord_bots/GPT3Discord/docker/:/data gpt3discord docker parses env files in a weird way so I had to remove the quotes just to test

cherryroots commented 1 year ago

@YinXiangz Have you tried running it from a path that doesn't include a space in a folder name?