add log
This commit is contained in:
@@ -45,6 +45,8 @@ func OnMessageCreated(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
log.Panicf("failed to query open ai with the following prompt [%s]. Error: %s", m.Content, err.Error())
|
||||
}
|
||||
|
||||
fmt.Println("Choices: ", res.Choices)
|
||||
|
||||
if len(res.Choices) > 0 {
|
||||
aiResponse := res.Choices[0].Message.Content
|
||||
sendResponse(s, m.ChannelID, aiResponse)
|
||||
|
||||
@@ -41,6 +41,15 @@ func (c Client) Chat(messages []*ChatMessage) (*ChatResponse, error) {
|
||||
return nil, fmt.Errorf("failed to query openai. Error: %s", err.Error())
|
||||
}
|
||||
|
||||
var test interface{}
|
||||
if err := json.Unmarshal(res.Body(), &test); err != nil {
|
||||
fmt.Println("ERROR: ", err.Error())
|
||||
}
|
||||
|
||||
fmt.Println("Parsing response in interface:")
|
||||
indent, _ := json.MarshalIndent(test, "\n", " ")
|
||||
fmt.Printf("\n%+v\n", indent)
|
||||
|
||||
var r ChatResponse
|
||||
if err := json.Unmarshal(res.Body(), &r); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse the openai response. Error: %s", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user