Files
HomeAgent/internal/memory/clean_text.go
root 3fc2151588 refactor: pluginize text cleaning and tool NoMemory control
- SDK: ToolDef.NoMemory field, PluginSDK.RegisterTextCleaner/TextCleaners
- Registry: aggregate text cleaners from plugins, expose CleanText()
- Memory: replace hardcoded QQ regex CleanTemplateText with dynamic CleanText/SetTextCleaner
- StageHost: add ToolDef(name) lookup
- eventloop: check ToolDef.NoMemory before emitMemoryCandidate
- context/Prune: replace hardcoded agentcli/terminal source filter with ToolsUsed NoMemory check
- agentcli/cmd: mark tools with NoMemory: true
- main.go: wire memory.SetTextCleaner(pluginReg.CleanText)
2026-07-24 14:49:08 +08:00

35 lines
622 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package memory
import (
"strings"
"gitcode.com/JianFeeeee/HomeAgent/internal/memory/vector"
)
var globalTextCleaner func(string) string
func SetTextCleaner(fn func(string) string) {
globalTextCleaner = fn
}
func CleanText(text string) string {
if globalTextCleaner != nil {
text = globalTextCleaner(text)
}
text = strings.TrimSpace(text)
if text == "" {
return ""
}
text = strings.TrimPrefix(text, "")
text = strings.TrimPrefix(text, "")
text = strings.TrimSpace(text)
return text
}
func (e *StaticEmbedder) VectorizeClean(text string) vector.Vector {
return e.Vectorize(CleanText(text))
}