From a247e8af67a8faf0f5329eee9a2c85d45290884a Mon Sep 17 00:00:00 2001 From: mudler Date: Sat, 29 Apr 2023 23:54:05 +0200 Subject: [PATCH] docs: add discord-bot example --- examples/discord-bot/.env.example | 6 +++++ examples/discord-bot/README.md | 28 ++++++++++++++++++++++++ examples/discord-bot/docker-compose.yaml | 23 +++++++++++++++++++ examples/discord-bot/models | 1 + 4 files changed, 58 insertions(+) create mode 100644 examples/discord-bot/.env.example create mode 100644 examples/discord-bot/README.md create mode 100644 examples/discord-bot/docker-compose.yaml create mode 120000 examples/discord-bot/models diff --git a/examples/discord-bot/.env.example b/examples/discord-bot/.env.example new file mode 100644 index 00000000..7f94e673 --- /dev/null +++ b/examples/discord-bot/.env.example @@ -0,0 +1,6 @@ +OPENAI_API_KEY=x +DISCORD_BOT_TOKEN=x +DISCORD_CLIENT_ID=x +OPENAI_API_BASE=http://api:8080 +ALLOWED_SERVER_IDS=x +SERVER_TO_MODERATION_CHANNEL=1:1 diff --git a/examples/discord-bot/README.md b/examples/discord-bot/README.md new file mode 100644 index 00000000..6053ae87 --- /dev/null +++ b/examples/discord-bot/README.md @@ -0,0 +1,28 @@ +# discord-bot + +## Setup + +```bash +# Clone LocalAI +git clone https://github.com/go-skynet/LocalAI + +cd LocalAI/examples/discord-bot + +git clone https://github.com/go-skynet/gpt-discord-bot.git + +# (optional) Checkout a specific LocalAI tag +# git checkout -b build + +# Download gpt4all-j to models/ +wget https://gpt4all.io/models/ggml-gpt4all-j.bin -O models/ggml-gpt4all-j + +# Set the discord bot options +cp -rfv .env.example .env +vim .env + +# start with docker-compose +docker-compose up -d --build +``` + +Open up the URL in the console and give permission to the bot in your server. Start a thread with `/chat ..` + diff --git a/examples/discord-bot/docker-compose.yaml b/examples/discord-bot/docker-compose.yaml new file mode 100644 index 00000000..19056d50 --- /dev/null +++ b/examples/discord-bot/docker-compose.yaml @@ -0,0 +1,23 @@ +version: '3.6' + +services: + api: + image: quay.io/go-skynet/local-ai:latest + build: + context: ../../ + dockerfile: Dockerfile.dev + ports: + - 8080:8080 + environment: + - DEBUG=true + - MODELS_PATH=/models + volumes: + - ./models:/models:cached + command: ["/usr/bin/local-ai" ] + + bot: + build: + context: ./gpt-discord-bot + dockerfile: Dockerfile + env_file: + - .env diff --git a/examples/discord-bot/models b/examples/discord-bot/models new file mode 120000 index 00000000..7055d2b8 --- /dev/null +++ b/examples/discord-bot/models @@ -0,0 +1 @@ +../chatbot-ui/models/ \ No newline at end of file