From 22009e90a4576764687328ed3cf81efbd2813d77 Mon Sep 17 00:00:00 2001 From: Florian <2320560+florianbuetow@users.noreply.github.com> Date: Sat, 31 Jan 2026 23:48:38 +0100 Subject: feat: add configurable request timeout for LLM calls Local LLMs (LM Studio, Ollama, etc.) often need more than the default 30-second timeout. Added request_timeout config option (in seconds) to [general] section and HEXAI_REQUEST_TIMEOUT env var. Original constructor signatures preserved via *WithTimeout variants, so no test changes required. --- internal/llm/anthropic.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'internal/llm/anthropic.go') 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, -- cgit v1.2.3