Skip to content

Commit

Permalink
Merge pull request #506 from innogames/dalle_stats
Browse files Browse the repository at this point in the history
DALL-E: add metrics for dalle requests
  • Loading branch information
brainexe authored Dec 1, 2023
2 parents 6216dbf + b4afa21 commit 66fe706
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bot/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 1 addition & 3 deletions bot/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down
2 changes: 2 additions & 0 deletions command/openai/dalle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit 66fe706

Please sign in to comment.