retrieval

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDefaultStrategies

func RegisterDefaultStrategies(reg *StrategyRegistry, nodes StrategyNodes) error

RegisterDefaultStrategies mounts available strategy nodes into registry.

Types

type Composer

type Composer interface {
	Compose(ctx context.Context, query string, results []rag.RetrievalResult) (string, error)
}

Composer builds context text from final candidates.

type GraphRetriever

type GraphRetriever interface {
	Retrieve(ctx context.Context, query string) ([]rag.GraphRetrievalResult, error)
}

GraphRetriever is the minimal contract required by graph strategy node.

type MultiHopReasoner

type MultiHopReasoner interface {
	Reason(ctx context.Context, query string) (*rag.ReasoningChain, error)
}

MultiHopReasoner is the minimal contract required by multi-hop strategy node.

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

Pipeline implements unified execution path: query transform -> retrieve -> rerank(optional) -> compose context.

func NewPipeline

func NewPipeline(
	config PipelineConfig,
	transformer QueryTransformer,
	retriever Retriever,
	reranker Reranker,
	composer Composer,
) *Pipeline

NewPipeline creates a pipeline with required retriever and optional stages.

func (*Pipeline) Execute

func (p *Pipeline) Execute(ctx context.Context, in PipelineInput) (*PipelineOutput, error)

Execute runs the unified retrieval pipeline.

type PipelineConfig

type PipelineConfig struct {
	RetrieveTopK int
	RerankTopK   int
}

PipelineConfig controls candidate limits for retrieval and rerank phases.

func DefaultPipelineConfig

func DefaultPipelineConfig() PipelineConfig

DefaultPipelineConfig returns conservative defaults for production flow.

type PipelineInput

type PipelineInput struct {
	Query          string
	QueryEmbedding []float64
}

PipelineInput is the request payload for retrieval pipeline execution.

type PipelineOutput

type PipelineOutput struct {
	TransformedQuery string
	Results          []rag.RetrievalResult
	Context          string
}

PipelineOutput is the normalized output of the retrieval pipeline.

type QueryTransformer

type QueryTransformer interface {
	Transform(ctx context.Context, query string) (string, error)
}

QueryTransformer transforms the incoming query before retrieval.

type Reranker

type Reranker interface {
	Rerank(ctx context.Context, query string, results []rag.RetrievalResult) ([]rag.RetrievalResult, error)
}

Reranker re-orders retrieval candidates.

type Retriever

type Retriever interface {
	Retrieve(ctx context.Context, query string, queryEmbedding []float64) ([]rag.RetrievalResult, error)
}

Retriever fetches candidates for the transformed query.

func NewStrategyNode

func NewStrategyNode(kind StrategyKind, nodes StrategyNodes) (Retriever, error)

NewStrategyNode builds a retriever strategy node for unified pipeline.

type StrategyFactory

type StrategyFactory func() (Retriever, error)

StrategyFactory builds a retriever for a concrete strategy kind.

type StrategyKind

type StrategyKind string

StrategyKind identifies retrieval strategy nodes mounted into unified pipeline.

const (
	StrategyHybrid     StrategyKind = "hybrid"
	StrategyBM25       StrategyKind = "bm25"
	StrategyVector     StrategyKind = "vector"
	StrategyGraph      StrategyKind = "graph"
	StrategyContextual StrategyKind = "contextual"
	StrategyMultiHop   StrategyKind = "multi_hop"
)

type StrategyNodes

type StrategyNodes struct {
	Hybrid     *rag.HybridRetriever
	BM25       *rag.HybridRetriever
	Vector     *rag.HybridRetriever
	Graph      GraphRetriever
	Contextual *rag.ContextualRetrieval
	MultiHop   MultiHopReasoner
}

StrategyNodes groups available strategy implementations.

type StrategyRegistry

type StrategyRegistry struct {
	// contains filtered or unexported fields
}

StrategyRegistry centralizes retrieval strategy construction.

func NewStrategyRegistry

func NewStrategyRegistry() *StrategyRegistry

NewStrategyRegistry creates an empty retrieval strategy registry.

func (*StrategyRegistry) Build

func (r *StrategyRegistry) Build(kind StrategyKind) (Retriever, error)

Build constructs a retriever by strategy kind.

func (*StrategyRegistry) List

func (r *StrategyRegistry) List() []StrategyKind

List returns all registered strategy kinds.

func (*StrategyRegistry) Register

func (r *StrategyRegistry) Register(kind StrategyKind, factory StrategyFactory) error

Register adds a strategy factory. Duplicate registration is rejected.

Jump to

Keyboard shortcuts

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