feat(agent): relax provider http timeouts (#348)

This commit is contained in:
Fodesu
2026-04-15 00:07:41 +08:00
committed by GitHub
parent 38ac907361
commit 8e1ed3683f
10 changed files with 95 additions and 28 deletions
+10 -18
View File
@@ -39,14 +39,16 @@ var (
// NewSDKChatModel builds a Twilight AI SDK Model from the resolved model config.
func NewSDKChatModel(cfg SDKModelConfig) *sdk.Model {
if cfg.HTTPClient == nil {
cfg.HTTPClient = NewProviderHTTPClient(0)
}
switch ClientType(cfg.ClientType) {
case ClientTypeOpenAICompletions:
opts := []openaicompletions.Option{
openaicompletions.WithAPIKey(cfg.APIKey),
}
if cfg.HTTPClient != nil {
opts = append(opts, openaicompletions.WithHTTPClient(cfg.HTTPClient))
}
opts = append(opts, openaicompletions.WithHTTPClient(cfg.HTTPClient))
if cfg.BaseURL != "" {
opts = append(opts, openaicompletions.WithBaseURL(cfg.BaseURL))
}
@@ -57,9 +59,7 @@ func NewSDKChatModel(cfg SDKModelConfig) *sdk.Model {
opts := []openairesponses.Option{
openairesponses.WithAPIKey(cfg.APIKey),
}
if cfg.HTTPClient != nil {
opts = append(opts, openairesponses.WithHTTPClient(cfg.HTTPClient))
}
opts = append(opts, openairesponses.WithHTTPClient(cfg.HTTPClient))
if cfg.BaseURL != "" {
opts = append(opts, openairesponses.WithBaseURL(cfg.BaseURL))
}
@@ -70,9 +70,7 @@ func NewSDKChatModel(cfg SDKModelConfig) *sdk.Model {
opts := []openaicodex.Option{
openaicodex.WithAccessToken(cfg.APIKey),
}
if cfg.HTTPClient != nil {
opts = append(opts, openaicodex.WithHTTPClient(cfg.HTTPClient))
}
opts = append(opts, openaicodex.WithHTTPClient(cfg.HTTPClient))
if cfg.CodexAccountID != "" {
opts = append(opts, openaicodex.WithAccountID(cfg.CodexAccountID))
}
@@ -85,9 +83,7 @@ func NewSDKChatModel(cfg SDKModelConfig) *sdk.Model {
opts := []anthropicmessages.Option{
anthropicmessages.WithAPIKey(cfg.APIKey),
}
if cfg.HTTPClient != nil {
opts = append(opts, anthropicmessages.WithHTTPClient(cfg.HTTPClient))
}
opts = append(opts, anthropicmessages.WithHTTPClient(cfg.HTTPClient))
if cfg.BaseURL != "" {
opts = append(opts, anthropicmessages.WithBaseURL(cfg.BaseURL))
}
@@ -105,9 +101,7 @@ func NewSDKChatModel(cfg SDKModelConfig) *sdk.Model {
opts := []googlegenerative.Option{
googlegenerative.WithAPIKey(cfg.APIKey),
}
if cfg.HTTPClient != nil {
opts = append(opts, googlegenerative.WithHTTPClient(cfg.HTTPClient))
}
opts = append(opts, googlegenerative.WithHTTPClient(cfg.HTTPClient))
if cfg.BaseURL != "" {
opts = append(opts, googlegenerative.WithBaseURL(cfg.BaseURL))
}
@@ -118,9 +112,7 @@ func NewSDKChatModel(cfg SDKModelConfig) *sdk.Model {
opts := []openaicompletions.Option{
openaicompletions.WithAPIKey(cfg.APIKey),
}
if cfg.HTTPClient != nil {
opts = append(opts, openaicompletions.WithHTTPClient(cfg.HTTPClient))
}
opts = append(opts, openaicompletions.WithHTTPClient(cfg.HTTPClient))
if cfg.BaseURL != "" {
opts = append(opts, openaicompletions.WithBaseURL(cfg.BaseURL))
}