From 2697e6a259ecf6a4240f707b164201294ac4c455 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Fri, 24 May 2024 10:35:49 -0400 Subject: [PATCH] llm: option to clear chat history --- plugins/llm/gpt.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/llm/gpt.go b/plugins/llm/gpt.go index bab3d7d..4a8f358 100644 --- a/plugins/llm/gpt.go +++ b/plugins/llm/gpt.go @@ -57,9 +57,9 @@ func (p *LLMPlugin) register() { }, { Kind: bot.Message, IsCmd: true, - Regex: regexp.MustCompile(`(?is)^got (?P.*)`), - 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 +}