internal/passage/passage.go
internal/passage · 113 lines · 15 declarations · source
This file carries the package documentation, rendered on the package page.
Declarations
const DefaultLimit
const DefaultLimit = 10
const MaxLimit
const MaxLimit = 32
const MaxCandidates
const MaxCandidates = 1000
var ErrInvalidQuery
var ErrInvalidQuery = errors.New("invalid passage query")
var ErrProvider
var ErrProvider = errors.New("passage embedding provider failed")
var ErrConfiguration
var ErrConfiguration = errors.New("passage retrieval is not configured")
type Embedder
type Embedder interface {
Embed(context.Context, []string) ([][]float32, error)
}
type Store
type Store interface {
Active(context.Context, string) (pg.EmbeddingGeneration, error)
SearchEvidence(context.Context, string, pg.EmbeddingModel, []float32, pg.MessageSearchOptions) (pg.MessageSearchResult, error)
}
type Binding
type Binding struct{ Name, Revision, EndpointHash string }
Binding carries only configuration identity. Dimensions come from the selected generation and are checked against the actual provider result by the store; equal names alone never join spaces.
type Query
type Query struct {
Question string
Limit, Candidates int
Subject, Role string
}
type Page
type Page struct {
GenerationID string `json:"generation_id"`
ThroughOffset int64 `json:"through_offset"`
CoveredThroughOffset int64 `json:"covered_through_offset"`
BuildState string `json:"build_state"`
Approximate bool `json:"approximate"`
Passages []pg.MessageMatch `json:"passages"`
}
type Retriever
type Retriever struct {
store Store
embedder Embedder
binding Binding
}
func New
func New(store Store, embedder Embedder, binding Binding) (*Retriever, error)
method Query.Validate
func (q Query) Validate() error
method Retriever.Search
func (r *Retriever) Search(ctx context.Context, scope string, query Query) (Page, error)