mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
Implemented `Fork` flag in `ModelNameMapping` to allow aliases as additional models while preserving the original model ID. Updated the `applyOAuthModelMappings` logic, added tests for `Fork` behavior, and updated documentation and examples accordingly.
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package cliproxy
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
|
)
|
|
|
|
func TestApplyOAuthModelMappings_Rename(t *testing.T) {
|
|
cfg := &config.Config{
|
|
OAuthModelMappings: map[string][]config.ModelNameMapping{
|
|
"codex": {
|
|
{Name: "gpt-5", Alias: "g5"},
|
|
},
|
|
},
|
|
}
|
|
models := []*ModelInfo{
|
|
{ID: "gpt-5", Name: "models/gpt-5"},
|
|
}
|
|
|
|
out := applyOAuthModelMappings(cfg, "codex", "oauth", models)
|
|
if len(out) != 1 {
|
|
t.Fatalf("expected 1 model, got %d", len(out))
|
|
}
|
|
if out[0].ID != "g5" {
|
|
t.Fatalf("expected model id %q, got %q", "g5", out[0].ID)
|
|
}
|
|
if out[0].Name != "models/g5" {
|
|
t.Fatalf("expected model name %q, got %q", "models/g5", out[0].Name)
|
|
}
|
|
}
|
|
|
|
func TestApplyOAuthModelMappings_ForkAddsAlias(t *testing.T) {
|
|
cfg := &config.Config{
|
|
OAuthModelMappings: map[string][]config.ModelNameMapping{
|
|
"codex": {
|
|
{Name: "gpt-5", Alias: "g5", Fork: true},
|
|
},
|
|
},
|
|
}
|
|
models := []*ModelInfo{
|
|
{ID: "gpt-5", Name: "models/gpt-5"},
|
|
}
|
|
|
|
out := applyOAuthModelMappings(cfg, "codex", "oauth", models)
|
|
if len(out) != 2 {
|
|
t.Fatalf("expected 2 models, got %d", len(out))
|
|
}
|
|
if out[0].ID != "gpt-5" {
|
|
t.Fatalf("expected first model id %q, got %q", "gpt-5", out[0].ID)
|
|
}
|
|
if out[1].ID != "g5" {
|
|
t.Fatalf("expected second model id %q, got %q", "g5", out[1].ID)
|
|
}
|
|
if out[1].Name != "models/g5" {
|
|
t.Fatalf("expected forked model name %q, got %q", "models/g5", out[1].Name)
|
|
}
|
|
}
|