- 4 大修复: 缺口分类向量化 + Schema 23字段 + Consolidation走Rust IPC + Client SDK - BGE ONNX: deploy/bge_embed_server.py + systemd unit,1024维本地推理 - Rust sidecar: 8模块完整,DBSCAN/衰减/修剪/质量回溯/整合报告 - Go: zhiyid 7821端口,37个API端点,多Agent架构
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
// 织忆 MemoryWeave — 图谱扩展器(供 Recall 管线调用)
|
|
package governance
|
|
|
|
import (
|
|
"github.com/xiaoxue/memoryweave/internal/models"
|
|
)
|
|
|
|
// ExpandFromResults 从 recall 结果出发,双向 BFS 扩展图谱邻接节点
|
|
// 实现 GraphStore 接口
|
|
func (g *InMemoryGraph) ExpandFromResults(results []models.RecallResult, namespace string, maxHops int) []models.RecallResult {
|
|
var expanded []models.RecallResult
|
|
seen := make(map[string]bool)
|
|
|
|
// 收集已有结果 ID
|
|
for _, r := range results {
|
|
seen[r.ID] = true
|
|
}
|
|
|
|
// 从每个结果出发扩展
|
|
for _, r := range results {
|
|
paths, err := g.Navigate(r.Category, maxHops, namespace)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
for _, p := range paths {
|
|
target, _ := p["target"].(string)
|
|
source, _ := p["source"].(string)
|
|
|
|
for _, id := range []string{target, source} {
|
|
if id != "" && !seen[id] {
|
|
seen[id] = true
|
|
expanded = append(expanded, models.RecallResult{
|
|
ID: id,
|
|
Category: "graph_expanded",
|
|
Score: 0.5, // 图谱扩展降权
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return expanded
|
|
}
|