Skip to main content

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

source

const MaxLimit

const MaxLimit = 32

source

const MaxCandidates

const MaxCandidates = 1000

source

var ErrInvalidQuery

var ErrInvalidQuery = errors.New("invalid passage query")

source

var ErrProvider

var ErrProvider = errors.New("passage embedding provider failed")

source

var ErrConfiguration

var ErrConfiguration = errors.New("passage retrieval is not configured")

source

type Embedder

type Embedder interface {
Embed(context.Context, []string) ([][]float32, error)
}

source

type Store

type Store interface {
Active(context.Context, string) (pg.EmbeddingGeneration, error)
SearchEvidence(context.Context, string, pg.EmbeddingModel, []float32, pg.MessageSearchOptions) (pg.MessageSearchResult, error)
}

source

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.

source

type Query

type Query struct {
Question string
Limit, Candidates int
Subject, Role string
}

source

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"`
}

source

type Retriever

type Retriever struct {
store Store
embedder Embedder
binding Binding
}

source

func New

func New(store Store, embedder Embedder, binding Binding) (*Retriever, error)

source

method Query.Validate

func (q Query) Validate() error

source

method Retriever.Search

func (r *Retriever) Search(ctx context.Context, scope string, query Query) (Page, error)

source