Skip to content

Commit d95ca55

Browse files
authored
chore(timeout): update default timeout to 30 seconds across files (appleboy#145)
- Increase the default timeout to `30` seconds - Change the default timeout to `30` seconds in the `commitCmd` function - Change the `availableKeys` map value for `openai.timeout` from `http timeout` to `request timeout` - Remove the import of `time` in the `cmd/config_set.go` file - Change the default timeout to `30` seconds in the `configSetCmd` function Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent ff97f1d commit d95ca55

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

cmd/commit.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ var (
3636

3737
templateVars []string
3838
templateVarsFile string
39+
40+
defaultTimeout = 30 * time.Second
3941
)
4042

4143
func init() {
@@ -52,7 +54,7 @@ func init() {
5254
commitCmd.PersistentFlags().StringSliceVar(&templateVars, "template_vars", []string{}, "template variables")
5355
commitCmd.PersistentFlags().StringVar(&templateVarsFile, "template_vars_file", "", "template variables file")
5456
commitCmd.PersistentFlags().BoolVar(&commitAmend, "amend", false, "replace the tip of the current branch by creating a new commit.")
55-
commitCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "t", 10*time.Second, "http timeout")
57+
commitCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "t", defaultTimeout, "request timeout")
5658
commitCmd.PersistentFlags().BoolVar(&promptOnly, "prompt_only", false, "show prompt only, don't send request to openai")
5759
_ = viper.BindPFlag("output.file", commitCmd.PersistentFlags().Lookup("file"))
5860
}
@@ -76,7 +78,8 @@ var commitCmd = &cobra.Command{
7678
}
7779

7880
// Update the OpenAI client request timeout if the timeout value is greater than the default openai.timeout
79-
if timeout > viper.GetDuration("openai.timeout") {
81+
if timeout > viper.GetDuration("openai.timeout") ||
82+
timeout != defaultTimeout {
8083
viper.Set("openai.timeout", timeout)
8184
}
8285

cmd/config_list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var availableKeys = map[string]string{
2626
"openai.proxy": "http proxy",
2727
"output.lang": "summarizing language uses English by default",
2828
"openai.base_url": "what API base url to use.",
29-
"openai.timeout": "http timeout",
29+
"openai.timeout": "request timeout",
3030
"openai.max_tokens": "the maximum number of tokens to generate in the chat completion.",
3131
"openai.temperature": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.",
3232
"openai.provider": "service provider, only support 'openai' or 'azure'",

cmd/config_set.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"errors"
55
"strings"
6-
"time"
76

87
"github.com/fatih/color"
98
"github.com/spf13/cobra"
@@ -19,7 +18,7 @@ func init() {
1918
configSetCmd.Flags().StringP("org_id", "o", "", availableKeys["openai.org_id"])
2019
configSetCmd.Flags().StringP("proxy", "", "", availableKeys["openai.proxy"])
2120
configSetCmd.Flags().StringP("socks", "", "", availableKeys["openai.socks"])
22-
configSetCmd.Flags().DurationP("timeout", "t", 10*time.Second, availableKeys["openai.timeout"])
21+
configSetCmd.Flags().DurationP("timeout", "t", defaultTimeout, availableKeys["openai.timeout"])
2322
configSetCmd.Flags().StringP("template_file", "", "", availableKeys["git.template_file"])
2423
configSetCmd.Flags().StringP("template_string", "", "", availableKeys["git.template_string"])
2524
configSetCmd.Flags().IntP("diff_unified", "", 3, availableKeys["git.diff_unified"])

0 commit comments

Comments
 (0)