Documentation
¶
Index ¶
- type Cache
- type ContextCompressor
- type ConversationManager
- type EngineConfig
- type HyDE
- type Option
- func WithAgenticRAG(agentic *retrieval.AgenticRAG) Option
- func WithCache(c Cache) Option
- func WithContextCompressor(c *ContextCompressor) Option
- func WithConversationManager(cm *ConversationManager) Option
- func WithEmbedder(e embedding.Provider) Option
- func WithHyDE(h *HyDE) Option
- func WithLLM(l llm.Client) Option
- func WithLogger(l observability.Logger) Option
- func WithMetrics(m observability.Metrics) Option
- func WithMultiHopRAG(multiHop *retrieval.MultiHopRAG) Option
- func WithParser(p parser.Parser) Option
- func WithParsers(parsers map[string]parser.Parser) Option
- func WithReranker(r *retrieval.Reranker) Option
- func WithRetriever(r *retrieval.HybridRetriever) Option
- func WithRouter(r Router) Option
- func WithTracer(t observability.Tracer) Option
- func WithVectorStore(s vectorstore.Store) Option
- type QueryOptions
- type Response
- type RouteResult
- type Router
- type Source
- type StreamResponse
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
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
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 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 ¶
WithEmbedder sets the embedding provider
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 ¶
WithParser sets the default document parser
func WithParsers ¶
WithParsers sets multiple parsers for different formats
func WithRetriever ¶
func WithRetriever(r *retrieval.HybridRetriever) Option
WithRetriever sets the hybrid retriever
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 RouteResult ¶
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",
}