Patch
All checks were successful
release-tag / release-image (push) Successful in 1m36s

This commit is contained in:
2026-08-05 19:17:23 +02:00
parent d415863604
commit 83b831526a

View File

@@ -17,6 +17,7 @@ import (
"time"
"unicode"
"github.com/example/glpi-ai-agent/internal/brainactivity"
"github.com/example/glpi-ai-agent/internal/model"
)
@@ -1073,6 +1074,7 @@ func safeID(v string) bool {
// are scored separately. Missing metadata does not lower a document's score:
// the weights of available components are normalized dynamically.
func (s *Store) Search(ctx context.Context, text string, topK int, categorySets ...[]model.Category) ([]model.KnowledgeHit, error) {
startedAt := time.Now()
if s == nil {
return nil, fmt.Errorf("knowledge store is not initialized")
}
@@ -1191,6 +1193,11 @@ func (s *Store) Search(ctx context.Context, text string, topK int, categorySets
if topK > 0 && len(hits) > topK {
hits = hits[:topK]
}
activityHits := make([]brainactivity.Hit, 0, len(hits))
for _, hit := range hits {
activityHits = append(activityHits, brainactivity.Hit{ID: hit.Doc.ID, Score: hit.Score})
}
brainactivity.EmitSearch("agent", text, activityHits, time.Since(startedAt))
return hits, nil
}