File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ type AgentDefaults struct {
1818 Temperature float64 `json:"temperature"`
1919 MaxToolIterations int `json:"maxToolIterations"`
2020 HeartbeatIntervalS int `json:"heartbeatIntervalS"`
21+ RequestTimeoutS int `json:"requestTimeoutS"`
2122}
2223
2324type ChannelsConfig struct {
Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ import "github.com/local/picobot/internal/config"
88// - else fallback to stub
99func NewProviderFromConfig (cfg config.Config ) LLMProvider {
1010 if cfg .Providers .OpenAI != nil && cfg .Providers .OpenAI .APIKey != "" {
11- return NewOpenAIProvider (cfg .Providers .OpenAI .APIKey , cfg .Providers .OpenAI .APIBase )
11+ return NewOpenAIProvider (
12+ cfg .Providers .OpenAI .APIKey ,
13+ cfg .Providers .OpenAI .APIBase ,
14+ cfg .Agents .Defaults .RequestTimeoutS ,
15+ )
1216 }
1317 return NewStubProvider ()
1418}
Original file line number Diff line number Diff line change @@ -19,15 +19,18 @@ type OpenAIProvider struct {
1919 Client * http.Client
2020}
2121
22- func NewOpenAIProvider (apiKey , apiBase string ) * OpenAIProvider {
22+ func NewOpenAIProvider (apiKey , apiBase string , timeoutSecs int ) * OpenAIProvider {
2323 if apiBase == "" {
2424 apiBase = "https://api.openai.com/v1" // sensible default; can be overridden
2525 }
26+ if timeoutSecs <= 0 {
27+ timeoutSecs = 60 // default 60 seconds
28+ }
2629 return & OpenAIProvider {
2730 APIKey : apiKey ,
2831 APIBase : strings .TrimRight (apiBase , "/" ),
2932 Client : & http.Client {
30- Timeout : 60 * time .Second ,
33+ Timeout : time . Duration ( timeoutSecs ) * time .Second ,
3134 },
3235 }
3336}
You can’t perform that action at this time.
0 commit comments