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>
116 lines
2.5 KiB
JSON
116 lines
2.5 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$defs": {
|
|
"AIModeConfigType": {
|
|
"properties": {
|
|
"display:name": {
|
|
"type": "string"
|
|
},
|
|
"display:order": {
|
|
"type": "number"
|
|
},
|
|
"display:icon": {
|
|
"type": "string"
|
|
},
|
|
"display:description": {
|
|
"type": "string"
|
|
},
|
|
"ai:provider": {
|
|
"type": "string",
|
|
"enum": [
|
|
"wave",
|
|
"google",
|
|
"groq",
|
|
"openrouter",
|
|
"nanogpt",
|
|
"openai",
|
|
"azure",
|
|
"azure-legacy",
|
|
"custom"
|
|
]
|
|
},
|
|
"ai:apitype": {
|
|
"type": "string",
|
|
"enum": [
|
|
"google-gemini",
|
|
"openai-responses",
|
|
"openai-chat"
|
|
]
|
|
},
|
|
"ai:model": {
|
|
"type": "string"
|
|
},
|
|
"ai:thinkinglevel": {
|
|
"type": "string",
|
|
"enum": [
|
|
"low",
|
|
"medium",
|
|
"high"
|
|
]
|
|
},
|
|
"ai:verbosity": {
|
|
"type": "string",
|
|
"enum": [
|
|
"low",
|
|
"medium",
|
|
"high"
|
|
],
|
|
"description": "Text verbosity level (OpenAI Responses API only)"
|
|
},
|
|
"ai:endpoint": {
|
|
"type": "string"
|
|
},
|
|
"ai:proxyurl": {
|
|
"type": "string"
|
|
},
|
|
"ai:azureapiversion": {
|
|
"type": "string"
|
|
},
|
|
"ai:apitoken": {
|
|
"type": "string"
|
|
},
|
|
"ai:apitokensecretname": {
|
|
"type": "string"
|
|
},
|
|
"ai:azureresourcename": {
|
|
"type": "string"
|
|
},
|
|
"ai:azuredeployment": {
|
|
"type": "string"
|
|
},
|
|
"ai:capabilities": {
|
|
"items": {
|
|
"type": "string",
|
|
"enum": [
|
|
"pdfs",
|
|
"images",
|
|
"tools"
|
|
]
|
|
},
|
|
"type": "array"
|
|
},
|
|
"ai:switchcompat": {
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"type": "array"
|
|
},
|
|
"waveai:cloud": {
|
|
"type": "boolean"
|
|
},
|
|
"waveai:premium": {
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"additionalProperties": false,
|
|
"type": "object",
|
|
"required": [
|
|
"display:name"
|
|
]
|
|
}
|
|
},
|
|
"additionalProperties": {
|
|
"$ref": "#/$defs/AIModeConfigType"
|
|
},
|
|
"type": "object"
|
|
}
|