Files
memoryweave/go/internal/api/routes/skillref_test.go
T
xiaoyi dc2b9db683 feat(distill,recall): 蒸馏粒度三档 + skill 分节召回增强(t_afacc477,本地未部署)
- distill: ZHIYI_DISTILL_MODE 三档(current/context/merged)+ ZHIYI_DISTILL_CAP 可配
- distill: 信息密度灰度门 ZHIYI_DISTILL_DENSITY(默认关,关态 prompt 逐字节不变)
- recall: skillref 方案二,skill 文档进召回(新增 routes/skillref.go)
- memory: DerivedFrom 原文指针(derived_from 列),供回溯原始 episode
- 验证: go build ./... 通过 / go test storage+distill+routes 全 ok
- gitea 推送暂缓(家里服务器维修中)
2026-11-06 21:25:46 +08:00

40 lines
1003 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package routes
import (
"os"
"path/filepath"
"testing"
)
// TestNPYParse 验证能解析 skill-find.py 维护的真实索引
func TestNPYParse(t *testing.T) {
home, _ := os.UserHomeDir()
p := filepath.Join(home, ".hermes", "skills", ".vec.npy")
raw, err := os.ReadFile(p)
if err != nil {
t.Skip("索引不存在:", err)
}
mat, ok := parseNPYFloat32(raw)
if !ok {
t.Fatalf(".npy 解析失败,前 200 字节: %q", raw[:min(200, len(raw))])
}
if len(mat) == 0 {
t.Fatal("解析出 0 行")
}
t.Logf("解析成功: %d 行 × %d 维", len(mat), len(mat[0]))
}
// TestSkillRefsFor 端到端:真实查询能拿到 skill_refs
func TestSkillRefsFor(t *testing.T) {
if os.Getenv("ZHIYI_SKILLREF_E2E") != "1" {
t.Skip("set ZHIYI_SKILLREF_E2E=1 才跑(依赖 bge 服务)")
}
refs := SkillRefsFor("织忆部署时 Go 和 Rust 二进制的启停顺序", 3)
if len(refs) == 0 {
t.Fatal("skill_refs 为空")
}
for _, r := range refs {
t.Logf(" %s %.3f", r.Name, r.Score)
}
}