fix(api): recall 默认 namespace 用 classifyNamespace 推导(query 近似 content)+ shared 回退条件改为 (0, top_k)
来源: t_24eceed0 run790 worker 改动,小怡补部署 + 清理误建的根级 go.mod
- core.go: req.Namespace=='' 时由 deriveNamespace 改为 classifyNamespace('general', agentID, query)
→ 无 ns/无 agent_id 时按 content 关键词推导,技术类 query 归 shared,其余归 agent 私有 ns
- shared 回退: len(results)<3 改为 0<len(results)<topK 时补充搜 shared(避免有结果时重复补)
- 删除 worker 误建在仓库根的 go.mod(真实模块定义在 go/go.mod)
验收: go build OK + go test internal/api/routes 3.7s ok + /proc/exe 无 deleted + shared 不变量回归通过
This commit is contained in:
@@ -256,8 +256,8 @@ func (a *API) Recall(w http.ResponseWriter, r *http.Request) {
|
||||
req.Limit = 10
|
||||
}
|
||||
if req.Namespace == "" {
|
||||
// 按 §1.3 推导 namespace
|
||||
req.Namespace = deriveNamespace(req.AgentID)
|
||||
// 按 §1.3 推导 namespace,与 commit 端点保持一致:使用 category 和 content(此处以 Query 近似)
|
||||
req.Namespace = classifyNamespace("general", req.AgentID, req.Query)
|
||||
}
|
||||
|
||||
// H4: Default diversity — balance relevance & diversity
|
||||
@@ -311,8 +311,8 @@ func (a *API) Recall(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// E4.2: 跨 agent 知识共享 — recall 结果 < 3 时,补充搜索 "shared" namespace
|
||||
if len(results) < 3 && req.Namespace != "shared" {
|
||||
// E4.2: 跨 agent 知识共享 — recall 结果在 (0, top_k) 时,补充搜索 "shared" namespace
|
||||
if len(results) > 0 && len(results) < 3 && req.Namespace != "shared" {
|
||||
vec, encErr := a.Embedder.EncodeSingle(req.Query)
|
||||
if encErr == nil {
|
||||
shared, _ := a.LanceDB.Search("memories", vec, 5, "shared")
|
||||
|
||||
Reference in New Issue
Block a user