1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

configurable timeout

This commit is contained in:
Laura
2025-10-25 15:31:21 +02:00
parent 34fa38ac8a
commit 61f0d00bfa
2 changed files with 21 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ package main
import (
"context"
"errors"
"net/http"
"time"
"github.com/revrost/go-openrouter"
)
@@ -12,7 +14,22 @@ func init() {
}
func OpenRouterClient() *openrouter.Client {
return openrouter.NewClient(env.Tokens.OpenRouter, openrouter.WithXTitle("Whiskr"), openrouter.WithHTTPReferer("https://github.com/coalaura/whiskr"))
timeout := env.Settings.Timeout
if timeout <= 0 {
timeout = 1
}
cc := openrouter.DefaultConfig(env.Tokens.OpenRouter)
cc.XTitle = "Whiskr"
cc.HttpReferer = "https://github.com/coalaura/whiskr"
cc.HTTPClient = &http.Client{
Timeout: time.Duration(timeout) * time.Second,
}
return openrouter.NewClientWithConfig(*cc)
}
func OpenRouterStartStream(ctx context.Context, request openrouter.ChatCompletionRequest) (*openrouter.ChatCompletionStream, error) {