Merge branch 'main' into fixcomp

Signed-off-by: Kaveen Kumarasinghe <k5kumara@uwaterloo.ca>
Kaveen Kumarasinghe 2 years ago committed by GitHub
commit 9bcf252fb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,7 +9,11 @@ from services.moderations_service import Moderation, ThresholdSet
MOD_DB = None MOD_DB = None
try: try:
print("Attempting to retrieve the General and Moderations DB") print("Attempting to retrieve the General and Moderations DB")
MOD_DB = SqliteDict("main_db.sqlite", tablename="moderations", autocommit=True) MOD_DB = SqliteDict(
EnvService.find_shared_file("main_db.sqlite"),
tablename="moderations",
autocommit=True,
)
except Exception as e: except Exception as e:
print("Failed to retrieve the General and Moderations DB") print("Failed to retrieve the General and Moderations DB")
raise e raise e

@ -49,8 +49,16 @@ MOD_DB = None
GENERAL_DB = None GENERAL_DB = None
try: try:
print("Attempting to retrieve the General and Moderations DB") print("Attempting to retrieve the General and Moderations DB")
MOD_DB = SqliteDict("main_db.sqlite", tablename="moderations", autocommit=True) MOD_DB = SqliteDict(
GENERAL_DB = SqliteDict("main_db.sqlite", tablename="general", autocommit=True) EnvService.find_shared_file("main_db.sqlite"),
tablename="moderations",
autocommit=True,
)
GENERAL_DB = SqliteDict(
EnvService.find_shared_file("main_db.sqlite"),
tablename="general",
autocommit=True,
)
print("Retrieved the General and Moderations DB") print("Retrieved the General and Moderations DB")
except Exception as e: except Exception as e:
print("Failed to retrieve the General and Moderations DB. The bot is terminating.") print("Failed to retrieve the General and Moderations DB. The bot is terminating.")

@ -80,38 +80,58 @@ To connect with ssh, run the following command in terminal:
It will then prompt you for your password, which you should enter, and then you will be logged in. It will then prompt you for your password, which you should enter, and then you will be logged in.
After login, we need to install the various dependencies that the bot needs. To do this, we will run the following commands: ## After login, we need to install the various dependencies that the bot needs. To do this, we will run the following commands:
#### Clone the project files
```shell ```shell
git clone https://github.com/Kav-K/GPT3Discord.git git clone https://github.com/Kav-K/GPT3Discord.git
cd GPT3Discord/ cd GPT3Discord/
# Install system packages (python) ````
#### Install system packages (python)
```shell
sudo apt-get update sudo apt-get update
sudo apt install software-properties-common sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9 sudo apt install python3.9
sudo apt install python3.9-distutils # If this doesn't work, try sudo apt install python3-distutils sudo apt install python3.9-distutils # If this doesn't work, try sudo apt install python3-distutils
# Install Pip for python3.9 ```
#### Install Pip for python3.9
```shell
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py python3.9 get-pip.py
# Install project dependencies ```
#### Install project dependencies
```
python3.9 -m pip install --ignore-installed PyYAML python3.9 -m pip install --ignore-installed PyYAML
python3.9 -m pip install torch==1.9.1+cpu torchvision==0.10.1+cpu -f https://download.pytorch.org/whl/torch_stable.html python3.9 -m pip install torch==1.9.1+cpu torchvision==0.10.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
python3.9 -m pip install -r requirements.txt python3.9 -m pip install -r requirements.txt
python3.9 -m pip install . python3.9 -m pip install .
# Copy the sample.env file into a regular .env file. `DEBUG_GUILD` and the ID for `ALLOWED_GUILDS` can be found by right-clicking your server and choosing "Copy ID". Similarly, `DEBUG_CHANNEL` can be found by right-clicking your debug channel. ```
#### Copy the sample.env file into a regular .env file. `DEBUG_GUILD` and the ID for `ALLOWED_GUILDS` can be found by right-clicking your server and choosing "Copy ID". Similarly, `DEBUG_CHANNEL` can be found by right-clicking your debug channel.
```shell
cp sample.env .env cp sample.env .env
# The command below is used to edit the .env file and to put in your API keys. You can right click within the ```
# editor after running this command to paste. When you are done editing, press CTRL + X, and then type Y, to save.
nano .env #### The command below is used to edit the .env file and to put in your API keys. You can right click within the editor after running this command to paste. When you are done editing, press CTRL + X, and then type Y, to save.
# Run the bot using [screen](https://www.gnu.org/software/screen/manual/screen.html) to keep it running after you disconnect from your SSH session: ```shell
nano .env
```
#### Run the bot using [screen](https://www.gnu.org/software/screen/manual/screen.html) to keep it running after you disconnect from your SSH session:
```shell
screen gpt3discord screen gpt3discord
# Hit `Ctrl+a` then `d` to detach from the running bot. ```
# The bot's screen session can be reattached:
screen -r #### Hit `Ctrl+a` then `d` to detach from the running bot. The bot's screen session can be reattached: `screen -r`
```
If the last few commands don't allow the bot to run `screen gpt3discord`, you can attempt to run the bot another way: If the last few commands don't allow the bot to run `screen gpt3discord`, you can attempt to run the bot another way:
```
``` shell
# First, navigate to the folder where the project files are # First, navigate to the folder where the project files are
screen -dmS GPTBot bash -c 'python3.9 gpt3discord.py' screen -dmS GPTBot bash -c 'python3.9 gpt3discord.py'
@ -123,7 +143,7 @@ screen -d -r {ID} # replace {ID} with the ID of the screen session you want to r
``` ```
As a last resort, you can try to run the bot using python in a basic way, with simply As a last resort, you can try to run the bot using python in a basic way, with simply
``` ```shell
cd GPT3Discord cd GPT3Discord
python3.9 gpt3discord.py python3.9 gpt3discord.py

@ -32,7 +32,7 @@ from services.environment_service import EnvService
from models.openai_model import Model from models.openai_model import Model
__version__ = "10.9.7" __version__ = "10.9.9"
PID_FILE = Path("bot.pid") PID_FILE = Path("bot.pid")

@ -347,7 +347,7 @@ class EnvService:
print( print(
"No user key database path was provided. Defaulting to user_key_db.sqlite" "No user key database path was provided. Defaulting to user_key_db.sqlite"
) )
user_key_db_path = "user_key_db.sqlite" user_key_db_path = EnvService.find_shared_file("user_key_db.sqlite")
else: else:
# append "user_key_db.sqlite" to USER_KEY_DB_PATH if it doesn't already end with .sqlite # append "user_key_db.sqlite" to USER_KEY_DB_PATH if it doesn't already end with .sqlite
if not user_key_db_path.match("*.sqlite"): if not user_key_db_path.match("*.sqlite"):

Loading…
Cancel
Save