User Preferences and Setup Docs (#20)

* added message style command

* docker setup scripts

* reformat messageStyle.ts

* fix: register unregister on deploy

* add: messageStream preference

* add: json config handler

* update: messageCreate gets config

* update: shifted chat to config callback

* fix: naming conventions based on discord

* update: setup in docs now

* add: static docker ips

* version increment

* add: bot message for no config

* fix: no config case

* add: clarification for subnetting

* update: version increment in lock file

---------

Co-authored-by: JT2M0L3Y <jtsmoley@icloud.com>
This commit is contained in:
Kevin Dang
2024-03-22 10:37:06 -07:00
committed by GitHub
parent 5e74736c57
commit 43fb2ea94e
20 changed files with 377 additions and 146 deletions

View File

@@ -1,5 +1,5 @@
import { Message } from 'discord.js'
import ollama, { ChatResponse } from 'ollama'
import { ChatResponse, Ollama } from 'ollama'
import { UserMessage } from './events.js'
/**
@@ -8,8 +8,9 @@ import { UserMessage } from './events.js'
* @param tokens tokens to run query
* @param msgHist message history between user and model
*/
export function normalMessage(
message: Message,
export async function normalMessage(
message: Message,
ollama: Ollama,
tokens: {
channel: string,
model: string
@@ -19,7 +20,7 @@ export function normalMessage(
// bot's respnse
let response: ChatResponse
message.reply('Generating Response . . .').then(async sentMessage => {
await message.reply('Generating Response . . .').then(async sentMessage => {
try {
// Attempt to query model for message
response = await ollama.chat({
@@ -37,7 +38,8 @@ export function normalMessage(
// edit the 'generic' response to new message
sentMessage.edit(response.message.content)
} catch(error: any) {
sentMessage.edit(error.error)
console.log(`[Util: messageNormal] Error creating message: ${error.message}`)
sentMessage.edit(`**Response generation failed.**\n\nReason: ${error.message}`)
}
})