mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-03-09 15:25:17 +00:00
GitHub Copilot API rejects model names with suffixes (e.g. claude-opus-4.6(medium)). The OAuthModelAlias resolution correctly maps aliases like 'opus(medium)' to 'claude-opus-4.6(medium)' preserving the suffix, but the executor must strip the suffix before sending to the upstream API since Copilot only accepts bare model names. Update normalizeModel in github_copilot_executor to strip suffixes using thinking.ParseSuffix, matching the pattern used by other executors. Also add test coverage for: - OAuthModelAliasChannel github-copilot and kiro channel resolution - Suffix preservation in alias resolution for github-copilot - normalizeModel suffix stripping in github_copilot_executor
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package executor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func TestGitHubCopilotNormalizeModel_StripsSuffix(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
model string
|
|
wantModel string
|
|
}{
|
|
{
|
|
name: "suffix stripped",
|
|
model: "claude-opus-4.6(medium)",
|
|
wantModel: "claude-opus-4.6",
|
|
},
|
|
{
|
|
name: "no suffix unchanged",
|
|
model: "claude-opus-4.6",
|
|
wantModel: "claude-opus-4.6",
|
|
},
|
|
{
|
|
name: "different suffix stripped",
|
|
model: "gpt-4o(high)",
|
|
wantModel: "gpt-4o",
|
|
},
|
|
{
|
|
name: "numeric suffix stripped",
|
|
model: "gemini-2.5-pro(8192)",
|
|
wantModel: "gemini-2.5-pro",
|
|
},
|
|
}
|
|
|
|
e := &GitHubCopilotExecutor{}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
body := []byte(`{"model":"` + tt.model + `","messages":[]}`)
|
|
got := e.normalizeModel(tt.model, body)
|
|
|
|
gotModel := gjson.GetBytes(got, "model").String()
|
|
if gotModel != tt.wantModel {
|
|
t.Fatalf("normalizeModel() model = %q, want %q", gotModel, tt.wantModel)
|
|
}
|
|
})
|
|
}
|
|
}
|