mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-12 04:13:55 +00:00
The provider verify call and the provider models-list call used hardcoded timeouts (30s and 15s) that were too low for slow models. Introduce a tenant-scoped, UI-editable setting `providers.request_timeout_sec` (default 30) stored in system_configs, consumed by both handlers, and overlaid from config.json like tts.timeout_ms. Adds a field to the System Settings modal (all 4 locales) so operators can raise it without a redeploy. Co-authored-by: Bruno Clermont <bruno.clermont@gmail.com>
30 lines
889 B
Go
30 lines
889 B
Go
package http
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/nextlevelbuilder/goclaw/internal/store"
|
|
)
|
|
|
|
// defaultProviderRequestTimeoutSec is used when the tenant has not configured
|
|
// (or has configured invalid values for) providers.request_timeout_sec.
|
|
const defaultProviderRequestTimeoutSec = 30
|
|
|
|
// loadProviderRequestTimeoutSec reads the tenant's providers.request_timeout_sec
|
|
// system config. Returns defaultProviderRequestTimeoutSec (30) when unset/invalid.
|
|
func loadProviderRequestTimeoutSec(ctx context.Context, sc store.SystemConfigStore) int {
|
|
if sc == nil {
|
|
return defaultProviderRequestTimeoutSec
|
|
}
|
|
raw, err := sc.Get(ctx, "providers.request_timeout_sec")
|
|
if err != nil || raw == "" {
|
|
return defaultProviderRequestTimeoutSec
|
|
}
|
|
timeoutSec, err := strconv.Atoi(raw)
|
|
if err != nil || timeoutSec <= 0 {
|
|
return defaultProviderRequestTimeoutSec
|
|
}
|
|
return timeoutSec
|
|
}
|