Compare commits
6 Commits
v0.8.3
...
feature/lo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc7a3661b7 | ||
|
|
c026de5d62 | ||
|
|
f99bd2528d | ||
|
|
40783818b9 | ||
|
|
ed0d8600df | ||
|
|
03939ef562 |
132
.github/workflows/deploy.yml
vendored
Normal file
132
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
name: Deploy
|
||||||
|
run-name: Deploy Application Latest
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Deploy-Application:
|
||||||
|
runs-on: self-hosted
|
||||||
|
environment: deploy
|
||||||
|
timeout-minutes: 5
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Generate Secret File for Compose case
|
||||||
|
- name: Create Environment Variables
|
||||||
|
run: |
|
||||||
|
touch .env
|
||||||
|
echo CLIENT_TOKEN = ${{ secrets.CLIENT }} >> .env
|
||||||
|
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
||||||
|
echo OLLAMA_PORT = ${{ secrets.OLLAMA_PORT }} >> .env
|
||||||
|
echo DISCORD_IP = ${{ secrets.DISCORD_IP }} >> .env
|
||||||
|
echo SUBNET_ADDRESS = ${{ secrets.SUBNET_ADDRESS }} >> .env
|
||||||
|
echo REDIS_IP = ${{ secrets.REDIS_IP }} >> .env
|
||||||
|
echo REDIS_PORT = ${{ secrets.REDIS_PORT }} >> .env
|
||||||
|
|
||||||
|
- name: Check if directory exists and delete it
|
||||||
|
run: |
|
||||||
|
if [ -d "${{ secrets.PATH }}" ]; then
|
||||||
|
echo "Directory exists, deleting old version..."
|
||||||
|
rm -rf ${{ secrets.PATH }}
|
||||||
|
else
|
||||||
|
echo "Directory does not exist."
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Clone Repo onto Server
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/kevinthedang/discord-ollama.git ${{ secrets.PATH }}
|
||||||
|
cd ${{ secrets.PATH }}
|
||||||
|
|
||||||
|
- name: Install nvm and Node.js lts/jod
|
||||||
|
run: |
|
||||||
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||||
|
export NVM_DIR="$HOME/.nvm"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
echo "NVM installed successfully."
|
||||||
|
nvm install lts/jod
|
||||||
|
nvm alias default lts/jod
|
||||||
|
node -v
|
||||||
|
npm -v
|
||||||
|
|
||||||
|
- name: Build Application
|
||||||
|
run: |
|
||||||
|
export NVM_DIR="$HOME/.nvm"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
npm install
|
||||||
|
|
||||||
|
IMAGE="kevinthedang/discord-ollama"
|
||||||
|
REDIS="redis"
|
||||||
|
OLLAMA="ollama/ollama"
|
||||||
|
|
||||||
|
if docker images | grep -q $IMAGE; then
|
||||||
|
IMAGE_ID=$(docker images -q $IMAGE)
|
||||||
|
CONTAINER_IDS=$(docker ps -q --filter "ancestor=$IMAGE_ID")
|
||||||
|
|
||||||
|
if [ ! -z "$CONTAINER_IDS" ]; then
|
||||||
|
# Stop and remove the running containers
|
||||||
|
docker stop $CONTAINER_IDS
|
||||||
|
echo "Stopped and removed the containers using the image $IMAGE"
|
||||||
|
fi
|
||||||
|
docker rmi $IMAGE_ID
|
||||||
|
echo "Old $IMAGE Image Removed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if docker images | grep -q $REDIS; then
|
||||||
|
IMAGE_ID=$(docker images -q $REDIS)
|
||||||
|
CONTAINER_IDS=$(docker ps -q --filter "ancestor=$IMAGE_ID")
|
||||||
|
|
||||||
|
if [ ! -z "$CONTAINER_IDS" ]; then
|
||||||
|
# Stop and remove the running containers
|
||||||
|
docker stop $CONTAINER_IDS
|
||||||
|
echo "Stopped and removed the containers using the image $REDIS"
|
||||||
|
fi
|
||||||
|
docker rmi $IMAGE_ID
|
||||||
|
echo "Old $REDIS Image Removed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if docker images | grep -q $OLLAMA; then
|
||||||
|
IMAGE_ID=$(docker images -q $OLLAMA)
|
||||||
|
CONTAINER_IDS=$(docker ps -q --filter "ancestor=$IMAGE_ID")
|
||||||
|
|
||||||
|
if [ ! -z "$CONTAINER_IDS" ]; then
|
||||||
|
# Stop and remove the running containers
|
||||||
|
docker stop $CONTAINER_IDS
|
||||||
|
echo "Stopped and removed the containers using the image $OLLAMA"
|
||||||
|
fi
|
||||||
|
docker rmi $IMAGE_ID
|
||||||
|
echo "Old $OLLAMA Image Removed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker network prune -f
|
||||||
|
docker system prune -a -f
|
||||||
|
|
||||||
|
npm run docker:build-latest
|
||||||
|
|
||||||
|
- name: Start Application
|
||||||
|
run: |
|
||||||
|
docker network create --subnet=${{ secrets.SUBNET_ADDRESS }}/16 ollama-net || true
|
||||||
|
docker run --rm -d \
|
||||||
|
-v ollama:/root/.ollama \
|
||||||
|
-p ${{ secrets.OLLAMA_PORT }}:${{ secrets.OLLAMA_PORT }} \
|
||||||
|
--name ollama \
|
||||||
|
--network ollama-net \
|
||||||
|
--ip ${{ secrets.OLLAMA_IP }} \
|
||||||
|
ollama/ollama:latest
|
||||||
|
|
||||||
|
docker run --rm -d \
|
||||||
|
-v redis:/root/.redis \
|
||||||
|
-p ${{ secrets.REDIS_PORT }}:${{ secrets.REDIS_PORT }} \
|
||||||
|
--name redis \
|
||||||
|
--network ollama-net \
|
||||||
|
--ip ${{ secrets.REDIS_IP }} \
|
||||||
|
redis:latest
|
||||||
|
|
||||||
|
docker run --rm -d \
|
||||||
|
-v discord:/src/app \
|
||||||
|
--name discord \
|
||||||
|
--network ollama-net \
|
||||||
|
--ip ${{ secrets.DISCORD_IP }} \
|
||||||
|
kevinthedang/discord-ollama
|
||||||
50
.github/workflows/release.yml
vendored
50
.github/workflows/release.yml
vendored
@@ -1,50 +0,0 @@
|
|||||||
name: Deploy
|
|
||||||
run-name: Release Docker Image
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Release-Docker-Image:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
environment: release
|
|
||||||
timeout-minutes: 3
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Node Environment lts/jod
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: lts/jod
|
|
||||||
cache: "npm"
|
|
||||||
|
|
||||||
- name: Create Environment Variables
|
|
||||||
run: |
|
|
||||||
touch .env
|
|
||||||
echo CLIENT_TOKEN = NOT_REAL_TOKEN >> .env
|
|
||||||
echo OLLAMA_IP = ${{ secrets.OLLAMA_IP }} >> .env
|
|
||||||
echo OLLAMA_PORT = ${{ secrets.OLLAMA_PORT }} >> .env
|
|
||||||
echo REDIS_IP = ${{ secrets.REDIS_IP }} >> .env
|
|
||||||
echo REDIS_PORT = ${{ secrets.REDIS_PORT }} >> .env
|
|
||||||
|
|
||||||
- name: Get Version from package.json
|
|
||||||
run: echo "VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build Image
|
|
||||||
run: |
|
|
||||||
npm run docker:build
|
|
||||||
|
|
||||||
- name: Build Image as Latest
|
|
||||||
run: |
|
|
||||||
npm run docker:build-latest
|
|
||||||
|
|
||||||
- name: Log into Docker
|
|
||||||
run: |
|
|
||||||
docker login --username ${{ vars.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }}
|
|
||||||
|
|
||||||
- name: Release Docker Image
|
|
||||||
run: |
|
|
||||||
docker push ${{ vars.DOCKER_USER }}/discord-ollama:${{ env.VERSION }}
|
|
||||||
docker push ${{ vars.DOCKER_USER }}/discord-ollama:latest
|
|
||||||
@@ -5,7 +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/deploy.yml"><img alt="Deploy Status" src="https://github.com/kevinthedang/discord-ollama/actions/workflows/deploy.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>
|
||||||
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/actions/workflows/coverage.yml"><img alt="Code Coverage" src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/kevinthedang/bc7b5dcfa16561ab02bb3df67a99b22d/raw/coverage.json"></a>
|
<a href="#"></a><a href="https://github.com/kevinthedang/discord-ollama/actions/workflows/coverage.yml"><img alt="Code Coverage" src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/kevinthedang/bc7b5dcfa16561ab02bb3df67a99b22d/raw/coverage.json"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
1019
package-lock.json
generated
1019
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -27,18 +27,18 @@
|
|||||||
"author": "Kevin Dang",
|
"author": "Kevin Dang",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^14.17.3",
|
"discord.js": "^14.18.0",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"ollama": "^0.5.11",
|
"ollama": "^0.5.13",
|
||||||
"redis": "^4.7.0"
|
"redis": "^4.7.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.10.2",
|
"@types/node": "^22.13.5",
|
||||||
"@vitest/coverage-v8": "^2.1.8",
|
"@vitest/coverage-v8": "^3.0.6",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsx": "^4.19.2",
|
"tsx": "^4.19.3",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.3",
|
||||||
"vitest": "^2.1.4"
|
"vitest": "^3.0.4"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Client, GatewayIntentBits } from 'discord.js'
|
import { Client, GatewayIntentBits } from 'discord.js'
|
||||||
import { Ollama } from 'ollama'
|
import { Ollama } from 'ollama'
|
||||||
import { createClient } from 'redis'
|
import { createClient } from 'redis'
|
||||||
import { Queue } from './queues/queue.js'
|
import { Queue } from './components/index.js'
|
||||||
import { UserMessage, registerEvents } from './utils/index.js'
|
import { UserMessage, registerEvents } from './utils/index.js'
|
||||||
import Events from './events/index.js'
|
import Events from './events/index.js'
|
||||||
import Keys from './keys.js'
|
import Keys from './keys.js'
|
||||||
|
|||||||
46
src/components/binder.ts
Normal file
46
src/components/binder.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* @class Logger
|
||||||
|
* @description A class to handle logging messages
|
||||||
|
* @method log
|
||||||
|
*/
|
||||||
|
export class Logger {
|
||||||
|
private logPrefix: string = ''
|
||||||
|
private type: string = 'log'
|
||||||
|
|
||||||
|
private constructPrefix(component?: string, method?: string): string {
|
||||||
|
let prefix = this.type.toUpperCase()
|
||||||
|
|
||||||
|
if (component) {
|
||||||
|
prefix += ` [${component}`
|
||||||
|
if (method) prefix += `: ${method}`
|
||||||
|
prefix += ']'
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
public bind(component?: string, method?: string): CallableFunction {
|
||||||
|
let tempPrefix = this.constructPrefix(component, method)
|
||||||
|
|
||||||
|
if (tempPrefix !== this.logPrefix) this.logPrefix = tempPrefix
|
||||||
|
|
||||||
|
switch (this.type) {
|
||||||
|
case 'warn':
|
||||||
|
return console.warn.bind(console, this.logPrefix)
|
||||||
|
case 'error':
|
||||||
|
return console.error.bind(console, this.logPrefix)
|
||||||
|
case 'log':
|
||||||
|
default:
|
||||||
|
return console.log.bind(console, this.logPrefix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public log(type: string, message: unknown, component?: string, method?: string): void {
|
||||||
|
if (type && type !== this.type) this.type = type
|
||||||
|
|
||||||
|
let log = this.bind(component, method)
|
||||||
|
|
||||||
|
log(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
2
src/components/index.ts
Normal file
2
src/components/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './queue.js'
|
||||||
|
export * from './binder.js'
|
||||||
@@ -16,5 +16,4 @@ export default event(Events.InteractionCreate, async ({ log, client }, interacti
|
|||||||
|
|
||||||
// the command exists, execute it
|
// the command exists, execute it
|
||||||
command.run(client, interaction)
|
command.run(client, interaction)
|
||||||
}
|
})
|
||||||
)
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { TextChannel } from 'discord.js'
|
import { TextChannel } from 'discord.js'
|
||||||
import { event, Events, normalMessage, UserMessage, clean } from '../utils/index.js'
|
|
||||||
import {
|
import {
|
||||||
|
event, Events, normalMessage, UserMessage, clean,
|
||||||
getChannelInfo, getServerConfig, getUserConfig, openChannelInfo,
|
getChannelInfo, getServerConfig, getUserConfig, openChannelInfo,
|
||||||
openConfig, UserConfig, getAttachmentData, getTextFileAttachmentData
|
openConfig, UserConfig, getAttachmentData, getTextFileAttachmentData
|
||||||
} from '../utils/index.js'
|
} from '../utils/index.js'
|
||||||
@@ -190,5 +190,4 @@ export default event(Events.MessageCreate, async ({ log, msgHist, ollama, client
|
|||||||
msgHist.pop() // remove message because of failure
|
msgHist.pop() // remove message because of failure
|
||||||
message.reply(`**Error Occurred:**\n\n**Reason:** *${error.message}*`)
|
message.reply(`**Error Occurred:**\n\n**Reason:** *${error.message}*`)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
|
||||||
@@ -14,5 +14,4 @@ export default event(Events.ClientReady, ({ log }, client) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
log(`Logged in as ${client.user.username}.`)
|
log(`Logged in as ${client.user.username}.`)
|
||||||
}
|
})
|
||||||
)
|
|
||||||
@@ -37,5 +37,4 @@ export default event(Events.ThreadDelete, async ({ log }, thread: ThreadChannel)
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
log(`Issue deleting user history files from ${thread.id}`)
|
log(`Issue deleting user history files from ${thread.id}`)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { ClientEvents, Awaitable, Client } from 'discord.js'
|
import type { ClientEvents, Awaitable, Client } from 'discord.js'
|
||||||
import { Ollama } from 'ollama'
|
import { Ollama } from 'ollama'
|
||||||
import { Queue } from '../queues/queue.js'
|
import { Queue } from '../components/index.js'
|
||||||
|
|
||||||
// Export events through here to reduce amount of imports
|
// Export events through here to reduce amount of imports
|
||||||
export { Events } from 'discord.js'
|
export { Events } from 'discord.js'
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ export async function clearChannelInfo(filename: string, channel: TextChannel, u
|
|||||||
* @param user the user's name
|
* @param user the user's name
|
||||||
* @param messages their messages
|
* @param messages their messages
|
||||||
*/
|
*/
|
||||||
export async function openChannelInfo(filename: string, channel: TextChannel | ThreadChannel, user: string, messages: UserMessage[] = []): Promise<void> {
|
export async function openChannelInfo(this: any, filename: string, channel: TextChannel | ThreadChannel, user: string, messages: UserMessage[] = []): Promise<void> {
|
||||||
const fullFileName = `data/${filename}-${user}.json`
|
const fullFileName = `data/${filename}-${user}.json`
|
||||||
if (fs.existsSync(fullFileName)) {
|
if (fs.existsSync(fullFileName)) {
|
||||||
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
||||||
@@ -95,7 +95,7 @@ export async function openChannelInfo(filename: string, channel: TextChannel | T
|
|||||||
|
|
||||||
// only creating it, no need to add anything
|
// only creating it, no need to add anything
|
||||||
fs.writeFileSync(fullFileName, JSON.stringify(object, null, 2))
|
fs.writeFileSync(fullFileName, JSON.stringify(object, null, 2))
|
||||||
console.log(`[Util: openChannelInfo] Created '${fullFileName}' in working directory`)
|
console.log(`[Util: ${this.name}] Created '${fullFileName}' in working directory`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import path from 'path'
|
|||||||
* @param value new value to assign
|
* @param value new value to assign
|
||||||
*/
|
*/
|
||||||
// add type of change (server, user)
|
// add type of change (server, user)
|
||||||
export function openConfig(filename: string, key: string, value: any) {
|
export function openConfig(this: any, filename: string, key: string, value: any) {
|
||||||
const fullFileName = `data/${filename}`
|
const fullFileName = `data/${filename}`
|
||||||
|
|
||||||
// check if the file exists, if not then make the config file
|
// check if the file exists, if not then make the config file
|
||||||
@@ -41,7 +41,7 @@ export function openConfig(filename: string, key: string, value: any) {
|
|||||||
fs.mkdirSync(directory, { recursive: true })
|
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: ${this.name}] Created '${filename}' in working directory`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { ChatResponse } from "ollama"
|
import { ChatResponse, AbortableAsyncIterator } from "ollama"
|
||||||
import { ChatParams } from "../index.js"
|
import { ChatParams } from "../index.js"
|
||||||
import { AbortableAsyncIterator } from "ollama/src/utils.js"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to query the Ollama client for async generation
|
* Method to query the Ollama client for async generation
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Message, SendableChannels } from 'discord.js'
|
import { Message, SendableChannels } from 'discord.js'
|
||||||
import { ChatResponse, Ollama } from 'ollama'
|
import { ChatResponse, Ollama, AbortableAsyncIterator } from 'ollama'
|
||||||
import { ChatParams, UserMessage, streamResponse, blockResponse } from './index.js'
|
import { ChatParams, UserMessage, streamResponse, blockResponse } from './index.js'
|
||||||
import { Queue } from '../queues/queue.js'
|
import { Queue } from '../components/index.js'
|
||||||
import { AbortableAsyncIterator } from 'ollama/src/utils.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to send replies as normal text on discord like any other user
|
* Method to send replies as normal text on discord like any other user
|
||||||
@@ -11,6 +10,7 @@ import { AbortableAsyncIterator } from 'ollama/src/utils.js'
|
|||||||
* @param msgHist message history between user and model
|
* @param msgHist message history between user and model
|
||||||
*/
|
*/
|
||||||
export async function normalMessage(
|
export async function normalMessage(
|
||||||
|
this: any,
|
||||||
message: Message,
|
message: Message,
|
||||||
ollama: Ollama,
|
ollama: Ollama,
|
||||||
model: string,
|
model: string,
|
||||||
@@ -73,7 +73,7 @@ export async function normalMessage(
|
|||||||
sentMessage.edit(result)
|
sentMessage.edit(result)
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(`[Util: messageNormal] Error creating message: ${error.message}`)
|
console.log(`[Util: ${this.name}] Error creating message: ${error.message}`)
|
||||||
if (error.message.includes('try pulling it first'))
|
if (error.message.includes('try pulling it first'))
|
||||||
sentMessage.edit(`**Response generation failed.**\n\nReason: You do not have the ${model} downloaded. Ask an admin to pull it using the \`pull-model\` command.`)
|
sentMessage.edit(`**Response generation failed.**\n\nReason: You do not have the ${model} downloaded. Ask an admin to pull it using the \`pull-model\` command.`)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { Queue } from '../src/queues/queue.js'
|
import { Queue } from '../src/components/index.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue test suite, tests the Queue class
|
* Queue test suite, tests the Queue class
|
||||||
|
|||||||
Reference in New Issue
Block a user