Small Documentation and Refactoring (#18)

* cleanup and documentation

* added dev message for parser

* grammar and other type replacements
This commit is contained in:
Kevin Dang
2024-02-18 17:39:00 -08:00
committed by GitHub
parent 1c62958c9f
commit 5e74736c57
7 changed files with 39 additions and 14 deletions

View File

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