llm: option to clear chat history

This commit is contained in:
Chris Sexton 2024-05-24 10:35:49 -04:00
parent aec464c1bf
commit 2697e6a259
1 changed files with 10 additions and 3 deletions

View File

@ -57,9 +57,9 @@ func (p *LLMPlugin) register() {
},
{
Kind: bot.Message, IsCmd: true,
Regex: regexp.MustCompile(`(?is)^got (?P<text>.*)`),
HelpText: "chat completion",
Handler: p.chatMessage,
Regex: regexp.MustCompile(`(?is)^llm-puke$`),
HelpText: "clear chat history",
Handler: p.puke,
},
}
p.b.RegisterTable(p, p.h)
@ -109,3 +109,10 @@ func (p *LLMPlugin) gptMessage(r bot.Request) bool {
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, resp)
return true
}
func (p *LLMPlugin) puke(r bot.Request) bool {
resp := fmt.Sprintf("I just forgot %d lines of chat history.", len(p.chatHistory))
p.chatHistory = []chatEntry{}
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, resp)
return true
}