蒸馏嵌入接线:Distiller/Agent 注入共享 embedder,修复配置缺失时蒸馏零产出

This commit is contained in:
JianFeeeee
2026-08-05 09:59:33 +08:00
parent adaf37909d
commit 954c9dafcb
7 changed files with 42 additions and 14 deletions

View File

@ -178,7 +178,7 @@ func (a *Agent) archiveColdDocs() {
if a.docStore != nil {
coldDocs := a.docStore.FindColdDocs(72*time.Hour, 2)
for _, doc := range coldDocs {
triples := docToTriples(doc)
triples := docToTriples(doc, a.embedder)
if len(triples) > 0 {
ec, rc, err := a.memory.Commit(triples, string(a.id)+"_doc_archival", 0)
if err != nil {
@ -387,7 +387,7 @@ func entitySimilarity(a, b string) float64 {
return float64(intersect) / float64(union)
}
func docToTriples(doc *document.Doc) []memory.Triple {
func docToTriples(doc *document.Doc, embedder nlp.Vectorizer) []memory.Triple {
var triples []memory.Triple
if doc == nil {
return triples
@ -409,6 +409,9 @@ func docToTriples(doc *document.Doc) []memory.Triple {
// NLP 通用提取
e := nlp.NewExtractor(nil)
if embedder != nil {
e.SetEmbedder(embedder)
}
result := e.Extract(doc.Content)
if result != nil {
for _, nt := range result.Triples {