mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
fix: LLM 工具循环 400、中断消息注入、ConPTY 终端支持
- agent: 工具轮请求尾部补 user 占位(zen 网关强制),tool 消息正确配对 - agent: 工具提醒/中断以 system 角色注入并带 [中断消息] 前缀,不进用户履历;系统提示词说明中断消息格式 - agentcli: 基于 ConPTY 的交互式终端(ptywin fork),terminal_create/read/write/resize/close/watch - webui: server 输出通道适配器(保留 reasoning_content/disable_thinking) - GUI: 沉浸式标题栏、icon 圆角重制、mascot 等打磨
This commit is contained in:
@ -86,3 +86,45 @@ func newSynthEmbedder(t testing.TB, dim int) *StaticEmbedder {
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// Phase 5: #topN 规格裁剪加载——只加载前 N 个词向量,控制常驻内存
|
||||
func TestStaticEmbedderTopNSpec(t *testing.T) {
|
||||
path := writeSynthModel(t, 300)
|
||||
|
||||
// 解析规格
|
||||
cleanPath, topN := parseModelSpec(path + "#top5")
|
||||
if cleanPath != path || topN != 5 {
|
||||
t.Fatalf("parseModelSpec(#top5) = (%q, %d), want (%q, 5)", cleanPath, topN, path)
|
||||
}
|
||||
cleanPath2, topN2 := parseModelSpec(path)
|
||||
if cleanPath2 != path || topN2 != 0 {
|
||||
t.Fatalf("parseModelSpec(plain) = (%q, %d), want (%q, 0)", cleanPath2, topN2, path)
|
||||
}
|
||||
cleanPath3, topN3 := parseModelSpec(path + "#abc")
|
||||
if cleanPath3 != path || topN3 != 0 {
|
||||
t.Fatalf("parseModelSpec(#abc) = (%q, %d), want (%q, 0)", cleanPath3, topN3, path)
|
||||
}
|
||||
|
||||
// 裁剪加载
|
||||
e := NewStaticEmbedder(path + "#top5")
|
||||
if !e.Loaded() {
|
||||
t.Fatal("topN embedder should be loaded")
|
||||
}
|
||||
if len(e.words) != 5 {
|
||||
t.Errorf("expected 5 words loaded with #top5, got %d", len(e.words))
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 5: 裁剪后向量化仍可用(未命中词走 unkVec 兜底)
|
||||
func TestStaticEmbedderTopNVectorize(t *testing.T) {
|
||||
path := writeSynthModel(t, 300)
|
||||
e := NewStaticEmbedder(path + "#top1")
|
||||
if !e.Loaded() {
|
||||
t.Fatal("embedder should be loaded")
|
||||
}
|
||||
v := e.Vectorize("天气怎么样")
|
||||
// 未命中词不应产生空向量(unkVec 兜底)
|
||||
if len(v) == 0 {
|
||||
t.Error("vectorize with topN=1 should still produce a vector (unkVec fallback)")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user