mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-13 03:56:07 -05:00
Fix Capacity Command (#49)
* fix: capacity while replace if * fix: command name in config
This commit is contained in:
@@ -36,13 +36,13 @@ export default event(Events.MessageCreate, async ({ log, msgHist, tokens, ollama
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if there is a set capacity in config
|
// check if there is a set capacity in config
|
||||||
if (typeof config.options['history-capacity'] !== 'number')
|
if (typeof config.options['modify-capacity'] !== 'number')
|
||||||
log(`Capacity is undefined, using default capacity of ${msgHist.capacity}.`)
|
log(`Capacity is undefined, using default capacity of ${msgHist.capacity}.`)
|
||||||
else if (config.options['history-capacity'] === msgHist.capacity)
|
else if (config.options['modify-capacity'] === msgHist.capacity)
|
||||||
log(`Capacity matches config as ${msgHist.capacity}, no changes made.`)
|
log(`Capacity matches config as ${msgHist.capacity}, no changes made.`)
|
||||||
else {
|
else {
|
||||||
log(`New Capacity found. Setting Context Capacity to ${config.options['history-capacity']}.`)
|
log(`New Capacity found. Setting Context Capacity to ${config.options['modify-capacity']}.`)
|
||||||
msgHist.capacity = config.options['history-capacity']
|
msgHist.capacity = config.options['modify-capacity']
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(config)
|
resolve(config)
|
||||||
@@ -52,7 +52,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, tokens, ollama
|
|||||||
let response: ChatResponse
|
let response: ChatResponse
|
||||||
|
|
||||||
// check if we can push, if not, remove oldest
|
// check if we can push, if not, remove oldest
|
||||||
if (msgHist.size() === msgHist.capacity) msgHist.dequeue()
|
while (msgHist.size() >= msgHist.capacity) msgHist.dequeue()
|
||||||
|
|
||||||
// push user response before ollama query
|
// push user response before ollama query
|
||||||
msgHist.enqueue({
|
msgHist.enqueue({
|
||||||
@@ -70,7 +70,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, tokens, ollama
|
|||||||
if (response == undefined) { msgHist.pop(); return }
|
if (response == undefined) { msgHist.pop(); return }
|
||||||
|
|
||||||
// if queue is full, remove the oldest message
|
// if queue is full, remove the oldest message
|
||||||
if (msgHist.size() === msgHist.capacity) msgHist.dequeue()
|
while (msgHist.size() >= msgHist.capacity) msgHist.dequeue()
|
||||||
|
|
||||||
// successful query, save it in context history
|
// successful query, save it in context history
|
||||||
msgHist.enqueue({
|
msgHist.enqueue({
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export interface Configuration {
|
|||||||
'message-stream'?: boolean,
|
'message-stream'?: boolean,
|
||||||
'message-style'?: boolean,
|
'message-style'?: boolean,
|
||||||
'toggle-chat'?: boolean,
|
'toggle-chat'?: boolean,
|
||||||
'history-capacity'?: number
|
'modify-capacity'?: number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user