Skip to content

Commit 3c61cc4

Browse files
authored
Improve AI assistant feedback (#2711)
1 parent 15d405d commit 3c61cc4

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

general/ai/cli.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ func HowCmd(c *cli.Context) error {
4545
}
4646
log.Output(coreutils.PrintLink("This AI-powered interface converts natural language inputs into AI-generated JFrog CLI commands.\n" +
4747
"For more information about this interface, see https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli/cli-ai\n" +
48-
"NOTE: This is an experimental version and it supports mostly Artifactory and Xray commands.\n"))
48+
"Note: JFrog AI Assistant is in beta and currently supports primarily Artifactory and Xray commands.\n"))
4949

5050
// Ask the user to agree to the terms and conditions. If the user does not agree, the command will not proceed.
5151
// Ask this only once per JFrog CLI installation, unless the terms are updated.
52-
if agreed, err := handleAiTermsAgreement(); err != nil || !agreed {
52+
if agreed, err := handleAiTermsAgreement(); err != nil {
5353
return err
54+
} else if !agreed {
55+
// If the user does not agree to the terms, the command will not proceed.
56+
return reportTermsDisagreement()
5457
}
5558

5659
for {
@@ -82,7 +85,7 @@ func HowCmd(c *cli.Context) error {
8285
// If the response is a valid JFrog CLI command, ask the user for feedback.
8386
if validResponse {
8487
log.Output()
85-
if err = sendFeedback(); err != nil {
88+
if err = handleResponseFeedback(); err != nil {
8689
return err
8790
}
8891
}
@@ -100,16 +103,22 @@ func askQuestion(question string) (response string, err error) {
100103
}
101104

102105
type feedbackBody struct {
103-
IsGoodResponse bool `json:"is_good_response"`
106+
IsGoodResponse bool `json:"is_good_response,omitempty"`
107+
IsAgreedTerms bool `json:"is_agreed_terms,omitempty"`
104108
}
105109

106-
func sendFeedback() (err error) {
110+
func handleResponseFeedback() (err error) {
107111
isGoodResponse, err := getUserFeedback()
108112
if err != nil {
109-
return err
113+
return
110114
}
111115
_, err = sendRestAPI(feedback, feedbackBody{IsGoodResponse: isGoodResponse})
112-
return err
116+
return
117+
}
118+
119+
func reportTermsDisagreement() (err error) {
120+
_, err = sendRestAPI(feedback, feedbackBody{IsAgreedTerms: false})
121+
return
113122
}
114123

115124
func getUserFeedback() (bool, error) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ replace (
1111
)
1212

1313
require (
14-
github.com/agnivade/levenshtein v1.1.1
14+
github.com/agnivade/levenshtein v1.2.0
1515
github.com/buger/jsonparser v1.1.1
1616
github.com/docker/docker v27.3.1+incompatible
1717
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1o
621621
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
622622
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
623623
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
624-
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
625-
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
624+
github.com/agnivade/levenshtein v1.2.0 h1:U9L4IOT0Y3i0TIlUIDJ7rVUziKi/zPbrJGaFrtYH3SY=
625+
github.com/agnivade/levenshtein v1.2.0/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
626626
github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY=
627627
github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk=
628628
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
@@ -703,8 +703,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
703703
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
704704
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
705705
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
706-
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
707-
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
706+
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo=
707+
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
708708
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
709709
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
710710
github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI=

0 commit comments

Comments
 (0)