Documentation
¶
Overview ¶
Package retrieval provides retrieval strategy steps that execute different search algorithms. These steps implement various retrieval methods including vector, sparse, graph, and hybrid search.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CRAGEvaluatorStep ¶
type CRAGEvaluatorStep struct {
// contains filtered or unexported fields
}
CRAGEvaluatorStep evaluates the quality of retrieved context using CRAG.
func NewCRAGEvaluatorStep ¶
func NewCRAGEvaluatorStep(evaluator retrieval.CRAGEvaluator) *CRAGEvaluatorStep
NewCRAGEvaluatorStep creates a new CRAG evaluator step.
func (*CRAGEvaluatorStep) Execute ¶
func (s *CRAGEvaluatorStep) Execute(ctx context.Context, state *entity.PipelineState) error
Execute runs the CRAG evaluation on retrieved chunks.
func (*CRAGEvaluatorStep) Name ¶
func (s *CRAGEvaluatorStep) Name() string
Name returns the name of this step.
type GraphGlobalSearchStep ¶
type GraphGlobalSearchStep struct {
// contains filtered or unexported fields
}
GraphGlobalSearchStep is a pipeline step that performs global graph search by synthesizing community summaries for macro-level questions.
func NewGraphGlobalSearchStep ¶
func NewGraphGlobalSearchStep(searcher *graph.GlobalSearcher, communityLevel int) *GraphGlobalSearchStep
NewGraphGlobalSearchStep creates a new graph global search step.
Parameters: - searcher: The global searcher instance - communityLevel: The level of community summaries to use (default: 1)
Returns: - A new GraphGlobalSearchStep instance
func (*GraphGlobalSearchStep) Execute ¶
func (s *GraphGlobalSearchStep) Execute(ctx context.Context, state *entity.PipelineState) error
Execute performs global graph search by synthesizing community summaries. It's suitable for answering broad, macro-level questions about the domain.
func (*GraphGlobalSearchStep) Name ¶
func (s *GraphGlobalSearchStep) Name() string
Name returns the step name
type GraphLocalSearchStep ¶
type GraphLocalSearchStep struct {
// contains filtered or unexported fields
}
GraphLocalSearchStep is a pipeline step that performs local graph search by traversing N-Hop relationships from specific entities.
func NewGraphLocalSearchStep ¶
func NewGraphLocalSearchStep(searcher *graph.LocalSearcher, maxHops, topK int) *GraphLocalSearchStep
NewGraphLocalSearchStep creates a new graph local search step.
Parameters: - searcher: The local searcher instance - maxHops: Maximum number of hops to traverse (default: 2) - topK: Maximum number of results to return (default: 10)
Returns: - A new GraphLocalSearchStep instance
func (*GraphLocalSearchStep) Execute ¶
func (s *GraphLocalSearchStep) Execute(ctx context.Context, state *entity.PipelineState) error
Execute performs local graph search using entities from the query or previous extraction. It requires entity IDs to be present in query metadata.
func (*GraphLocalSearchStep) Name ¶
func (s *GraphLocalSearchStep) Name() string
Name returns the step name
type ImageSearchStep ¶
type ImageSearchStep struct {
// contains filtered or unexported fields
}
ImageSearchStep performs a vector search using the image embedding produced by MultimodalEmbeddingStep. It reads state.Agentic.Custom["image_vector"] and queries the VectorStore with that vector.
The step is a no-op when the image vector is absent, making image retrieval a fully optional third branch in the multimodal pipeline.
func NewImageSearchStep ¶
func NewImageSearchStep(store abstraction.VectorStore, topK int, logger logging.Logger) *ImageSearchStep
NewImageSearchStep creates a new image-based vector search step.
func (*ImageSearchStep) Execute ¶
func (s *ImageSearchStep) Execute(ctx context.Context, state *entity.PipelineState) error
Execute retrieves chunks using the image query vector. It is a no-op when state.Agentic.Custom["image_vector"] is not set.
func (*ImageSearchStep) Name ¶
func (s *ImageSearchStep) Name() string
type RAGFusionStep ¶
type RAGFusionStep struct {
// contains filtered or unexported fields
}
RAGFusionStep merges multiple chunk lists from state (e.g., from parallel searches) using the Reciprocal Rank Fusion algorithm.
func NewRAGFusionStep ¶
func NewRAGFusionStep(engine retrieval.FusionEngine, topK int) *RAGFusionStep
NewRAGFusionStep creates a fusion step.
func (*RAGFusionStep) Execute ¶
func (s *RAGFusionStep) Execute(ctx context.Context, state *entity.PipelineState) error
func (*RAGFusionStep) Name ¶
func (s *RAGFusionStep) Name() string
type SearchResult ¶
SearchResult represents a search result.
type SparseSearchStep ¶
type SparseSearchStep struct {
// contains filtered or unexported fields
}
SparseSearchStep is a pipeline step that performs sparse retrieval (e.g., BM25). It's effective for keyword-based search and works well with dense retrieval.
func NewSparseSearchStep ¶
func NewSparseSearchStep(searcher SparseSearcher, topK int, logger logging.Logger) *SparseSearchStep
NewSparseSearchStep creates a new sparse search step.
Parameters: - searcher: The sparse searcher to use for retrieval - topK: Number of top results to return (default: 10) - logger: optional structured logger; pass nil to use noop
Returns: - A new SparseSearchStep instance
func (*SparseSearchStep) Execute ¶
func (s *SparseSearchStep) Execute(ctx context.Context, state *entity.PipelineState) error
Execute performs sparse retrieval using the query text. Results are stored in state.RetrievedChunks.
type SparseSearcher ¶
type SparseSearcher interface {
Search(ctx context.Context, query string, topK int) ([]*SearchResult, error)
}
SparseSearcher defines the interface for sparse search operations.
type VectorSearchStep ¶
type VectorSearchStep struct {
// contains filtered or unexported fields
}
VectorSearchStep retrieves relevant chunks from a VectorStore based on the Query.
func NewVectorSearchStep ¶
func NewVectorSearchStep(embedder embedding.Provider, store abstraction.VectorStore, topK int) *VectorSearchStep
NewVectorSearchStep creates a new vector search step.
func (*VectorSearchStep) Execute ¶
func (s *VectorSearchStep) Execute(ctx context.Context, state *entity.PipelineState) error
func (*VectorSearchStep) Name ¶
func (s *VectorSearchStep) Name() string