蒸馏嵌入接线: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

@ -42,8 +42,11 @@ type Distiller struct {
ctx context.Context
cancel context.CancelFunc
onMemory func(input, response string)
embedder nlp.Vectorizer
}
func (d *Distiller) SetEmbedder(ev nlp.Vectorizer) { d.embedder = ev }
func NewDistiller(db *memory.GraphDB, dataDir string, cfg DistillerConfig) *Distiller {
ctx, cancel := context.WithCancel(context.Background())
return &Distiller{
@ -233,7 +236,7 @@ func (d *Distiller) distillBatch(batch []RawRecord) {
assistantContent += r.Content + " "
}
}
triples := extractKeyTriples(userContent, assistantContent)
triples := extractKeyTriples(userContent, assistantContent, d.embedder)
if len(triples) > 0 {
sessionID := ""
for sid := range sessionIDs {
@ -263,10 +266,13 @@ func (d *Distiller) cleanupRawFiles() {
}
}
func extractKeyTriples(userContent, assistantContent string) []memory.Triple {
func extractKeyTriples(userContent, assistantContent string, embedder nlp.Vectorizer) []memory.Triple {
var triples []memory.Triple
e := nlp.NewExtractor(nil)
if embedder != nil {
e.SetEmbedder(embedder)
}
text := userContent
if assistantContent != "" {
text += assistantContent