Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2caf54346a | ||
|
|
6e6467c2a5 | ||
|
|
b463b0a8cb | ||
|
|
42ef38db14 | ||
|
|
af23db20bb |
@@ -1,9 +1,6 @@
|
|||||||
# Discord token for the bot
|
# Discord token for the bot
|
||||||
CLIENT_TOKEN = BOT_TOKEN
|
CLIENT_TOKEN = BOT_TOKEN
|
||||||
|
|
||||||
# id token of a discord server
|
|
||||||
GUILD_ID = GUILD_ID
|
|
||||||
|
|
||||||
# model for the bot to query from (i.e. llama2 [llama2:13b], mistral, codellama, etc... )
|
# model for the bot to query from (i.e. llama2 [llama2:13b], mistral, codellama, etc... )
|
||||||
MODEL = MODEL_NAME
|
MODEL = MODEL_NAME
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -31,7 +31,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
touch .env
|
touch .env
|
||||||
echo CLIENT_TOKEN = ${{ secrets.BOT_TOKEN }} >> .env
|
echo CLIENT_TOKEN = ${{ secrets.BOT_TOKEN }} >> .env
|
||||||
echo GUILD_ID = ${{ secrets.GUILD_ID }} >> .env
|
|
||||||
echo MODEL = ${{ secrets.MODEL }} >> .env
|
echo MODEL = ${{ secrets.MODEL }} >> .env
|
||||||
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
||||||
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
||||||
@@ -60,7 +59,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
touch .env
|
touch .env
|
||||||
echo CLIENT_TOKEN = ${{ secrets.BOT_TOKEN }} >> .env
|
echo CLIENT_TOKEN = ${{ secrets.BOT_TOKEN }} >> .env
|
||||||
echo GUILD_ID = ${{ secrets.GUILD_ID }} >> .env
|
|
||||||
echo MODEL = ${{ secrets.MODEL }} >> .env
|
echo MODEL = ${{ secrets.MODEL }} >> .env
|
||||||
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
||||||
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
||||||
|
|||||||
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: release
|
name: Deploy
|
||||||
run-name: Release Docker Image
|
run-name: Release Docker Image
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Deploy-Image:
|
Release-Docker-Image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: release
|
environment: release
|
||||||
timeout-minutes: 3
|
timeout-minutes: 3
|
||||||
@@ -24,7 +24,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
touch .env
|
touch .env
|
||||||
echo CLIENT_TOKEN = NOT_REAL_TOKEN >> .env
|
echo CLIENT_TOKEN = NOT_REAL_TOKEN >> .env
|
||||||
echo GUILD_ID = 123456 >> .env
|
|
||||||
echo MODEL = ${{ secrets.MODEL }} >> .env
|
echo MODEL = ${{ secrets.MODEL }} >> .env
|
||||||
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
||||||
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
||||||
|
|||||||
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@@ -39,7 +39,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
touch .env
|
touch .env
|
||||||
echo CLIENT_TOKEN = ${{ secrets.BOT_TOKEN }} >> .env
|
echo CLIENT_TOKEN = ${{ secrets.BOT_TOKEN }} >> .env
|
||||||
echo GUILD_ID = ${{ secrets.GUILD_ID }} >> .env
|
|
||||||
echo MODEL = ${{ secrets.MODEL }} >> .env
|
echo MODEL = ${{ secrets.MODEL }} >> .env
|
||||||
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
echo CLIENT_UID = ${{ secrets.CLIENT_UID }} >> .env
|
||||||
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<p><a href="#"></a><a href="https://creativecommons.org/licenses/by/4.0/"><img alt="License" src="https://img.shields.io/badge/License-CC_BY_4.0-darkgreen.svg" /></a>
|
<p><a href="#"></a><a href="https://creativecommons.org/licenses/by/4.0/"><img alt="License" src="https://img.shields.io/badge/License-CC_BY_4.0-darkgreen.svg" /></a>
|
||||||
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/releases/latest"><img alt="Release" src="https://img.shields.io/github/v/release/kevinthedang/discord-ollama?logo=github" /></a>
|
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/releases/latest"><img alt="Release" src="https://img.shields.io/github/v/release/kevinthedang/discord-ollama?logo=github" /></a>
|
||||||
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/actions/workflows/build.yml"><img alt="Build Status" src="https://github.com/kevinthedang/discord-ollama/actions/workflows/build.yml/badge.svg" /></a>
|
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/actions/workflows/build.yml"><img alt="Build Status" src="https://github.com/kevinthedang/discord-ollama/actions/workflows/build.yml/badge.svg" /></a>
|
||||||
|
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/actions/workflows/release.yml"><img alt="Release Status" src="https://github.com/kevinthedang/discord-ollama/actions/workflows/release.yml/badge.svg" /></a>
|
||||||
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/actions/workflows/test.yml"><img alt="Testing Status" src="https://github.com/kevinthedang/discord-ollama/actions/workflows/test.yml/badge.svg" /></a>
|
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/actions/workflows/test.yml"><img alt="Testing Status" src="https://github.com/kevinthedang/discord-ollama/actions/workflows/test.yml/badge.svg" /></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ services:
|
|||||||
build: ./ # find docker file in designated path
|
build: ./ # find docker file in designated path
|
||||||
container_name: discord
|
container_name: discord
|
||||||
restart: always # rebuild container always
|
restart: always # rebuild container always
|
||||||
image: kevinthedang/discord-ollama:0.5.8
|
image: kevinthedang/discord-ollama:0.5.10
|
||||||
environment:
|
environment:
|
||||||
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
||||||
GUILD_ID: ${GUILD_ID}
|
|
||||||
MODEL: ${MODEL}
|
MODEL: ${MODEL}
|
||||||
CLIENT_UID: ${CLIENT_UID}
|
CLIENT_UID: ${CLIENT_UID}
|
||||||
OLLAMA_IP: ${OLLAMA_IP}
|
OLLAMA_IP: ${OLLAMA_IP}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
## To Run Locally (without Docker)
|
## To Run Locally (without Docker)
|
||||||
* Run `npm install` to install the npm packages.
|
* Run `npm install` to install the npm packages.
|
||||||
* Ensure that your [.env](../.env.sample) file's `OLLAMA_IP` is `127.0.0.1` to work properly.
|
* Ensure that your [.env](../.env.sample) file's `OLLAMA_IP` is `127.0.0.1` to work properly.
|
||||||
* You only need your `CLIENT_TOKEN`, `GUILD_ID`, `MODEL`, `CLIENT_UID`, `OLLAMA_IP`, `OLLAMA_PORT`.
|
* You only need your `CLIENT_TOKEN`, `MODEL`, `CLIENT_UID`, `OLLAMA_IP`, `OLLAMA_PORT`.
|
||||||
* The ollama ip and port should just use it's defaults by nature. If not, utilize `OLLAMA_IP = 127.0.0.1` and `OLLAMA_PORT = 11434`.
|
* The ollama ip and port should just use it's defaults by nature. If not, utilize `OLLAMA_IP = 127.0.0.1` and `OLLAMA_PORT = 11434`.
|
||||||
* Now, you can run the bot by running `npm run client` which will build and run the decompiled typescript and run the setup for ollama.
|
* Now, you can run the bot by running `npm run client` which will build and run the decompiled typescript and run the setup for ollama.
|
||||||
* **IMPORTANT**: This must be ran in the wsl/Linux instance to work properly! Using Command Prompt/Powershell/Git Bash/etc. will not work on Windows (at least in my experience).
|
* **IMPORTANT**: This must be ran in the wsl/Linux instance to work properly! Using Command Prompt/Powershell/Git Bash/etc. will not work on Windows (at least in my experience).
|
||||||
|
|||||||
961
package-lock.json
generated
961
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-ollama",
|
"name": "discord-ollama",
|
||||||
"version": "0.5.8",
|
"version": "0.5.10",
|
||||||
"description": "Ollama Integration into discord",
|
"description": "Ollama Integration into discord",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"exports": "./build/index.js",
|
"exports": "./build/index.js",
|
||||||
@@ -29,16 +29,16 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^14.15.3",
|
"discord.js": "^14.15.3",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"ollama": "^0.5.6"
|
"ollama": "^0.5.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.14.12",
|
"@types/node": "^22.5.1",
|
||||||
"@vitest/coverage-v8": "^2.0.4",
|
"@vitest/coverage-v8": "^2.0.5",
|
||||||
"nodemon": "^3.1.4",
|
"nodemon": "^3.1.4",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsx": "^4.16.2",
|
"tsx": "^4.19.0",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"vitest": "^2.0.4"
|
"vitest": "^2.0.5"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ export const Keys = {
|
|||||||
clientToken: getEnvVar('CLIENT_TOKEN'),
|
clientToken: getEnvVar('CLIENT_TOKEN'),
|
||||||
model: getEnvVar('MODEL'),
|
model: getEnvVar('MODEL'),
|
||||||
clientUid: getEnvVar('CLIENT_UID'),
|
clientUid: getEnvVar('CLIENT_UID'),
|
||||||
guildId: getEnvVar('GUILD_ID'),
|
|
||||||
ipAddress: getEnvVar('OLLAMA_IP'),
|
ipAddress: getEnvVar('OLLAMA_IP'),
|
||||||
portAddress: getEnvVar('OLLAMA_PORT'),
|
portAddress: getEnvVar('OLLAMA_PORT'),
|
||||||
} as const // readonly keys
|
} as const // readonly keys
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Configuration, ServerConfig, UserConfig, isServerConfigurationKey } from '../index.js'
|
import { Configuration, ServerConfig, UserConfig, isServerConfigurationKey } from '../index.js'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to open a file in the working directory and modify/create it
|
* Method to open a file in the working directory and modify/create it
|
||||||
@@ -35,6 +36,10 @@ export function openConfig(filename: string, key: string, value: any) {
|
|||||||
[key]: value
|
[key]: value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const directory = path.dirname(fullFileName)
|
||||||
|
if (!fs.existsSync(directory))
|
||||||
|
fs.mkdirSync(directory, { recursive: true })
|
||||||
|
|
||||||
fs.writeFileSync(`data/${filename}`, JSON.stringify(object, null, 2))
|
fs.writeFileSync(`data/${filename}`, JSON.stringify(object, null, 2))
|
||||||
console.log(`[Util: openConfig] Created '${filename}' in working directory`)
|
console.log(`[Util: openConfig] Created '${filename}' in working directory`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user