Skip to content

Commit

Permalink
update check question
Browse files Browse the repository at this point in the history
  • Loading branch information
3mp8r3 committed Jul 24, 2023
1 parent 4ef4882 commit a5d46b1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions go/internal/indexerhandler/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,12 @@ func (h *Handler) createPost(
return errors.Wrap(err, "failed to get block time")
}
message, ok := metadataJSON["message"].(string)
if !ok {
return errors.Wrap(err, "failed to get message")
}
//check question
if strings.Contains(message, "?") {
err1 := h.createAIAnswer(e, metadataJSON, createPostMsg) //store AI's answer to indexer db
if err1 != nil {
return errors.Wrap(err, "failed to generate answer using AI")
if ok {
if strings.HasPrefix(strings.TrimSpace(message), "/question") {
err1 := h.createAIAnswer(e, metadataJSON, createPostMsg) //store AI's answer to indexer db
if err1 != nil {
h.logger.Debug("failed to generate answer using AI")
}
}
}

Expand Down Expand Up @@ -225,6 +223,7 @@ func (h *Handler) createAIAnswer(e *Message, metadata map[string]interface{}, cr
url := "https://api.openai.com/v1/completions"
response := make([]byte, 0)
question, _ := metadata["message"].(string)
question = strings.Replace(strings.TrimSpace(question), "/question", "", 1)
input := CreateCompletionsRequest{
Model: "text-davinci-003",
Prompt: question,
Expand Down

0 comments on commit a5d46b1

Please sign in to comment.