changes to src/events/messageCreate.ts, Dockerfile, Modelfile, docker-compose.yml
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -1,19 +1,8 @@
|
||||
# use node LTS image for version 22
|
||||
FROM node:jod-alpine
|
||||
|
||||
# set working directory inside container
|
||||
WORKDIR /app
|
||||
|
||||
# copy package.json and the lock file into the container, and src files
|
||||
COPY ./src ./src
|
||||
COPY ./*.json ./
|
||||
COPY ./.env ./
|
||||
|
||||
# install dependencies, breaks
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm install
|
||||
|
||||
# build the typescript code
|
||||
COPY src/ ./src/
|
||||
COPY src/personality.json ./src/
|
||||
RUN npm run build
|
||||
|
||||
# start the application
|
||||
CMD ["npm", "run", "prod"]
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
# creates the docker compose
|
||||
|
||||
# build individual services
|
||||
version: '3.8'
|
||||
services:
|
||||
# setup discord bot container
|
||||
discord:
|
||||
build: ./ # find docker file in designated path
|
||||
build: ./
|
||||
container_name: discord
|
||||
restart: always # rebuild container always
|
||||
restart: always
|
||||
image: gitea.matrixwide.com/alex/discord-aidolls:0.1.0
|
||||
environment:
|
||||
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
||||
@@ -18,23 +15,20 @@ services:
|
||||
networks:
|
||||
ollama-net:
|
||||
ipv4_address: ${DISCORD_IP}
|
||||
volumes:
|
||||
- discord:/src/app # docker will not make this for you, make it yourself
|
||||
|
||||
# setup redis container
|
||||
volumes:
|
||||
- discord:/app/data
|
||||
- ./src:/app/src # Mount src/ to ensure personality.json is available
|
||||
redis:
|
||||
image: redis:latest
|
||||
image: redis:alpine # Use alpine for smaller footprint
|
||||
container_name: redis
|
||||
restart: always
|
||||
networks:
|
||||
ollama-net:
|
||||
ipv4_address: ${REDIS_IP}
|
||||
volumes:
|
||||
- redis:/root/.redis
|
||||
- redis:/data
|
||||
ports:
|
||||
- ${REDIS_PORT}:${REDIS_PORT}
|
||||
|
||||
# create a network that supports giving addresses withing a specific subnet
|
||||
networks:
|
||||
ollama-net:
|
||||
driver: bridge
|
||||
@@ -42,7 +36,6 @@ networks:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: ${SUBNET_ADDRESS}/16
|
||||
|
||||
volumes:
|
||||
discord:
|
||||
redis:
|
||||
|
||||
@@ -132,9 +132,9 @@ export default event(Events.MessageCreate, async ({ log, msgHist, ollama, client
|
||||
if (chatMessages.length === 0) {
|
||||
chatMessages = await new Promise((resolve, reject) => {
|
||||
openChannelInfo(message.channelId, message.channel as TextChannel, message.author.tag)
|
||||
getChannelInfo(`${message.channelId}-${message.author.username}.json`, (channelInfo) => {
|
||||
if (channelInfo?.messages) {
|
||||
resolve(channelInfo.messages)
|
||||
getChannelInfo(`${message.channelId}-${message.author.username}.json`, (config) => {
|
||||
if (config?.messages) {
|
||||
resolve(config.messages)
|
||||
} else {
|
||||
reject(new Error(`Failed to find ${message.author.username}'s history. Try chatting again.`))
|
||||
}
|
||||
@@ -160,7 +160,6 @@ export default event(Events.MessageCreate, async ({ log, msgHist, ollama, client
|
||||
// Load personality
|
||||
let personality: string
|
||||
try {
|
||||
// Point to /app/src/personality.json
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
const personalityPath = path.join(__dirname, '../personality.json')
|
||||
@@ -248,7 +247,9 @@ export default event(Events.MessageCreate, async ({ log, msgHist, ollama, client
|
||||
}
|
||||
} catch (error) {
|
||||
log(`Failed to parse model response: ${error}`)
|
||||
throw new Error(`Invalid JSON response from model: ${error}`)
|
||||
message.reply('Sorry, I’m having trouble thinking right now. Try again?')
|
||||
msgHist.pop()
|
||||
return
|
||||
}
|
||||
|
||||
if (jsonResponse.status === 'error') {
|
||||
|
||||
Reference in New Issue
Block a user