ingst chat message added
This commit is contained in:
@@ -37,6 +37,18 @@ var (
|
||||
Name: "ingest",
|
||||
Description: "Importiert Markdown-Notizen aus brain_root in die Wissensdatenbank",
|
||||
},
|
||||
{
|
||||
Name: "remember",
|
||||
Description: "Speichert eine Nachricht in der Wissensdatenbank",
|
||||
Options: []*discordgo.ApplicationCommandOption{
|
||||
{
|
||||
Type: discordgo.ApplicationCommandOptionString,
|
||||
Name: "text",
|
||||
Description: "Der Text, der gespeichert werden soll",
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -107,6 +119,8 @@ func onInteraction(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
handleAsk(s, i, i.ApplicationCommandData().Options[0].StringValue())
|
||||
case "ingest":
|
||||
handleIngest(s, i)
|
||||
case "remember":
|
||||
handleRemember(s, i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +184,25 @@ func handleIngest(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
})
|
||||
}
|
||||
|
||||
func handleRemember(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseDeferredChannelMessageWithSource,
|
||||
})
|
||||
|
||||
text := i.ApplicationCommandData().Options[0].StringValue()
|
||||
author := i.Member.User.Username
|
||||
source := fmt.Sprintf("discord/#%s", i.ChannelID)
|
||||
|
||||
err := brain.IngestChatMessage(text, author, source)
|
||||
var msg string
|
||||
if err != nil {
|
||||
msg = fmt.Sprintf("❌ Fehler beim Speichern: %v", err)
|
||||
} else {
|
||||
msg = fmt.Sprintf("✅ Gespeichert: _%s_", text)
|
||||
}
|
||||
s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{Content: &msg})
|
||||
}
|
||||
|
||||
func queryAndFormat(question string) string {
|
||||
answer, chunks, err := brain.AskQuery(question)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user