Roll NPM Dependencies Forward (#136)

* update channel as sendable

* Update: Casting SendableChannels Once

* Remove: another semicolon

* Update: version increment

---------

Co-authored-by: kevinthedang <kevinthedang_1@outlook.com>
This commit is contained in:
Jonathan Smoley
2024-11-08 10:13:16 -08:00
committed by GitHub
parent 68a5e097fe
commit 1ccd1a012e
5 changed files with 643 additions and 408 deletions

View File

@@ -7,7 +7,7 @@ services:
build: ./ # find docker file in designated path
container_name: discord
restart: always # rebuild container always
image: kevinthedang/discord-ollama:0.7.0
image: kevinthedang/discord-ollama:0.7.1
environment:
CLIENT_TOKEN: ${CLIENT_TOKEN}
OLLAMA_IP: ${OLLAMA_IP}

1009
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "discord-ollama",
"version": "0.7.0",
"version": "0.7.1",
"description": "Ollama Integration into discord",
"main": "build/index.js",
"exports": "./build/index.js",
@@ -26,17 +26,17 @@
"author": "Kevin Dang",
"license": "ISC",
"dependencies": {
"discord.js": "^14.15.3",
"discord.js": "^14.16.3",
"dotenv": "^16.4.5",
"ollama": "^0.5.9"
},
"devDependencies": {
"@types/node": "^22.7.5",
"@vitest/coverage-v8": "^2.1.2",
"@types/node": "^22.9.0",
"@vitest/coverage-v8": "^2.1.4",
"ts-node": "^10.9.2",
"tsx": "^4.19.1",
"tsx": "^4.19.2",
"typescript": "^5.6.3",
"vitest": "^2.1.2"
"vitest": "^2.1.4"
},
"type": "module",
"engines": {

View File

@@ -1,4 +1,4 @@
import { EmbedBuilder, Message } from 'discord.js'
import { EmbedBuilder, Message, SendableChannels } from 'discord.js'
import { ChatResponse, Ollama } from 'ollama'
import { ChatParams, UserMessage, streamResponse, blockResponse } from './index.js'
import { Queue } from '../queues/queue.js'
@@ -28,7 +28,8 @@ export async function embedMessage(
.setColor('#00FF00')
// send the message
const sentMessage = await message.channel.send({ embeds: [botMessage] })
const channel = message.channel as SendableChannels
const sentMessage = await channel.send({ embeds: [botMessage] })
// create params
const params: ChatParams = {
@@ -53,7 +54,7 @@ export async function embedMessage(
.setColor('#00FF00')
// send error
message.channel.send({ embeds: [errorEmbed] })
channel.send({ embeds: [errorEmbed] })
break // cancel loop and stop
}
@@ -90,7 +91,7 @@ export async function embedMessage(
.setDescription(result.slice(0, 5000) || 'No Content to Provide...')
.setColor('#00FF00')
message.channel.send({ embeds: [whileEmbed] })
channel.send({ embeds: [whileEmbed] })
result = result.slice(5000)
}
@@ -100,7 +101,7 @@ export async function embedMessage(
.setColor('#00FF00')
// rest of the response
message.channel.send({ embeds: [lastEmbed] })
channel.send({ embeds: [lastEmbed] })
} else {
// only need to create 1 embed, handles 6000 characters
const newEmbed = new EmbedBuilder()

View File

@@ -1,4 +1,4 @@
import { Message } from 'discord.js'
import { Message, SendableChannels } from 'discord.js'
import { ChatResponse, Ollama } from 'ollama'
import { ChatParams, UserMessage, streamResponse, blockResponse } from './index.js'
import { Queue } from '../queues/queue.js'
@@ -20,8 +20,9 @@ export async function normalMessage(
// bot's respnse
let response: ChatResponse | AbortableAsyncIterator<ChatResponse>
let result: string = ''
const channel = message.channel as SendableChannels
await message.channel.send('Generating Response . . .').then(async sentMessage => {
await channel.send('Generating Response . . .').then(async sentMessage => {
try {
const params: ChatParams = {
model: model,
@@ -39,7 +40,7 @@ export async function normalMessage(
result = portion.message.content
// new message block, wait for it to send and assign new block to respond.
await message.channel.send("Creating new stream block...").then(sentMessage => { messageBlock = sentMessage })
await channel.send("Creating new stream block...").then(sentMessage => { messageBlock = sentMessage })
} else {
result += portion.message.content
@@ -61,12 +62,12 @@ export async function normalMessage(
// handle for rest of message that is >2000
while (result.length > 2000) {
message.channel.send(result.slice(0, 2000))
channel.send(result.slice(0, 2000))
result = result.slice(2000)
}
// last part of message
message.channel.send(result)
channel.send(result)
} else // edit the 'generic' response to new message since <2000
sentMessage.edit(result)
}