Compare commits

...

2 Commits

Author SHA1 Message Date
Kevin Dang
32b12e93c0 Infinite Message Length for Streamed Messages (#70)
* Add: Infinite Stream messages

* Update: version increment
2024-06-16 18:20:23 -07:00
Kevin Dang
89213c2d39 Removed Ollama API Threads as an Option (#68)
* rm: threads as a chat option

* update: change test Actions name

* Fix: workflows running in correct instance
2024-06-16 15:47:49 -07:00
7 changed files with 22 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
name: Builds
run-name: Validate Node and Docker Builds
on:
pull_request:
push:
branches:
- master

View File

@@ -1,7 +1,7 @@
name: Tests
run-name: Test source code for errors
run-name: Unit Tests
on:
push:
pull_request:
branches:
- master

View File

@@ -8,7 +8,7 @@ services:
build: ./ # find docker file in designated path
container_name: discord
restart: always # rebuild container always
image: discord/bot:0.5.0
image: discord/bot:0.5.1
environment:
CLIENT_TOKEN: ${CLIENT_TOKEN}
GUILD_ID: ${GUILD_ID}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "discord-ollama",
"version": "0.5.0",
"version": "0.5.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "discord-ollama",
"version": "0.5.0",
"version": "0.5.1",
"license": "ISC",
"dependencies": {
"discord.js": "^14.14.1",

View File

@@ -1,6 +1,6 @@
{
"name": "discord-ollama",
"version": "0.5.0",
"version": "0.5.1",
"description": "Ollama Integration into discord",
"main": "build/index.js",
"exports": "./build/index.js",

View File

@@ -32,19 +32,23 @@ export async function normalMessage(
// run query based on stream preference, true = stream, false = block
if (stream) {
response = await streamResponse(params)
let messageBlock: Message = sentMessage
response = await streamResponse(params) // THIS WILL BE SLOW due to discord limits!
for await (const portion of response) {
// append token to message
result += portion.message.content
// check if over discord message limit
if (result.length + portion.message.content.length > 2000) {
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...')
// 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 })
} else {
result += portion.message.content
// ensure block is not empty
if (result.length > 5)
messageBlock.edit(result)
}
console.log(result)
}
}
else {

View File

@@ -11,7 +11,6 @@ export async function streamResponse(params: ChatParams): Promise<AsyncGenerator
model: params.model,
messages: params.msgHist,
options: {
num_thread: 8, // remove if optimization needed further
mirostat: 1,
mirostat_tau: 2.0,
top_k: 70
@@ -30,7 +29,6 @@ export async function blockResponse(params: ChatParams): Promise<ChatResponse> {
model: params.model,
messages: params.msgHist,
options: {
num_thread: 8, // remove if optimization needed further
mirostat: 1,
mirostat_tau: 2.0,
top_k: 70