Documentation
¶
Overview ¶
Package index builds an on-disk, searchable map of expertise from connector records and ranks people and channels for a query without an LLM.
Index ¶
- Constants
- type Changes
- type Embedder
- type Index
- func (ix *Index) Add(records []connector.Record)
- func (ix *Index) Alias(a, b model.ID)
- func (ix *Index) Build(records []connector.Record)
- func (ix *Index) Canonicalize()
- func (ix *Index) Embed(ctx context.Context, e Embedder) error
- func (ix *Index) HasEmbeddings() bool
- func (ix *Index) LoadAliases(path string) error
- func (ix *Index) Profile(id model.ID) (Profile, bool)
- func (ix *Index) Save(path string) (err error)
- func (ix *Index) Search(query string, limit int) []model.Match
- func (ix *Index) SearchChannels(query string, limit int) []model.ChannelMatch
- func (ix *Index) SemanticChannels(query []float32, limit int) []model.ChannelMatch
- func (ix *Index) SemanticPeople(query []float32, limit int) []model.Match
- func (ix *Index) SetFeedback(entries []feedback.Entry)
- func (ix *Index) SetFeedbackStrength(step float64, maxNet int)
- func (ix *Index) SetHalfLife(d time.Duration)
- type Profile
Constants ¶
const DefaultHalfLife = 180 * 24 * time.Hour
DefaultHalfLife is the age at which a dated record's weight halves.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Changes ¶
type Changes struct {
// PeopleJoined are people present now but not before.
PeopleJoined []string `json:"people_joined,omitempty"`
// PeopleLeft are people present before but not now.
PeopleLeft []string `json:"people_left,omitempty"`
// TeamsAdded are teams present now but not before.
TeamsAdded []string `json:"teams_added,omitempty"`
// TeamsRemoved are teams present before but not now.
TeamsRemoved []string `json:"teams_removed,omitempty"`
// ChannelsAdded are channels present now but not before.
ChannelsAdded []string `json:"channels_added,omitempty"`
// ChannelsRemoved are channels present before but not now.
ChannelsRemoved []string `json:"channels_removed,omitempty"`
}
Changes describes which people, teams, and channels entered or left the graph between a previous index and a new one.
type Embedder ¶
type Embedder interface {
// Embed returns the embedding vector for text.
Embed(ctx context.Context, text string) ([]float32, error)
}
Embedder turns text into a vector. The llm package's Ollama client satisfies it.
type Index ¶
type Index struct {
// Graph is the entity graph this index was built from.
Graph *model.Graph
// contains filtered or unexported fields
}
Index is a searchable expertise index over people and channels.
func (*Index) Add ¶ added in v0.1.3
Add merges records into the current index, accumulating onto whatever is already present. Person records merge by email or id, channel records by name. It leaves embeddings unchanged; call Embed to refresh vectors after adding.
func (*Index) Alias ¶ added in v0.1.6
Alias records that two identifiers belong to the same person. Records indexed afterward key by the canonical identifier; call Canonicalize to also join people already in the graph.
func (*Index) Canonicalize ¶ added in v0.1.6
func (ix *Index) Canonicalize()
Canonicalize rewrites the graph so every person appears once under their canonical identifier, merging people the identity resolver maps together and re-pointing channel members and manager links. Run it after loading aliases over an existing index; records added after aliases load already key canonically. A merged person keeps at most one embedding vector, so re-embed afterward when vectors matter.
func (*Index) Embed ¶
Embed fills per-person and per-channel vectors by embedding a text representation of each entity. An error from e aborts and is returned.
func (*Index) HasEmbeddings ¶
HasEmbeddings reports whether the index holds vectors to search semantically.
func (*Index) LoadAliases ¶ added in v0.1.6
LoadAliases merges a JSON alias file into the index's identity resolver so records indexed afterward key by their canonical identifier. Call Canonicalize to also join people already in the graph.
func (*Index) Profile ¶ added in v0.1.15
Profile returns the full profile for id, resolving identity aliases, or false when the person is not in the graph.
func (*Index) Search ¶
Search ranks people for query and returns up to limit matches. A non-positive limit returns all matches.
func (*Index) SearchChannels ¶
func (ix *Index) SearchChannels(query string, limit int) []model.ChannelMatch
SearchChannels ranks channels for query and returns up to limit matches, each carrying the most relevant active members. A non-positive limit returns all.
func (*Index) SemanticChannels ¶
func (ix *Index) SemanticChannels(query []float32, limit int) []model.ChannelMatch
SemanticChannels ranks channels by cosine similarity to the query vector and attaches the members most similar to the query.
func (*Index) SemanticPeople ¶
SemanticPeople ranks people by cosine similarity to the query vector.
func (*Index) SetFeedback ¶ added in v0.1.10
SetFeedback gives the index user votes to apply during ranking. Later calls replace earlier ones. Person votes resolve through identity aliases, so a vote on any of a person's identifiers lands on the canonical entry.
func (*Index) SetFeedbackStrength ¶ added in v0.1.18
SetFeedbackStrength tunes how hard votes move ranking: step is the per-vote score multiplier and maxNet clamps the net votes applied to one result. A step at or below one, or a maxNet at or below zero, turns feedback off.
func (*Index) SetHalfLife ¶ added in v0.1.7
SetHalfLife sets the age at which a dated record's weight halves. Zero or negative disables recency decay.
type Profile ¶ added in v0.1.15
type Profile struct {
// Person is the profiled individual.
Person *model.Person
// Team is the person's team, if known.
Team *model.Team
// Org is the person's organization, if known.
Org *model.Org
// Manager is the person's manager, if known and indexed.
Manager *model.Person
// Channels lists the channels naming the person as an active member.
Channels []*model.Channel
}
Profile is everything the index knows about one person: the person, their org placement, their manager, and the channels they are active in.