mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
feat(chat,seahorse): persist and display model_name across history (#2897)
* feat(chat,seahorse): persist and display model_name across history * test(seahorse): fix lint regressions in repair coverage * fix(pico): preserve model_name in live updates * fix(pico): preserve model_name through live stream wrappers
This commit is contained in:
@@ -7,6 +7,55 @@ import (
|
||||
"github.com/sipeed/picoclaw/pkg/providers"
|
||||
)
|
||||
|
||||
func TestModelNameFromIdentityKey_LegacyProviderModel(t *testing.T) {
|
||||
if got := modelNameFromIdentityKey("openai/gpt-5.4"); got != "gpt-5.4" {
|
||||
t.Fatalf("modelNameFromIdentityKey() = %q, want %q", got, "gpt-5.4")
|
||||
}
|
||||
}
|
||||
|
||||
func TestModelNameFromIdentityKey_PreservesNonLegacyIdentity(t *testing.T) {
|
||||
if got := modelNameFromIdentityKey("model_name:primary"); got != "model_name:primary" {
|
||||
t.Fatalf("modelNameFromIdentityKey() = %q, want %q", got, "model_name:primary")
|
||||
}
|
||||
}
|
||||
|
||||
func TestModelAliasFromCandidateIdentityKey(t *testing.T) {
|
||||
if got := modelAliasFromCandidateIdentityKey("model_name:primary"); got != "primary" {
|
||||
t.Fatalf("modelAliasFromCandidateIdentityKey() = %q, want %q", got, "primary")
|
||||
}
|
||||
if got := modelAliasFromCandidateIdentityKey("openai/gpt-5.4"); got != "" {
|
||||
t.Fatalf("modelAliasFromCandidateIdentityKey() = %q, want empty", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolvedCandidateModelName_PrefersIdentityAlias(t *testing.T) {
|
||||
got := resolvedCandidateModelName([]providers.FallbackCandidate{
|
||||
{Provider: "openai", Model: "gpt-5.4", IdentityKey: "model_name:primary"},
|
||||
}, "fallback-model")
|
||||
if got != "primary" {
|
||||
t.Fatalf("resolvedCandidateModelName() = %q, want %q", got, "primary")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolvedCandidateModelName_DoesNotScanFallbackAliases(t *testing.T) {
|
||||
got := resolvedCandidateModelName([]providers.FallbackCandidate{
|
||||
{Provider: "openai", Model: "gpt-5.4"},
|
||||
{Provider: "openai", Model: "gpt-5.4-mini", IdentityKey: "model_name:fallback"},
|
||||
}, "primary-model")
|
||||
if got != "primary-model" {
|
||||
t.Fatalf("resolvedCandidateModelName() = %q, want %q", got, "primary-model")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolvedCandidateModelName_UsesCandidateDisplayName(t *testing.T) {
|
||||
got := resolvedCandidateModelName([]providers.FallbackCandidate{
|
||||
{Provider: "openai", Model: "gpt-5.4", DisplayName: "gpt-5.4-display"},
|
||||
}, "fallback-model")
|
||||
if got != "gpt-5.4-display" {
|
||||
t.Fatalf("resolvedCandidateModelName() = %q, want %q", got, "gpt-5.4-display")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveActiveModelConfig_PrefersCandidateIdentityKey(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
ModelList: []*config.ModelConfig{
|
||||
|
||||
Reference in New Issue
Block a user