diff options
| author | Paul Bütow <1224732+snonux@users.noreply.github.com> | 2026-02-02 20:55:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-02 20:55:36 +0200 |
| commit | da01d65da337cc2f6c99d8236140f8fb45c6bd5e (patch) | |
| tree | 4887ab977b8a92165e180dd3d3c7323df7e6172b /internal/llm/openrouter.go | |
| parent | 7194696eb8c4c5bd50f69df96e9a6b87cec1f049 (diff) | |
| parent | 791cd282ec143c9bbb44eba3b2271f1573272ba5 (diff) | |
Merge pull request #2 from florianbuetow/feature-timeout-config
feat: add configurable request timeout for LLM calls
Diffstat (limited to 'internal/llm/openrouter.go')
| -rw-r--r-- | internal/llm/openrouter.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/llm/openrouter.go b/internal/llm/openrouter.go index 4aae398..21e3102 100644 --- a/internal/llm/openrouter.go +++ b/internal/llm/openrouter.go @@ -23,14 +23,21 @@ type openRouterClient struct { } func newOpenRouter(baseURL, model, apiKey string, defaultTemp *float64) Client { + return newOpenRouterWithTimeout(baseURL, model, apiKey, defaultTemp, 0) +} + +func newOpenRouterWithTimeout(baseURL, model, apiKey string, defaultTemp *float64, timeoutSec int) Client { if strings.TrimSpace(baseURL) == "" { baseURL = "https://openrouter.ai/api/v1" } if strings.TrimSpace(model) == "" { model = "openrouter/auto" } + if timeoutSec <= 0 { + timeoutSec = 30 + } return openRouterClient{ - httpClient: &http.Client{Timeout: 30 * time.Second}, + httpClient: &http.Client{Timeout: time.Duration(timeoutSec) * time.Second}, apiKey: apiKey, baseURL: baseURL, defaultModel: model, |
