This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user