Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript review #34

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 9 additions & 29 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Discord bot token
TOKEN=
# Discord bot token https://discord.com/developers/applications/<ID>/bot
DISCORD_TOKEN=

# What language model to use, orca is one of the lower-end models that doesn't require as much computer power as llama2
MODEL=orca

# Ollama URL
# Ollama URL (only one sever)
OLLAMA=http://localhost:11434

# Stable diffusion URL
# Stable Diffusion URL (only one server)
STABLE_DIFFUSION=http://localhost:7860

# What Discord channels to enable it in (by ID)
CHANNELS=123456789,987654321
# List of channels IDs bot will respond in (separated by commas)
# Obtain them by right-clicking on the channel and clicking "Copy ID" (ensure Developer Mode is enabled in Discord settings)
# Leave empty to respond in all channels
CHANNELS=123,356,238

# System message that the language model can understand
# Feel free to change this
Expand All @@ -38,23 +37,4 @@ Images, links, tables, LaTeX, and anything else is not supported.
If you need to use the symbols >, |, _, *, ~, @, #, :, `, put a backslash before them to escape them.

If the user is chatting casually, your responses should be only a few sentences, unless they are asking for help or a question.
Don't use unicode emoji unless needed."

# Use the system message above? (true/false)
USE_SYSTEM=true

# Use the model's system message? (true/false) If both are specified, model system message will be first
USE_MODEL_SYSTEM=true

# Require users to mention the bot to interact with it? (true/false)
REQUIRES_MENTION=true

# Whether to show a message at the start of a conversation
SHOW_START_OF_CONVERSATION=true

# Whether to use a random Ollama server or use the first available one
RANDOM_SERVER=false

# Whether to add a message before the first prompt of the conversation
INITIAL_PROMPT=""
USE_INITIAL_PROMPT=false
Don't use unicode emoji unless needed."
52 changes: 0 additions & 52 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist

*.md
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": [],
"arrowParens": "avoid",
"bracketSameLine": true,
"bracketSpacing": true,
"singleQuote": false,
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": false,
"semi": true,
"printWidth": 100
}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM node:20

COPY . .
RUN npm i --omit=dev --no-package-lock
RUN npm run build
USER node

CMD ["node","./src/index.js"]
CMD ["npm","start"]
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
<div align="center">
<h1>Discord AI Bot</h1>
<h2>Repository is now in maintanance mode - rewriting project to Typescript on <a href="https://github.com/238SAMIxD/discord-ai-bot/tree/typescript">typescript</a> branch</h2>
<h3 align="center">Discord bot to interact with <a href="https://github.com/jmorganca/ollama">Ollama</a> and <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">AUTOMATIC1111 Stable Diffusion</a> as a chatbot</h3>
<h3><img alt="Stars" src="https://img.shields.io/github/stars/mekb-turtle/discord-ai-bot?display_name=tag&style=for-the-badge" /></h3>
<h3><img alt="Discord chat with the bot" src="assets/screenshot.png" /></h3>
<h1>Discord AI Bot</h1>
<h2>Repository is now in maintanance mode - rewriting project to Typescript</h2>
<h3 align="center">Discord bot to interact with <a href="https://github.com/jmorganca/ollama">Ollama</a> and <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">AUTOMATIC1111 Stable Diffusion</a> as a chatbot</h3>
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/238samixd/discord-ai-bot?style=social">
</div>

The project started thanks to [mekb](https://github.com/mekb-turtle).

### Set-up instructions
## Roadmap

- Rewrite old options to work with the new codebase
- Add message history (storing, clearing)
- Setup channels ids to allow the bot only in specific channels
- Implement multiple servers support (copying commands?)
- Check (and fix if necessary) `Dockerfile` and `docker-compose` setup
- Review installation and usage instructions
- Create docs with examples for the bot
- Handle text attachments
- Handle image attachments (only working with vision models)
- Add slow mode option to prevent spam and GPU overload
- Write unit tests
- Create a RAG to extract information from _PDFs_ and/or docs
- Implement [OpenWebUI](https://github.com/open-webui/open-webui) interactions (web search, youtube loader)
- ? Implement [fabric](https://github.com/danielmiessler/fabric) integration (patterns, youtube video extraction if needed)
- Fix streaming issues `/chat ... stream: True`

### Set-up instructions (TO BE REVIEWED)

1. Install [Node.js](https://nodejs.org) (if you have a package manager, use that instead to install this)
- Make sure to install at least v14 of Node.js
2. Install [Ollama](https://github.com/jmorganca/ollama) (ditto)
3. Pull (download) a model, e.g `ollama pull orca` or `ollama pull llama2`
4. Start Ollama by running `ollama serve`
- Make sure to install at least v18 of Node.js (v20+ recommended)
2. Install [Ollama](https://github.com/ollama/ollama)
3. Pull (download) a model, `ollama pull MODEL` e.g `ollama pull llama3.1` - [Model list](https://ollama.com/search)
4. Start Ollama by running `ollama serve` if not already running
5. [Create a Discord bot](https://discord.com/developers/applications)
- Under Application » Bot
- Enable Message Content Intent
Expand All @@ -36,10 +53,10 @@ The project started thanks to [mekb](https://github.com/mekb-turtle).
8. Install the required dependencies with `npm i`
9. Start the bot with `npm start`
10. You can interact with the bot by @mentioning it with your message
11. Install <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">Stable Diffusion</a>
11. Install [Stable Diffusion](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
12. Run the script `./webui.sh --api --listen`

### Set-up instructions with Docker
### Set-up instructions with Docker (TO BE CHECKED)

1. Install [Docker](https://docs.docker.com/get-docker/)
- Should be atleast compatible with version 3 of compose (docker engine 1.13.0+)
Expand Down
Binary file removed assets/screenshot.png
Binary file not shown.
17 changes: 17 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.ts"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {},
rules: {},
}
);
99 changes: 0 additions & 99 deletions eslint.config.mjs

This file was deleted.

55 changes: 37 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
{
"name": "discord-ai-bot",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js"
},
"dependencies": {
"axios": "^1.6.3",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"meklog": "^1.0.2"
},
"type": "module",
"devDependencies": {
"@eslint/js": "^9.7.0",
"@types/eslint__js": "^8.42.3",
"eslint": "^9.7.0",
"globals": "^15.8.0"
}
"name": "discord-bot-template",
"version": "1.0.0",
"description": "A basic Discord bot template using TypeScript and discord.js",
"main": "dist/index.js",
"scripts": {
"start": "node dist/index.js",
"build": "tsc",
"dev": "ts-node src/index.ts"
},
"keywords": [
"discord",
"bot",
"typescript",
"discord.js"
],
"author": "238SAMIxD",
"license": "ISC",
"dependencies": {
"axios": "^1.7.9",
"discord.js": "^14.14.1",
"dotenv": "^16.4.5",
"meklog": "^1.0.2"
},
"devDependencies": {
"@eslint/js": "^9.20.0",
"@jest/globals": "^29.7.0",
"@types/eslint__js": "^8.42.3",
"@types/node": "^20.11.24",
"eslint": "^9.20.1",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.3",
"globals": "^15.15.0",
"prettier": "^3.5.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.2",
"typescript-eslint": "^8.24.0"
}
}
Loading