Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32b12e93c0 | ||
|
|
89213c2d39 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Builds
|
name: Builds
|
||||||
run-name: Validate Node and Docker Builds
|
run-name: Validate Node and Docker Builds
|
||||||
on:
|
on:
|
||||||
pull_request:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Tests
|
name: Tests
|
||||||
run-name: Test source code for errors
|
run-name: Unit Tests
|
||||||
on:
|
on:
|
||||||
push:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ services:
|
|||||||
build: ./ # find docker file in designated path
|
build: ./ # find docker file in designated path
|
||||||
container_name: discord
|
container_name: discord
|
||||||
restart: always # rebuild container always
|
restart: always # rebuild container always
|
||||||
image: discord/bot:0.5.0
|
image: discord/bot:0.5.1
|
||||||
environment:
|
environment:
|
||||||
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
||||||
GUILD_ID: ${GUILD_ID}
|
GUILD_ID: ${GUILD_ID}
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-ollama",
|
"name": "discord-ollama",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "discord-ollama",
|
"name": "discord-ollama",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-ollama",
|
"name": "discord-ollama",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"description": "Ollama Integration into discord",
|
"description": "Ollama Integration into discord",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"exports": "./build/index.js",
|
"exports": "./build/index.js",
|
||||||
|
|||||||
@@ -32,19 +32,23 @@ export async function normalMessage(
|
|||||||
|
|
||||||
// run query based on stream preference, true = stream, false = block
|
// run query based on stream preference, true = stream, false = block
|
||||||
if (stream) {
|
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) {
|
for await (const portion of response) {
|
||||||
// append token to message
|
// check if over discord message limit
|
||||||
result += portion.message.content
|
if (result.length + portion.message.content.length > 2000) {
|
||||||
|
result = portion.message.content
|
||||||
|
|
||||||
// exceeds handled length
|
// new message block, wait for it to send and assign new block to respond.
|
||||||
if (result.length > 2000) {
|
await message.channel.send("Creating new stream block...").then(sentMessage => { messageBlock = sentMessage })
|
||||||
message.channel.send(`Response length ${result.length} has exceeded Discord maximum.\n\nLong Stream messages not supported.`)
|
} else {
|
||||||
break // stop stream
|
result += portion.message.content
|
||||||
}
|
|
||||||
|
// ensure block is not empty
|
||||||
// resent current output, THIS WILL BE SLOW due to discord limits!
|
if (result.length > 5)
|
||||||
sentMessage.edit(result || 'No Content Yet...')
|
messageBlock.edit(result)
|
||||||
|
}
|
||||||
|
console.log(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export async function streamResponse(params: ChatParams): Promise<AsyncGenerator
|
|||||||
model: params.model,
|
model: params.model,
|
||||||
messages: params.msgHist,
|
messages: params.msgHist,
|
||||||
options: {
|
options: {
|
||||||
num_thread: 8, // remove if optimization needed further
|
|
||||||
mirostat: 1,
|
mirostat: 1,
|
||||||
mirostat_tau: 2.0,
|
mirostat_tau: 2.0,
|
||||||
top_k: 70
|
top_k: 70
|
||||||
@@ -30,7 +29,6 @@ export async function blockResponse(params: ChatParams): Promise<ChatResponse> {
|
|||||||
model: params.model,
|
model: params.model,
|
||||||
messages: params.msgHist,
|
messages: params.msgHist,
|
||||||
options: {
|
options: {
|
||||||
num_thread: 8, // remove if optimization needed further
|
|
||||||
mirostat: 1,
|
mirostat: 1,
|
||||||
mirostat_tau: 2.0,
|
mirostat_tau: 2.0,
|
||||||
top_k: 70
|
top_k: 70
|
||||||
|
|||||||
Reference in New Issue
Block a user