mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-04 00:03:59 +00:00
fix: doc_query chronological insert, register cli/webui output channels
- context.go: add InsertByTimestamp for chronological context insertion - toolcall.go: doc_query uses InsertByTimestamp instead of Append - agent_tools_test.go: update tests to use payload/type keys - cli/plugin.go: register output_send__cli channel - webui/plugin.go: register output_send__webui channel
This commit is contained in:
@ -139,6 +139,23 @@ func (c *RelevanceContext) Append(evt ContextEvent) {
|
||||
c.save()
|
||||
}
|
||||
|
||||
func (c *RelevanceContext) InsertByTimestamp(evt ContextEvent) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
evt.Vector = c.computeVector(&evt)
|
||||
|
||||
idx := sort.Search(len(c.events), func(i int) bool {
|
||||
return c.events[i].Timestamp.After(evt.Timestamp)
|
||||
})
|
||||
|
||||
c.events = append(c.events, nil)
|
||||
copy(c.events[idx+1:], c.events[idx:])
|
||||
c.events[idx] = &evt
|
||||
|
||||
c.save()
|
||||
}
|
||||
|
||||
func (c *RelevanceContext) save() error {
|
||||
if c.savePath == "" {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user