Refactored orchestrator for staged file handling, added structured prompt support, adjusted Feishu file handling
This commit is contained in:
48
internal/agent/orchestrator_skill_selection_test.go
Normal file
48
internal/agent/orchestrator_skill_selection_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"laodingbot/internal/knowledge"
|
||||
)
|
||||
|
||||
func TestBuildQueryTokensIncludesChineseBigrams(t *testing.T) {
|
||||
tokens := buildQueryTokens("请执行命令并查看文件")
|
||||
joined := strings.Join(tokens, ",")
|
||||
if !strings.Contains(joined, "命令") {
|
||||
t.Fatalf("expected token contains 命令, got: %v", tokens)
|
||||
}
|
||||
if !strings.Contains(joined, "文件") {
|
||||
t.Fatalf("expected token contains 文件, got: %v", tokens)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectRelevantSkillsPrefersMatchingSkill(t *testing.T) {
|
||||
o := &Orchestrator{
|
||||
skills: []knowledge.Skill{
|
||||
{Name: "文件系统查询专家", Content: "适用于目录、文件、路径、命令执行等场景"},
|
||||
{Name: "天气查询", Content: "用于天气和空气质量查询"},
|
||||
{Name: "日程助手", Content: "用于日程管理"},
|
||||
},
|
||||
}
|
||||
|
||||
selected := o.selectRelevantSkills("帮我执行命令查看某个文件", 2)
|
||||
if len(selected) == 0 {
|
||||
t.Fatal("expected non-empty selected skills")
|
||||
}
|
||||
if selected[0].Name != "文件系统查询专家" {
|
||||
t.Fatalf("expected top skill 文件系统查询专家, got: %s", selected[0].Name)
|
||||
}
|
||||
if len(selected) > 2 {
|
||||
t.Fatalf("expected at most 2 skills, got: %d", len(selected))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatRuntimeContextForPromptIncludesGOOS(t *testing.T) {
|
||||
doc := formatRuntimeContextForPrompt()
|
||||
if !strings.Contains(strings.ToLower(doc), strings.ToLower(runtime.GOOS)) {
|
||||
t.Fatalf("expected runtime context contains GOOS=%s, got: %s", runtime.GOOS, doc)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user