-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: refactor codebase and improve security (#168)
- Add a new `.golangci.yml` configuration file with a list of linters and a 3-minute timeout setting - Refactor `commit.go` to improve readability by breaking long lines of flag definitions - Replace the OpenAI client initialization in `commit.go` with a call to a new function `NewOpenAI` - Change file permission in `commit.go` from `644` to `600` when writing the `outputFile` - Fix a typo in an error message in `hepler.go` (should be `helper.go`) - Create a new `openai.go` file to handle OpenAI client initialization - Remove OpenAI client initialization from `review.go` and replace it with a call to `NewOpenAI` - Refactor `review.go` to improve readability by breaking long lines of flag definitions - Update error messages in `git.go` to remove periods at the end - Change file permission in `git.go` from `755` to `600` when writing the hook file Signed-off-by: Bo-Yi Wu <[email protected]>
- Loading branch information
Showing
6 changed files
with
89 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
linters: | ||
enable-all: false | ||
disable-all: true | ||
fast: false | ||
enable: | ||
- bodyclose | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- exportloopref | ||
- exhaustive | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- noctx | ||
- nolintlint | ||
- rowserrcheck | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
- gofumpt | ||
run: | ||
timeout: 3m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/appleboy/CodeGPT/openai" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
func NewOpenAI() (*openai.Client, error) { | ||
return openai.New( | ||
openai.WithToken(viper.GetString("openai.api_key")), | ||
openai.WithModel(viper.GetString("openai.model")), | ||
openai.WithOrgID(viper.GetString("openai.org_id")), | ||
openai.WithProxyURL(viper.GetString("openai.proxy")), | ||
openai.WithSocksURL(viper.GetString("openai.socks")), | ||
openai.WithBaseURL(viper.GetString("openai.base_url")), | ||
openai.WithTimeout(viper.GetDuration("openai.timeout")), | ||
openai.WithMaxTokens(viper.GetInt("openai.max_tokens")), | ||
openai.WithTemperature(float32(viper.GetFloat64("openai.temperature"))), | ||
openai.WithProvider(viper.GetString("openai.provider")), | ||
openai.WithSkipVerify(viper.GetBool("openai.skip_verify")), | ||
openai.WithHeaders(viper.GetStringSlice("openai.headers")), | ||
openai.WithApiVersion(viper.GetString("openai.api_version")), | ||
openai.WithTopP(float32(viper.GetFloat64("openai.top_p"))), | ||
openai.WithFrequencyPenalty(float32(viper.GetFloat64("openai.frequency_penalty"))), | ||
openai.WithPresencePenalty(float32(viper.GetFloat64("openai.presence_penalty"))), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters