@@ -3,6 +3,7 @@ package ai
3
3
import (
4
4
"bufio"
5
5
"bytes"
6
+ "encoding/json"
6
7
"errors"
7
8
"fmt"
8
9
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
@@ -29,13 +30,6 @@ type QuestionBody struct {
29
30
Question string `json:"question"`
30
31
}
31
32
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
-
39
33
func HowCmd (c * cli.Context ) error {
40
34
if show , err := cliutils .ShowCmdHelpIfNeeded (c , c .Args ()); show || err != nil {
41
35
return err
@@ -70,15 +64,19 @@ func HowCmd(c *cli.Context) error {
70
64
}
71
65
72
66
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
+ }
73
71
client , err := httpclient .ClientBuilder ().Build ()
74
72
if errorutils .CheckError (err ) != nil {
75
73
return
76
74
}
77
- req , err := http .NewRequest (http .MethodPost , cliAiAskApiPath , bytes .NewBufferString ( question ))
75
+ req , err := http .NewRequest (http .MethodPost , cliAiAskApiPath , bytes .NewBuffer ( contentBytes ))
78
76
if errorutils .CheckError (err ) != nil {
79
77
return
80
78
}
81
- req .Header .Set ("Content-Type" , "text/plain " )
79
+ req .Header .Set ("Content-Type" , "application/json " )
82
80
req .Header .Set (apiHeader , "true" )
83
81
log .Debug (fmt .Sprintf ("Sending HTTP %s request to: %s" , req .Method , req .URL ))
84
82
resp , err := client .GetClient ().Do (req )
0 commit comments