diff --git a/cmd/tapir/uploads_chat_models_test.go b/cmd/tapir/uploads_chat_models_test.go index eb64f93..cc749de 100644 --- a/cmd/tapir/uploads_chat_models_test.go +++ b/cmd/tapir/uploads_chat_models_test.go @@ -44,3 +44,42 @@ func TestUploadChatModels_NoLocalModelMeansNoneOfferedNotACloudDefault(t *testin t.Errorf("uploadChatModels = %v, want none", got) } } + +// A valid local TAPIR_UPLOAD_CHAT_MODEL that is not in the video chat's chain used to be +// accepted by config and then silently ignored: the shared chat service re-maps a model it +// does not offer, so the user got koala/phi4-mini, whose 8,192-token context cannot hold an +// hour of speech (second adversarial review). + +func TestChatModels_AnUploadChatModelOutsideTheChainIsOfferedWhenUploadsAreOn(t *testing.T) { + var cfg config.Config + cfg.SummarizerModel = "koala/phi4-mini" + cfg.FallbackModel = "iguana/gemma4-26b" + cfg.UploadsEnabled = true + cfg.UploadChatModel = "iguana/gemma4-31b" + + service := chatModels(cfg) + upload := uploadChatModels(cfg) + + if !reflect.DeepEqual(service, []string{"koala/phi4-mini", "iguana/gemma4-26b", "iguana/gemma4-31b"}) { + t.Errorf("chatModels = %v: the shared service must be able to call the configured upload model", service) + } + if !reflect.DeepEqual(upload, service) { + t.Errorf("uploadChatModels = %v, want %v", upload, service) + } +} + +func TestChatModels_NothingIsAddedWhenUploadsAreOffOrTheModelIsNotLocal(t *testing.T) { + var cfg config.Config + cfg.SummarizerModel = "koala/phi4-mini" + cfg.UploadChatModel = "iguana/gemma4-31b" + + if got := chatModels(cfg); !reflect.DeepEqual(got, []string{"koala/phi4-mini"}) { + t.Errorf("uploads off: chatModels = %v, want the video chain unchanged", got) + } + + cfg.UploadsEnabled = true + cfg.UploadChatModel = "berget/mistral-small" + if got := chatModels(cfg); !reflect.DeepEqual(got, []string{"koala/phi4-mini"}) { + t.Errorf("a cloud upload chat model was added to the service: %v", got) + } +}