fix endpoint

This commit is contained in:
unintendedfraud
2023-05-06 12:21:10 +02:00
parent 9935f034f8
commit 3f0e55e45b
2 changed files with 13 additions and 31 deletions
-7
View File
@@ -15,18 +15,13 @@ func OnMessageCreated(s *discordgo.Session, m *discordgo.MessageCreate) {
}
if containUser(m.Mentions, s.State.User.ID) {
fmt.Println("create ai client")
aiclient := openai.NewClient(env.GetEnvVariables().OpenaiHalToken)
fmt.Println("ai client created")
res, err := aiclient.ChatCompletions(m.Content)
if err != nil {
log.Panicf("failed to query open ai with the following prompt [%s]. Error: %s", m.Content, err.Error())
}
fmt.Println("ai client replied")
if len(res.Choices) > 0 {
aiResponse := res.Choices[0].Message.Content
if _, err = s.ChannelMessageSend(m.ChannelID, aiResponse); err != nil {
@@ -34,8 +29,6 @@ func OnMessageCreated(s *discordgo.Session, m *discordgo.MessageCreate) {
}
}
fmt.Println("### ai did not return any response ###", res.Usage, res.Choices)
return
}
}