mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-04-26 15:05:17 +00:00
Fix GitHub Copilot gpt-5.4 endpoint routing
Amp-Thread-ID: https://ampcode.com/threads/T-019d14cd-bc90-70ce-b1ae-87bc97332650 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -365,6 +365,19 @@ func GetGitHubCopilotModels() []*ModelInfo {
|
|||||||
SupportedEndpoints: []string{"/responses"},
|
SupportedEndpoints: []string{"/responses"},
|
||||||
Thinking: &ThinkingSupport{Levels: []string{"none", "low", "medium", "high", "xhigh"}},
|
Thinking: &ThinkingSupport{Levels: []string{"none", "low", "medium", "high", "xhigh"}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ID: "gpt-5.4",
|
||||||
|
Object: "model",
|
||||||
|
Created: now,
|
||||||
|
OwnedBy: "github-copilot",
|
||||||
|
Type: "github-copilot",
|
||||||
|
DisplayName: "GPT-5.4",
|
||||||
|
Description: "OpenAI GPT-5.4 via GitHub Copilot",
|
||||||
|
ContextLength: 200000,
|
||||||
|
MaxCompletionTokens: 32768,
|
||||||
|
SupportedEndpoints: []string{"/responses"},
|
||||||
|
Thinking: &ThinkingSupport{Levels: []string{"low", "medium", "high", "xhigh"}},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ID: "claude-haiku-4.5",
|
ID: "claude-haiku-4.5",
|
||||||
Object: "model",
|
Object: "model",
|
||||||
|
|||||||
@@ -577,9 +577,32 @@ func useGitHubCopilotResponsesEndpoint(sourceFormat sdktranslator.Format, model
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
baseModel := strings.ToLower(thinking.ParseSuffix(model).ModelName)
|
baseModel := strings.ToLower(thinking.ParseSuffix(model).ModelName)
|
||||||
|
if info := registry.GetGlobalRegistry().GetModelInfo(baseModel, ""); info != nil {
|
||||||
|
if len(info.SupportedEndpoints) > 0 && !containsEndpoint(info.SupportedEndpoints, githubCopilotChatPath) && containsEndpoint(info.SupportedEndpoints, githubCopilotResponsesPath) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, info := range registry.GetGitHubCopilotModels() {
|
||||||
|
if info == nil || !strings.EqualFold(info.ID, baseModel) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(info.SupportedEndpoints) > 0 && !containsEndpoint(info.SupportedEndpoints, githubCopilotChatPath) && containsEndpoint(info.SupportedEndpoints, githubCopilotResponsesPath) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
return strings.Contains(baseModel, "codex")
|
return strings.Contains(baseModel, "codex")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func containsEndpoint(endpoints []string, endpoint string) bool {
|
||||||
|
for _, item := range endpoints {
|
||||||
|
if item == endpoint {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// flattenAssistantContent converts assistant message content from array format
|
// flattenAssistantContent converts assistant message content from array format
|
||||||
// to a joined string. GitHub Copilot requires assistant content as a string;
|
// to a joined string. GitHub Copilot requires assistant content as a string;
|
||||||
// sending it as an array causes Claude models to re-answer all previous prompts.
|
// sending it as an array causes Claude models to re-answer all previous prompts.
|
||||||
|
|||||||
@@ -70,6 +70,13 @@ func TestUseGitHubCopilotResponsesEndpoint_CodexModel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUseGitHubCopilotResponsesEndpoint_RegistryResponsesOnlyModel(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
if !useGitHubCopilotResponsesEndpoint(sdktranslator.FromString("openai"), "gpt-5.4") {
|
||||||
|
t.Fatal("expected responses-only registry model to use /responses")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUseGitHubCopilotResponsesEndpoint_DefaultChat(t *testing.T) {
|
func TestUseGitHubCopilotResponsesEndpoint_DefaultChat(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
if useGitHubCopilotResponsesEndpoint(sdktranslator.FromString("openai"), "claude-3-5-sonnet") {
|
if useGitHubCopilotResponsesEndpoint(sdktranslator.FromString("openai"), "claude-3-5-sonnet") {
|
||||||
|
|||||||
Reference in New Issue
Block a user