This commit is contained in:
lpf
2026-02-13 14:20:24 +08:00
parent 28cea4c3bd
commit 1deb9e6888
2 changed files with 21 additions and 3 deletions

View File

@@ -8,12 +8,14 @@ package providers
import (
"bytes"
"clawgo/pkg/logger"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"time"
"clawgo/pkg/config"
)
@@ -25,13 +27,15 @@ type HTTPProvider struct {
httpClient *http.Client
}
const defaultChatTimeout = 90 * time.Second
func NewHTTPProvider(apiKey, apiBase, authMode string) *HTTPProvider {
return &HTTPProvider{
apiKey: apiKey,
apiBase: apiBase,
authMode: authMode,
httpClient: &http.Client{
Timeout: 0,
Timeout: defaultChatTimeout,
},
}
}
@@ -41,6 +45,14 @@ func (p *HTTPProvider) Chat(ctx context.Context, messages []Message, tools []Too
return nil, fmt.Errorf("API base not configured")
}
logger.DebugCF("provider", "HTTP chat request", map[string]interface{}{
"api_base": p.apiBase,
"model": model,
"messages_count": len(messages),
"tools_count": len(tools),
"timeout": defaultChatTimeout.String(),
})
requestBody := map[string]interface{}{
"model": model,
"messages": messages,