Skip to content

Commit

Permalink
Update dependencies (#2662)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 authored Aug 21, 2024
1 parent 9c08b29 commit 02fbfbd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions general/ai/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ai
import (
"bufio"
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
Expand All @@ -29,13 +30,6 @@ type QuestionBody struct {
Question string `json:"question"`
}

type FeedbackBody struct {
QuestionBody
LlmAnswer string `json:"llm_answer"`
IsAccurate bool `json:"is_accurate"`
ExpectedAnswer string `json:"expected_answer"`
}

func HowCmd(c *cli.Context) error {
if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil {
return err
Expand Down Expand Up @@ -70,15 +64,19 @@ func HowCmd(c *cli.Context) error {
}

func askQuestion(question string) (response string, err error) {
contentBytes, err := json.Marshal(QuestionBody{Question: question})
if errorutils.CheckError(err) != nil {
return
}
client, err := httpclient.ClientBuilder().Build()
if errorutils.CheckError(err) != nil {
return
}
req, err := http.NewRequest(http.MethodPost, cliAiAskApiPath, bytes.NewBufferString(question))
req, err := http.NewRequest(http.MethodPost, cliAiAskApiPath, bytes.NewBuffer(contentBytes))
if errorutils.CheckError(err) != nil {
return
}
req.Header.Set("Content-Type", "text/plain")
req.Header.Set("Content-Type", "application/json")
req.Header.Set(apiHeader, "true")
log.Debug(fmt.Sprintf("Sending HTTP %s request to: %s", req.Method, req.URL))
resp, err := client.GetClient().Do(req)
Expand Down

0 comments on commit 02fbfbd

Please sign in to comment.