chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"academy/internal/models/api"
|
||||
)
|
||||
|
||||
// The agent composes multimodal turns as MultiContent parts — the shape every
|
||||
// remote protocol prefers — while older callers fill Images. Ollama read only
|
||||
// the latter, so such a turn reached the model with neither its question nor
|
||||
// its picture and came back answering about nothing.
|
||||
func TestOllamaConvertMessagesReadsMultiContent(t *testing.T) {
|
||||
c := &OllamaChat{}
|
||||
original := []string{"data:image/png;base64,aGVsbG8="}
|
||||
messages := []Message{
|
||||
{
|
||||
Role: "user",
|
||||
Images: original,
|
||||
MultiContent: []api.MessageContentPart{
|
||||
{Type: "text", Text: "what is this?"},
|
||||
{Type: "image_url", ImageURL: &api.ImageURL{URL: "data:image/png;base64,d29ybGQ="}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
got := c.convertMessages(messages)
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("expected one message, got %d", len(got))
|
||||
}
|
||||
if got[0].Content != "what is this?" {
|
||||
t.Errorf("text parts should become the content, got %q", got[0].Content)
|
||||
}
|
||||
if len(got[0].Images) != 2 {
|
||||
t.Errorf("both the legacy image and the MultiContent one should survive, got %d", len(got[0].Images))
|
||||
}
|
||||
if len(original) != 1 || original[0] != "data:image/png;base64,aGVsbG8=" {
|
||||
t.Errorf("the caller's slice must not be written through, got %v", original)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOllamaConvertMessagesKeepsExplicitContent(t *testing.T) {
|
||||
c := &OllamaChat{}
|
||||
got := c.convertMessages([]Message{{
|
||||
Role: "user",
|
||||
Content: "already set",
|
||||
MultiContent: []api.MessageContentPart{
|
||||
{Type: "text", Text: "ignored"},
|
||||
},
|
||||
}})
|
||||
if got[0].Content != "already set" {
|
||||
t.Errorf("an explicit Content wins over the parts, got %q", got[0].Content)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user