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