kevinthedang / discord-ollama

Discord Bot that utilizes Ollama to interact with any Large Language Models to talk with users and allow them to host/create their own models.
Creative Commons Attribution 4.0 International
42 stars 4 forks source link

Keyword/Phrase Context Persistence via Model LLM #42

Open kevinthedang opened 2 months ago

kevinthedang commented 2 months ago

Idea

Questions to answer

// queue.ts
...

export class Queue<T> implements IQueue<T> {
    private storage: T[] = []
    private necessaryContext = [] // **list of necessary information for the bot to have if something gets dequeued

    /**
     * Set up Queue
     * @param capacity max length of queue
     */
    constructor(public capacity: number = 5) {}

    ...
// messageCreate.ts
import { ChatResponse } from 'ollama'

...

let response: ChatResponse    

// check if we can push, if not, remove oldest
if (msgHist.size() === msgHist.capacity) msgHist.dequeue()

// push user response before ollama query
msgHist.enqueue({
    role: 'user',
    content: message.content
})

...