From b4afa217e2212f2ca427bea7ba85f2fdd0785869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20D=C3=B6tsch?= Date: Fri, 1 Dec 2023 09:00:00 +0100 Subject: [PATCH] DALL-E: add metrics for dalle requests --- bot/interaction.go | 2 +- bot/stats/stats.go | 4 +--- command/openai/dalle.go | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bot/interaction.go b/bot/interaction.go index 0ae322a0..e5c1e801 100644 --- a/bot/interaction.go +++ b/bot/interaction.go @@ -28,7 +28,7 @@ func (b *Bot) handleEvent(eventsAPIEvent slackevents.EventsAPIEvent) { return } - if len(ev.Files) > 0 { + if len(ev.Files) > 0 && ev.User != b.auth.UserID { ev.Text += b.loadFileContent(ev) } diff --git a/bot/stats/stats.go b/bot/stats/stats.go index 20825c5f..fdb77a6d 100644 --- a/bot/stats/stats.go +++ b/bot/stats/stats.go @@ -36,9 +36,7 @@ func Increase[T constraints.Signed](key string, count T) { value += count - if err := storage.Write(collection, key, value); err != nil { - log.Warn(errors.Wrap(err, "error while increasing stats")) - } + Set(key, value) }) } diff --git a/command/openai/dalle.go b/command/openai/dalle.go index 727c829c..16916483 100644 --- a/command/openai/dalle.go +++ b/command/openai/dalle.go @@ -8,6 +8,7 @@ import ( "github.com/innogames/slack-bot/v2/bot/matcher" "github.com/innogames/slack-bot/v2/bot/msg" + "github.com/innogames/slack-bot/v2/bot/stats" "github.com/innogames/slack-bot/v2/bot/util" log "github.com/sirupsen/logrus" "github.com/slack-go/slack" @@ -95,6 +96,7 @@ func generateImages(cfg Config, prompt string) ([]DalleResponseImage, error) { log.WithField("model", cfg.DalleModel). Infof("Dall-E image generation took %s", time.Since(start)) + stats.Increase("openai_dalle_images", len(response.Data)) return response.Data, nil }