config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(ctx interface{}, key string) (*Response, bool)
	Set(ctx interface{}, key string, value *Response, expiration interface{})
}

Cache defines the interface for query result caching

type ContextCompressor

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

ContextCompressor represents context compression for optimizing context window usage

func NewContextCompressor

func NewContextCompressor(llm llm.Client) *ContextCompressor

NewContextCompressor creates a new context compressor

func (*ContextCompressor) Compress

func (c *ContextCompressor) Compress(ctx interface{}, question string, results []core.Result) ([]core.Result, error)

Compress compresses the context

type ConversationManager

type ConversationManager struct {
}

ConversationManager manages multi-turn conversations

func NewConversationManager

func NewConversationManager() *ConversationManager

NewConversationManager creates a new conversation manager

type EngineConfig

type EngineConfig struct {
	Parsers             map[string]parser.Parser   // Map of file extensions to parsers
	DefaultParser       parser.Parser              // Default parser for unknown file types
	Embedder            embedding.Provider         // Embedding model provider
	Store               vectorstore.Store          // Vector storage backend
	LLM                 llm.Client                 // LLM client for generation
	Retriever           *retrieval.HybridRetriever // Hybrid retrieval (vector + keyword)
	Reranker            *retrieval.Reranker        // LLM-based reranker
	Hydration           *HyDE                      // Hypothetical Document Embeddings
	Compressor          *ContextCompressor         // Context compression
	ConversationManager *ConversationManager       // Multi-turn conversation support
	MultiHopRAG         *retrieval.MultiHopRAG     // Multi-hop RAG for complex questions
	AgenticRAG          *retrieval.AgenticRAG      // Agentic RAG with autonomous retrieval
	Cache               Cache                      // Query result cache
	Router              Router                     // Query router
	Metrics             observability.Metrics      // Metrics collector
	Logger              observability.Logger       // Logger
	Tracer              observability.Tracer       // Tracer
}

EngineConfig represents the configuration for the RAG engine

type HyDE

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

HyDE represents Hypothetical Document Embeddings for query enhancement

func NewHyDE

func NewHyDE(llm llm.Client) *HyDE

NewHyDE creates a new HyDE instance

func (*HyDE) EnhanceQuery

func (h *HyDE) EnhanceQuery(ctx interface{}, question string) (string, error)

EnhanceQuery enhances the query using HyDE

type Option

type Option func(*EngineConfig)

Option configures the Engine

func WithAgenticRAG

func WithAgenticRAG(agentic *retrieval.AgenticRAG) Option

WithAgenticRAG sets the agentic RAG component

func WithCache

func WithCache(c Cache) Option

WithCache sets the query cache

func WithContextCompressor

func WithContextCompressor(c *ContextCompressor) Option

WithContextCompressor sets the context compressor for optimizing context

func WithConversationManager

func WithConversationManager(cm *ConversationManager) Option

WithConversationManager sets the conversation manager

func WithEmbedder

func WithEmbedder(e embedding.Provider) Option

WithEmbedder sets the embedding provider

func WithHyDE

func WithHyDE(h *HyDE) Option

WithHyDE sets the HyDE instance for query enhancement

func WithLLM

func WithLLM(l llm.Client) Option

WithLLM sets the LLM client

func WithLogger

func WithLogger(l observability.Logger) Option

WithLogger sets the logger

func WithMetrics

func WithMetrics(m observability.Metrics) Option

WithMetrics sets the metrics collector

func WithMultiHopRAG

func WithMultiHopRAG(multiHop *retrieval.MultiHopRAG) Option

WithMultiHopRAG sets the multi-hop RAG component

func WithParser

func WithParser(p parser.Parser) Option

WithParser sets the default document parser

func WithParsers

func WithParsers(parsers map[string]parser.Parser) Option

WithParsers sets multiple parsers for different formats

func WithReranker

func WithReranker(r *retrieval.Reranker) Option

WithReranker sets the reranker

func WithRetriever

func WithRetriever(r *retrieval.HybridRetriever) Option

WithRetriever sets the hybrid retriever

func WithRouter

func WithRouter(r Router) Option

WithRouter sets the query router

func WithTracer

func WithTracer(t observability.Tracer) Option

WithTracer sets the tracer

func WithVectorStore

func WithVectorStore(s vectorstore.Store) Option

WithVectorStore sets the vector store

type QueryOptions

type QueryOptions struct {
	TopK              int
	PromptTemplate    string
	Stream            bool
	UseMultiHopRAG    bool   // Use multi-hop RAG for complex questions
	UseAgenticRAG     bool   // Use agentic RAG with autonomous retrieval
	MaxHops           int    // Maximum number of hops for multi-hop RAG
	AgentInstructions string // Instructions for agentic RAG
}

QueryOptions configures query behavior

type Response

type Response struct {
	Answer  string
	Sources []core.Result
}

Response represents the RAG query response

type RouteResult

type RouteResult struct {
	Type   string
	Params map[string]interface{}
}

RouteResult represents the result of query routing

type Router

type Router interface {
	Route(ctx interface{}, question string) (RouteResult, error)
}

Router defines the interface for query routing

type Source

type Source struct {
	Type    string      // Document type/format (e.g., "text", ".pdf", ".docx")
	Path    string      // File path (if indexing a file)
	Content string      // Text content (if indexing a string)
	Reader  interface{} // Reader interface (if indexing from a reader)
}

Source represents a document source for indexing

Source defines the input for the indexing process. It can represent: 1. A text string (Content field) 2. A file path (Path field) 3. A reader interface (Reader field)

The Type field specifies the document format (e.g., ".txt", ".pdf", ".docx") and is used to select the appropriate parser.

Example:

// Index a text string
source1 := rag.Source{
    Type:    "text",
    Content: "Go is an open source programming language...",
}

// Index a file
source2 := rag.Source{
    Type: ".pdf",
    Path: "/path/to/document.pdf",
}

type StreamResponse

type StreamResponse struct {
	Chunk   string
	Sources []core.Result
	Done    bool
	Error   error
}

StreamResponse represents a streaming RAG query response

Jump to

Keyboard shortcuts

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