mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-12 11:56:06 -05:00
Small Documentation and Refactoring (#18)
* cleanup and documentation * added dev message for parser * grammar and other type replacements
This commit is contained in:
@@ -6,12 +6,29 @@ export { Events } from 'discord.js'
|
||||
|
||||
export type LogMethod = (...args: unknown[]) => void
|
||||
export type EventKeys = keyof ClientEvents // only wants keys of ClientEvents object
|
||||
|
||||
/**
|
||||
* Tokens to run the bot as intended
|
||||
* @param channel the channel where the bot will respond to queries
|
||||
* @param model chosen model for the ollama to utilize
|
||||
* @param clientUid the discord id for the bot
|
||||
*/
|
||||
export type Tokens = {
|
||||
channel: string,
|
||||
model: string,
|
||||
clientUid: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Format for the messages to be stored when communicating when the bot
|
||||
* @param role either assistant, user, or system
|
||||
* @param content string of the message the user or assistant provided
|
||||
*/
|
||||
export type UserMessage = {
|
||||
role: string,
|
||||
content: string
|
||||
}
|
||||
|
||||
// Event properties
|
||||
export interface EventProps {
|
||||
client: Client
|
||||
@@ -35,10 +52,18 @@ export function event<T extends EventKeys>(key: T, callback: EventCallback<T>):
|
||||
return { key, callback }
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to register events to the bot per file in the events directory
|
||||
* @param client initialized bot client
|
||||
* @param events all the exported events from the index.ts in the events dir
|
||||
* @param msgHist The message history of the bot
|
||||
* @param tokens the passed in environment tokens for the service
|
||||
* @param ollama the initialized ollama instance
|
||||
*/
|
||||
export function registerEvents(
|
||||
client: Client,
|
||||
events: Event[],
|
||||
msgHist: { role: string, content: string }[],
|
||||
msgHist: UserMessage[],
|
||||
tokens: Tokens,
|
||||
ollama: Ollama
|
||||
): void {
|
||||
|
||||
Reference in New Issue
Block a user