internal/reportcandidate/reportcandidate.go
internal/reportcandidate · 108 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 report candidate query")
var ErrProvider
var ErrProvider = errors.New("report candidate embedding provider failed")
var ErrConfiguration
var ErrConfiguration = errors.New("report candidate 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.ReportEmbeddingGeneration, error)
FindCandidates(context.Context, string, pg.EmbeddingModel, []float32, pg.ReportCandidateOptions) (pg.ReportCandidateResult, error)
}
type Binding
type Binding struct{ Name, Revision, EndpointHash string }
type Query
type Query struct {
Question string
Limit, Candidates int
}
type Page
type Page struct {
GenerationID string `json:"generation_id"`
TargetCount int64 `json:"target_count"`
BuildState string `json:"build_state"`
Approximate bool `json:"approximate"`
Candidates []pg.ReportCandidate `json:"candidates"`
}
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)