summaryrefslogtreecommitdiff
path: root/internal/llm/openai.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/llm/openai.go')
-rw-r--r--internal/llm/openai.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/llm/openai.go b/internal/llm/openai.go
index b97111d..6bc3a7c 100644
--- a/internal/llm/openai.go
+++ b/internal/llm/openai.go
@@ -77,14 +77,21 @@ type oaStreamChunk struct {
// newOpenAI constructs an OpenAI client using explicit configuration values.
// The apiKey may be empty; calls will fail until a valid key is supplied.
func newOpenAI(baseURL, model, apiKey string, defaultTemp *float64) Client {
+ return newOpenAIWithTimeout(baseURL, model, apiKey, defaultTemp, 0)
+}
+
+func newOpenAIWithTimeout(baseURL, model, apiKey string, defaultTemp *float64, timeoutSec int) Client {
if strings.TrimSpace(baseURL) == "" {
baseURL = "https://api.openai.com/v1"
}
if strings.TrimSpace(model) == "" {
model = "gpt-4.1"
}
+ if timeoutSec <= 0 {
+ timeoutSec = 30
+ }
return openAIClient{
- httpClient: &http.Client{Timeout: 30 * time.Second},
+ httpClient: &http.Client{Timeout: time.Duration(timeoutSec) * time.Second},
apiKey: apiKey,
baseURL: baseURL,
defaultModel: model,