retrieval

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string

ActionType is the decision made by the Agentic reasoner on each iteration.

const (
	ActionRetrieve ActionType = "retrieve"
	ActionReflect  ActionType = "reflect"
	ActionFinish   ActionType = "finish"
)

type AgentAction

type AgentAction struct {
	Type  ActionType // which branch to execute next
	Query string     // refined sub-query for the retrieve action (empty for reflect/finish)
}

AgentAction is the output of the action-selection step.

type AgentActionSelector

type AgentActionSelector interface {
	SelectAction(ctx context.Context, query, reasoning string, iteration, maxIterations int) (*AgentAction, error)
}

AgentActionSelector chooses the next action (retrieve / reflect / finish) based on the reasoning trace and the current iteration count relative to the allowed maximum.

type AgentReasoner

type AgentReasoner interface {
	Reason(ctx context.Context, query string, retrieved [][]*entity.Chunk, answer string) (reasoning string, err error)
}

AgentReasoner analyses the current retrieval state and returns a natural-language reasoning trace that summarises what has been found and what is still missing.

type AgenticMetadata

type AgenticMetadata = entity.AgenticMetadata

AgenticMetadata is an alias for entity.AgenticMetadata. All methods (Validate, MergeToQuery, LoadFromQuery, SetCacheHit, GetCacheHit) are defined on entity.AgenticMetadata. Use entity.AgenticMetadata directly.

func NewAgenticMetadata

func NewAgenticMetadata() *AgenticMetadata

NewAgenticMetadata creates a new AgenticMetadata instance.

type CRAGEvaluation

type CRAGEvaluation struct {
	Relevance float32
	Label     CRAGLabel
	Reason    string
}

CRAGEvaluation holds the result of CRAG quality evaluation.

type CRAGEvaluator

type CRAGEvaluator interface {
	Evaluate(ctx context.Context, query *entity.Query, chunks []*entity.Chunk) (*CRAGEvaluation, error)
}

CRAGEvaluator evaluates the quality of retrieved context.

type CRAGLabel

type CRAGLabel string

CRAGLabel represents the quality assessment label.

const (
	CRAGRelevant   CRAGLabel = "relevant"
	CRAGAmbiguous  CRAGLabel = "ambiguous"
	CRAGIrrelevant CRAGLabel = "irrelevant"
)

type DecompositionResult

type DecompositionResult struct {
	SubQueries []string
	Reasoning  string
	IsComplex  bool
}

DecompositionResult holds the result of query decomposition.

type EntityExtractionResult

type EntityExtractionResult struct {
	Entities []string
}

EntityExtractionResult holds the result of entity extraction.

type EntityExtractor

type EntityExtractor interface {
	Extract(ctx context.Context, query *entity.Query) (*EntityExtractionResult, error)
}

EntityExtractor extracts entities from queries.

type FilterExtractor

type FilterExtractor interface {
	ExtractFilters(ctx context.Context, query *entity.Query) (map[string]any, error)
}

FilterExtractor uses LLM or rules to extract hard metadata constraints from natural language.

type FusionEngine

type FusionEngine interface {
	// ReciprocalRankFusion (RRF) merges results from different modalities
	// (e.g., Sparse + Dense, or Vector + Graph) and re-ranks them based on their reciprocal positions.
	ReciprocalRankFusion(ctx context.Context, resultSets [][]*entity.Chunk, topK int) ([]*entity.Chunk, error)
}

FusionEngine is responsible for merging multiple retrieval streams.

type GenerationResult

type GenerationResult struct {
	Answer string
}

GenerationResult holds the generated answer.

type Generator

type Generator interface {
	Generate(ctx context.Context, query *entity.Query, chunks []*entity.Chunk) (*GenerationResult, error)
}

Generator generates answers based on query and retrieved context.

type GraphGlobalSearcher

type GraphGlobalSearcher interface {
	// Search performs a Map-Reduce over community summaries at a specific hierarchical level.
	Search(ctx context.Context, query string, communityLevel int) (string, error)
}

GraphGlobalSearcher utilizes Community Detection summaries to answer macro-level questions.

type GraphLocalSearcher

type GraphLocalSearcher interface {
	// Search returns a textual description of the N-Hop relationship sub-graph.
	Search(ctx context.Context, entities []string, maxHops int, topK int) (string, error)
}

GraphLocalSearcher performs Entity-Centric N-Hop search in the GraphStore.

type HyDEGenerator

type HyDEGenerator interface {
	GenerateHypotheticalDocument(ctx context.Context, query *entity.Query) (*entity.Document, error)
}

HyDEGenerator generates hypothetical documents to improve dense vector matching.

type IntentClassifier

type IntentClassifier interface {
	Classify(ctx context.Context, query *entity.Query) (*IntentResult, error)
}

IntentClassifier classifies user queries into different intents.

type IntentResult

type IntentResult struct {
	Intent     IntentType
	Confidence float32
	Reason     string
}

IntentResult holds the result of intent classification.

type IntentType

type IntentType string

IntentType represents the classified intent of a query.

const (
	IntentChat           IntentType = "chat"
	IntentDomainSpecific IntentType = "domain_specific"
	IntentFactCheck      IntentType = "fact_check"
)

type QueryDecomposer

type QueryDecomposer interface {
	Decompose(ctx context.Context, query *entity.Query) (*DecompositionResult, error)
}

QueryDecomposer breaks down complex queries into simpler sub-queries.

type QueryRewriter

type QueryRewriter interface {
	Rewrite(ctx context.Context, query *entity.Query) (*entity.Query, error)
}

QueryRewriter optimizes the user's raw query (e.g., coreference resolution).

type RAGEScores

type RAGEScores = entity.RAGEScores

RAGEScores is an alias for entity.RAGEScores. All score fields are defined on entity.RAGEScores as the single source of truth.

type RAGEvaluator

type RAGEvaluator interface {
	Evaluate(ctx context.Context, query, answer, context string) (*RAGEScores, error)
}

RAGEvaluator evaluates the quality of generated answers.

type ResultEnhancer

type ResultEnhancer interface {
	Enhance(ctx context.Context, results *entity.RetrievalResult) (*entity.RetrievalResult, error)
}

ResultEnhancer enhances retrieval results (e.g., reranking, pruning, expansion).

type RetrievalResult

type RetrievalResult struct {
	Chunks []*entity.Chunk
	Scores []float32
}

RetrievalResult holds the result of retrieval.

type Retriever

type Retriever interface {
	Retrieve(ctx context.Context, queries []string, topK int) ([]*RetrievalResult, error)
}

Retriever retrieves relevant chunks based on queries.

type StepBackGenerator

type StepBackGenerator interface {
	GenerateStepBackQuery(ctx context.Context, query *entity.Query) (*entity.Query, error)
}

StepBackGenerator abstracts specific questions into broader background questions.

Jump to

Keyboard shortcuts

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