retrieve

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package retrieve fusiona varios canales de búsqueda (BM25 sobre mensajes, BM25 sobre nodos del índice y —opcional— vectores) en un único ranking mediante Reciprocal Rank Fusion (RRF) + un boost de recencia. El agente es el reranker final: rerankea leyendo los hits; acá solo se ordenan candidatos baratos.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Name  string
	Items []Item
}

Channel es una lista de items ya ordenada por relevancia (mejor primero).

func VectorChannel

func VectorChannel(store db.Store, query string, top int, allowed []string) (*Channel, error)

VectorChannel arma el canal de embeddings (capa opcional). Devuelve nil si los embeddings están apagados o el backend no responde (la búsqueda sigue con BM25 + estructura). Hace cosine de la query contra los vectores de los nodos y devuelve los top como Items de nodo. allowed (scope) vacío = sin filtro.

type Item

type Item struct {
	Kind      string // "message" | "node"
	ID        string // id del mensaje o del nodo
	ChatID    string
	Title     string // título del chat/nodo (path corto)
	Source    string // codex | claude
	Role      string // rol (hits de mensaje)
	NodeKind  string // project|chat|commit (hits de nodo)
	Content   string // snippet o summary
	Timestamp int64
}

Item es un candidato de cualquier canal, normalizado para fusionar y mostrar.

type Option

type Option func(*config)

Option configura la fusión.

func WithRRFK

func WithRRFK(k float64) Option

WithRRFK fija la constante k de RRF (default 60).

func WithRecencyWeight

func WithRecencyWeight(w float64) Option

WithRecencyWeight fija el peso del boost de recencia (default 0.02).

type Scored

type Scored struct {
	Item
	Score float64
}

Scored es un item con su score fusionado.

func Fuse

func Fuse(channels []Channel, limit int, options ...Option) []Scored

Fuse combina los canales por RRF + recencia y devuelve los top `limit`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL