Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #2662

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 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,20 @@ func HowCmd(c *cli.Context) error {
}

func askQuestion(question string) (response string, err error) {
questionBody := QuestionBody{Question: question}
contentBytes, err := json.Marshal(questionBody)
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
Loading