Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
496ce43939 |
@@ -16,9 +16,9 @@ The project aims to:
|
||||
* [x] Containerization with Docker
|
||||
* [x] Slash Commands Compatible
|
||||
* [x] Generated Token Length Handling for >2000 ~~or >6000 characters~~
|
||||
* [ ] Token Length Handling of any message size
|
||||
* [x] Token Length Handling of any message size
|
||||
* [ ] External WebUI Integration
|
||||
* [ ] Administrator Role Compatible
|
||||
* [x] Administrator Role Compatible
|
||||
* [ ] Allow others to create their own models personalized for their own servers!
|
||||
* [ ] Documentation on creating your own LLM
|
||||
* [ ] Documentation on web scrapping and cleaning
|
||||
|
||||
@@ -8,7 +8,7 @@ services:
|
||||
build: ./ # find docker file in designated path
|
||||
container_name: discord
|
||||
restart: always # rebuild container always
|
||||
image: discord/bot:0.4.3
|
||||
image: discord/bot:0.4.4
|
||||
environment:
|
||||
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
||||
GUILD_ID: ${GUILD_ID}
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "discord-ollama",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "discord-ollama",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.4",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord.js": "^14.14.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord-ollama",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.4",
|
||||
"description": "Ollama Integration into discord",
|
||||
"main": "build/index.js",
|
||||
"exports": "./build/index.js",
|
||||
|
||||
@@ -47,27 +47,72 @@ export async function embedMessage(
|
||||
for await (const portion of response) {
|
||||
result += portion.message.content
|
||||
|
||||
// exceeds handled length
|
||||
if (result.length > 5000) {
|
||||
const errorEmbed = new EmbedBuilder()
|
||||
.setTitle(`Responding to ${message.author.tag}`)
|
||||
.setDescription(`Response length ${result.length} has exceeded Discord maximum.\n\nLong Stream messages not supported.`)
|
||||
.setColor('#00FF00')
|
||||
|
||||
// send error
|
||||
message.channel.send({ embeds: [errorEmbed] })
|
||||
break // cancel loop and stop
|
||||
}
|
||||
|
||||
// new embed per token...
|
||||
const newEmbed = new EmbedBuilder()
|
||||
const streamEmbed = new EmbedBuilder()
|
||||
.setTitle(`Responding to ${message.author.tag}`)
|
||||
.setDescription(result || 'No Content Yet...')
|
||||
.setColor('#00FF00')
|
||||
|
||||
// edit the message
|
||||
sentMessage.edit({ embeds: [newEmbed] })
|
||||
sentMessage.edit({ embeds: [streamEmbed] })
|
||||
}
|
||||
} else {
|
||||
response = await blockResponse(params)
|
||||
result = response.message.content
|
||||
|
||||
// only need to create 1 embed again
|
||||
const newEmbed = new EmbedBuilder()
|
||||
.setTitle(`Responding to ${message.author.tag}`)
|
||||
.setDescription(result || 'No Content to Provide...')
|
||||
.setColor('#00FF00')
|
||||
// long message, split into different embeds sadly.
|
||||
if (result.length > 5000) {
|
||||
const firstEmbed = new EmbedBuilder()
|
||||
.setTitle(`Responding to ${message.author.tag}`)
|
||||
.setDescription(result.slice(0, 5000) || 'No Content to Provide...')
|
||||
.setColor('#00FF00')
|
||||
|
||||
// edit the message
|
||||
sentMessage.edit({ embeds: [newEmbed] })
|
||||
// replace first embed
|
||||
sentMessage.edit({ embeds: [firstEmbed] })
|
||||
|
||||
// take the rest out
|
||||
result = result.slice(5000)
|
||||
|
||||
// handle the rest
|
||||
while (result.length > 5000) {
|
||||
const whileEmbed = new EmbedBuilder()
|
||||
.setTitle(`Responding to ${message.author.tag}`)
|
||||
.setDescription(result.slice(0, 5000) || 'No Content to Provide...')
|
||||
.setColor('#00FF00')
|
||||
|
||||
message.channel.send({ embeds: [whileEmbed] })
|
||||
result = result.slice(5000)
|
||||
}
|
||||
|
||||
const lastEmbed = new EmbedBuilder()
|
||||
.setTitle(`Responding to ${message.author.tag}`)
|
||||
.setDescription(result || 'No Content to Provide...')
|
||||
.setColor('#00FF00')
|
||||
|
||||
// rest of the response
|
||||
message.channel.send({ embeds: [lastEmbed] })
|
||||
} else {
|
||||
// only need to create 1 embed, handles 6000 characters
|
||||
const newEmbed = new EmbedBuilder()
|
||||
.setTitle(`Responding to ${message.author.tag}`)
|
||||
.setDescription(result || 'No Content to Provide...')
|
||||
.setColor('#00FF00')
|
||||
|
||||
// edit the message
|
||||
sentMessage.edit({ embeds: [newEmbed] })
|
||||
}
|
||||
}
|
||||
} catch(error: any) {
|
||||
console.log(`[Util: messageEmbed] Error creating message: ${error.message}`)
|
||||
|
||||
@@ -38,6 +38,12 @@ export async function normalMessage(
|
||||
// append token to message
|
||||
result += portion.message.content
|
||||
|
||||
// exceeds handled length
|
||||
if (result.length > 2000) {
|
||||
message.channel.send(`Response length ${result.length} has exceeded Discord maximum.\n\nLong Stream messages not supported.`)
|
||||
break // stop stream
|
||||
}
|
||||
|
||||
// resent current output, THIS WILL BE SLOW due to discord limits!
|
||||
sentMessage.edit(result || 'No Content Yet...')
|
||||
}
|
||||
@@ -49,8 +55,17 @@ export async function normalMessage(
|
||||
// check if message length > discord max for normal messages
|
||||
if (result.length > 2000) {
|
||||
sentMessage.edit(result.slice(0, 2000))
|
||||
message.channel.send(result.slice(2000))
|
||||
} else // edit the 'generic' response to new message
|
||||
result = result.slice(2000)
|
||||
|
||||
// handle for rest of message that is >2000
|
||||
while (result.length > 2000) {
|
||||
message.channel.send(result.slice(0, 2000))
|
||||
result = result.slice(2000)
|
||||
}
|
||||
|
||||
// last part of message
|
||||
message.channel.send(result)
|
||||
} else // edit the 'generic' response to new message since <2000
|
||||
sentMessage.edit(result)
|
||||
}
|
||||
} catch(error: any) {
|
||||
@@ -59,6 +74,6 @@ export async function normalMessage(
|
||||
}
|
||||
})
|
||||
|
||||
// return the string representation of response
|
||||
// return the string representation of ollama query response
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user