summaryrefslogtreecommitdiff
path: root/internal/llm/anthropic.go
diff options
context:
space:
mode:
authorPaul Bütow <1224732+snonux@users.noreply.github.com>2026-02-02 20:55:36 +0200
committerGitHub <noreply@github.com>2026-02-02 20:55:36 +0200
commitda01d65da337cc2f6c99d8236140f8fb45c6bd5e (patch)
tree4887ab977b8a92165e180dd3d3c7323df7e6172b /internal/llm/anthropic.go
parent7194696eb8c4c5bd50f69df96e9a6b87cec1f049 (diff)
parent791cd282ec143c9bbb44eba3b2271f1573272ba5 (diff)
Merge pull request #2 from florianbuetow/feature-timeout-config
feat: add configurable request timeout for LLM calls
Diffstat (limited to 'internal/llm/anthropic.go')
-rw-r--r--internal/llm/anthropic.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/llm/anthropic.go b/internal/llm/anthropic.go
index c0cdc9a..a6c1454 100644
--- a/internal/llm/anthropic.go
+++ b/internal/llm/anthropic.go
@@ -90,14 +90,21 @@ var (
// newAnthropic constructs an Anthropic client using explicit configuration values.
// The apiKey may be empty; calls will fail until a valid key is supplied.
func newAnthropic(baseURL, model, apiKey string, defaultTemp *float64) Client {
+ return newAnthropicWithTimeout(baseURL, model, apiKey, defaultTemp, 0)
+}
+
+func newAnthropicWithTimeout(baseURL, model, apiKey string, defaultTemp *float64, timeoutSec int) Client {
if strings.TrimSpace(baseURL) == "" {
baseURL = "https://api.anthropic.com/v1"
}
if strings.TrimSpace(model) == "" {
model = "claude-3-5-sonnet-20241022"
}
+ if timeoutSec <= 0 {
+ timeoutSec = 30
+ }
return anthropicClient{
- httpClient: &http.Client{Timeout: 30 * time.Second},
+ httpClient: &http.Client{Timeout: time.Duration(timeoutSec) * time.Second},
apiKey: apiKey,
baseURL: baseURL,
defaultModel: model,