Skip to content

Commit 02fbfbd

Browse files
authored
Update dependencies (#2662)
1 parent 9c08b29 commit 02fbfbd

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

general/ai/cli.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ai
33
import (
44
"bufio"
55
"bytes"
6+
"encoding/json"
67
"errors"
78
"fmt"
89
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
@@ -29,13 +30,6 @@ type QuestionBody struct {
2930
Question string `json:"question"`
3031
}
3132

32-
type FeedbackBody struct {
33-
QuestionBody
34-
LlmAnswer string `json:"llm_answer"`
35-
IsAccurate bool `json:"is_accurate"`
36-
ExpectedAnswer string `json:"expected_answer"`
37-
}
38-
3933
func HowCmd(c *cli.Context) error {
4034
if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil {
4135
return err
@@ -70,15 +64,19 @@ func HowCmd(c *cli.Context) error {
7064
}
7165

7266
func askQuestion(question string) (response string, err error) {
67+
contentBytes, err := json.Marshal(QuestionBody{Question: question})
68+
if errorutils.CheckError(err) != nil {
69+
return
70+
}
7371
client, err := httpclient.ClientBuilder().Build()
7472
if errorutils.CheckError(err) != nil {
7573
return
7674
}
77-
req, err := http.NewRequest(http.MethodPost, cliAiAskApiPath, bytes.NewBufferString(question))
75+
req, err := http.NewRequest(http.MethodPost, cliAiAskApiPath, bytes.NewBuffer(contentBytes))
7876
if errorutils.CheckError(err) != nil {
7977
return
8078
}
81-
req.Header.Set("Content-Type", "text/plain")
79+
req.Header.Set("Content-Type", "application/json")
8280
req.Header.Set(apiHeader, "true")
8381
log.Debug(fmt.Sprintf("Sending HTTP %s request to: %s", req.Method, req.URL))
8482
resp, err := client.GetClient().Do(req)

0 commit comments

Comments
 (0)