Infinite Message Length for Block Messages (#55)

* add: message loop for block messages

* add: infinite message length for block embeds

* update: error message on stream length

* rm: unnecessary import

* update: version increment

* update: embed max length

* update: check off features
This commit is contained in:
Kevin Dang
2024-04-30 19:33:06 -07:00
committed by GitHub
parent b5194fa645
commit 496ce43939
6 changed files with 78 additions and 18 deletions

View File

@@ -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
}