mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-20 00:48:00 +00:00
fix: zen adapter strips multimodal parts (upstream is text-only)
This commit is contained in:
@ -135,6 +135,37 @@ func TestOpenCodeAdapterFingerprint(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenCodeStripsMultiModalParts(t *testing.T) {
|
||||
vm := NewVM(freshAdapterDir(t))
|
||||
if err := vm.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer vm.Stop()
|
||||
body := `{"model":"x","messages":[
|
||||
{"role":"user","content":[
|
||||
{"type":"text","text":"describe"},
|
||||
{"type":"image_url","image_url":{"url":"data:image/png;base64,QUJD"}},
|
||||
{"type":"input_audio","input_audio":{"data":"QQ","format":"wav"}}
|
||||
]},
|
||||
{"role":"user","content":[{"type":"image_url","image_url":{"url":"https://ex.com/a.png"}}]},
|
||||
{"role":"assistant","content":"plain"}
|
||||
]}`
|
||||
out, err := vm.Transform("opencode", "transform_request", body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(out, "image_url") || strings.Contains(out, "input_audio") {
|
||||
t.Fatalf("opencode must strip multimodal parts: %s", out)
|
||||
}
|
||||
if !strings.Contains(out, "describe") {
|
||||
t.Fatalf("text parts must survive: %s", out)
|
||||
}
|
||||
// image-only message dropped: only the text message and plain assistant message remain
|
||||
if got := strings.Count(out, `"role"`); got != 2 {
|
||||
t.Fatalf("image-only message must be dropped, got %d messages: %s", got, out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildHeadersCustomHook(t *testing.T) {
|
||||
vm := NewVM(freshAdapterDir(t))
|
||||
if err := vm.Start(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user