mirror of
https://github.com/wavetermdev/waveterm
synced 2026-04-21 22:47:16 +00:00
`makeHTTPClient(proxyURL)` had been duplicated across AI backends with
equivalent behavior. This change consolidates the logic into a single
helper in `aiutil` and updates backends to consume it, then removes
backend-local tests that only re-verified that shared utility behavior.
- **Shared client construction**
- Added `aiutil.MakeHTTPClient(proxyURL string) (*http.Client, error)`
in `pkg/aiusechat/aiutil/aiutil.go`.
- Standardizes proxy parsing and `http.Transport.Proxy` setup in one
place.
- Keeps streaming-safe client semantics (`Timeout: 0`) and existing
invalid proxy URL error behavior.
- **Backend refactor**
- Removed duplicated client/proxy setup blocks from:
- `pkg/aiusechat/openaichat/openaichat-backend.go`
- `pkg/aiusechat/gemini/gemini-backend.go`
- `pkg/aiusechat/openai/openai-backend.go`
- `pkg/aiusechat/anthropic/anthropic-backend.go`
- Replaced with direct calls to the shared helper.
- **Test cleanup**
- Deleted backend tests that only covered basic proxy client creation
and no backend-specific behavior:
- `pkg/aiusechat/openaichat/openaichat-backend_test.go`
- `pkg/aiusechat/gemini/gemini-backend_test.go`
```go
httpClient, err := aiutil.MakeHTTPClient(chatOpts.Config.ProxyURL)
if err != nil {
return nil, nil, nil, err
}
resp, err := httpClient.Do(req)
```
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
|
||
|---|---|---|
| .. | ||
| aiutil.go | ||