Skip to content

Commit

Permalink
Merge pull request #60 from whatwewant/fix/timeout-default-60s-cannot…
Browse files Browse the repository at this point in the history
…-config

fix: timeout default 60s and cannot custom config
  • Loading branch information
whatwewant authored Apr 7, 2023
2 parents fb8c2fc + 3f82bb8 commit b8ab9f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ go 1.20
require (
github.com/go-zoox/chalk v1.0.2
github.com/go-zoox/chatbot-feishu v1.2.9
github.com/go-zoox/chatgpt-client v1.4.3
github.com/go-zoox/chatgpt-client v1.4.4
github.com/go-zoox/cli v1.2.0
github.com/go-zoox/core-utils v1.2.7
github.com/go-zoox/feishu v1.3.11
github.com/go-zoox/fs v1.3.9
github.com/go-zoox/logger v1.4.4
github.com/go-zoox/openai-client v1.3.0
github.com/go-zoox/openai-client v1.3.1
github.com/go-zoox/proxy v1.3.6
github.com/go-zoox/retry v1.0.3
github.com/go-zoox/zoox v1.8.9
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/go-zoox/chalk v1.0.2 h1:DCWft37fogmvqF37JdbGSLg28L/tQeA8u0lMvb62KOg=
github.com/go-zoox/chalk v1.0.2/go.mod h1:z5+qvE9nEJI5uT4px2tyoFa/xxkqf3CUo22KmXLKbNI=
github.com/go-zoox/chatbot-feishu v1.2.9 h1:eSMufO7oO94wh1B4n1k+EXeEYvPnHcCC08vD0vfbnIc=
github.com/go-zoox/chatbot-feishu v1.2.9/go.mod h1:DOYszjwta05Xg87acn2+CtmROLEqanHjwxROn4FpGzE=
github.com/go-zoox/chatgpt-client v1.4.3 h1:4NrIoA2S5R5RyyEGBadYDavDdr7WVup5EKI9erWAvmA=
github.com/go-zoox/chatgpt-client v1.4.3/go.mod h1:zbs/hCS8MkxEvuYc4bODF4u/c5ji1J17gCBNYDIZZcI=
github.com/go-zoox/chatgpt-client v1.4.4 h1:2a1qsN+4UMsacNSc0ETQoc6lRLSFLEXB4jFBqg9RLoI=
github.com/go-zoox/chatgpt-client v1.4.4/go.mod h1:mI/5SAeHjIxi+ji9gRfrOwVZO20i5yP2ND59XghXWwg=
github.com/go-zoox/cli v1.2.0 h1:qBDHwcv2o5xgqGpYokxSszs8MVdNzaNZJJroAhpevFM=
github.com/go-zoox/cli v1.2.0/go.mod h1:p2VJxwXFJRp3+nt29/LihKTNzwAFRkIhnFpf3hyVrmE=
github.com/go-zoox/compress v1.0.1 h1:EyNxo5NscMLua5fvUdiGSF+BwhuTfMeyppu7OwKAW7Q=
Expand Down Expand Up @@ -105,8 +105,8 @@ github.com/go-zoox/logger v1.4.4 h1:050xlOkXfslwGuR57B0rA+toSXUo4UQqRCsyTw2n0UQ=
github.com/go-zoox/logger v1.4.4/go.mod h1:o7ddvv/gMoMa0TomPhHoIz11ZWRbQ92pF6rwYbOY3iQ=
github.com/go-zoox/lru v1.0.1 h1:AvRHxKEeEFSH9UXyfDQ5lj8nr66p6tJS3kVf/eTVyMg=
github.com/go-zoox/lru v1.0.1/go.mod h1:xxtYsRbJ2iJKEL4OIEZ6lk0xjuGJHHZmZZhGtH5qwv0=
github.com/go-zoox/openai-client v1.3.0 h1:7aqN+idkCkrr0Xq0r3MqRbeuFfSTbRxAfDaWnfbnqx4=
github.com/go-zoox/openai-client v1.3.0/go.mod h1:h6vfyPajS1ScdALzDb+CwcSiMH3WKqScma0qH+SlRF8=
github.com/go-zoox/openai-client v1.3.1 h1:jgOvuRpWd/afrQs4+cWpKOQi+1g0V6axWfEPTZafpro=
github.com/go-zoox/openai-client v1.3.1/go.mod h1:h6vfyPajS1ScdALzDb+CwcSiMH3WKqScma0qH+SlRF8=
github.com/go-zoox/proxy v1.2.3/go.mod h1:T+gbngAtIgvambbYibAbzrjwdu8j5pduJdA2j6RYi94=
github.com/go-zoox/proxy v1.3.6 h1:Xij9DeLlVaq6CjJ+XuhpMNJ9EmSCq/dGuXjjBv/imGA=
github.com/go-zoox/proxy v1.3.6/go.mod h1:DQckJqVcSnYYgX+L1SSjj/UQGCBABXTZO5Al1aJ6pnc=
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func main() {
EnvVars: []string{"OPENAI_API_KEY"},
Required: true,
},
&cli.Int64Flag{
Name: "openai-api-timeout",
Usage: "OpenAI API Timeout, unit: second, default: 300",
EnvVars: []string{"OPENAI_API_TIMEOUT"},
Value: 300,
},
&cli.StringFlag{
Name: "openai-api-server",
Usage: "OpenAI API Server",
Expand Down Expand Up @@ -132,6 +138,7 @@ func main() {
Port: ctx.Int64("port"),
APIPath: ctx.String("api-path"),
OpenAIAPIKey: ctx.String("openai-api-key"),
OpenAIAPITimeout: ctx.Int64("openai-api-timeout"),
AppID: ctx.String("app-id"),
AppSecret: ctx.String("app-secret"),
EncryptKey: ctx.String("encrypt-key"),
Expand Down
2 changes: 2 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type FeishuBotConfig struct {
Port int64
APIPath string
OpenAIAPIKey string
OpenAIAPITimeout int64
AppID string
AppSecret string
EncryptKey string
Expand Down Expand Up @@ -96,6 +97,7 @@ func ServeFeishuBot(cfg *FeishuBotConfig) (err error) {
ConversationLanguage: cfg.ConversationLanguage,
ChatGPTName: cfg.BotName,
Proxy: cfg.Proxy,
Timeout: time.Duration(cfg.OpenAIAPITimeout) * time.Second,
})
if err != nil {
return fmt.Errorf("failed to create chatgpt client: %v", err)
Expand Down

0 comments on commit b8ab9f2

Please sign in to comment.