Documentation
¶
Index ¶
- func GenerateCacheKey(question string, opts QueryOptions) string
- type Cache
- type CacheStats
- type ContextCompressor
- type Embedder
- type HyDE
- type Logger
- type MemoryCache
- func (c *MemoryCache) Clear(ctx context.Context)
- func (c *MemoryCache) Delete(ctx context.Context, key string)
- func (c *MemoryCache) Get(ctx context.Context, key string) (*Response, bool)
- func (c *MemoryCache) Set(ctx context.Context, key string, value *Response, ttl time.Duration)
- func (c *MemoryCache) Size() int
- func (c *MemoryCache) Stats() CacheStats
- type Metrics
- type QueryHandler
- func (q *QueryHandler) BatchQuery(ctx context.Context, questions []string, opts QueryOptions) ([]*Response, error)
- func (q *QueryHandler) Query(ctx context.Context, question string, opts QueryOptions) (*Response, error)
- func (q *QueryHandler) QueryStream(ctx context.Context, question string, opts QueryOptions) (<-chan StreamResponse, error)
- type QueryOptions
- type Response
- type RouteResult
- type Router
- type StreamResponse
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCacheKey ¶ added in v1.0.1
func GenerateCacheKey(question string, opts QueryOptions) string
GenerateCacheKey generates a cache key from a question and options
Types ¶
type Cache ¶
type Cache interface {
Get(ctx context.Context, key string) (*Response, bool)
Set(ctx context.Context, key string, value *Response, expiration time.Duration)
}
Cache defines the interface for query result caching
type CacheStats ¶ added in v1.0.1
CacheStats represents cache statistics
type ContextCompressor ¶
type ContextCompressor interface {
Compress(ctx context.Context, question string, results []core.Result) ([]core.Result, error)
}
ContextCompressor defines the interface for context compression
type Logger ¶
type Logger interface {
Info(ctx context.Context, message string, fields map[string]interface{})
Debug(ctx context.Context, message string, fields map[string]interface{})
Error(ctx context.Context, message string, err error, fields map[string]interface{})
Warn(ctx context.Context, message string, fields map[string]interface{})
}
Logger defines the interface for logging
type MemoryCache ¶ added in v1.0.1
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements the Cache interface for query results
func NewMemoryCache ¶ added in v1.0.1
func NewMemoryCache(defaultTTL time.Duration) *MemoryCache
NewMemoryCache creates a new in-memory cache
func NewMemoryCacheWithSize ¶ added in v1.0.1
func NewMemoryCacheWithSize(defaultTTL time.Duration, maxSize int) *MemoryCache
NewMemoryCacheWithSize creates a new in-memory cache with size limit
func (*MemoryCache) Clear ¶ added in v1.0.1
func (c *MemoryCache) Clear(ctx context.Context)
Clear clears all entries from the cache
func (*MemoryCache) Delete ¶ added in v1.0.1
func (c *MemoryCache) Delete(ctx context.Context, key string)
Delete removes a value from the cache
func (*MemoryCache) Get ¶ added in v1.0.1
Get retrieves a value from the cache Implements the Cache interface
func (*MemoryCache) Size ¶ added in v1.0.1
func (c *MemoryCache) Size() int
Size returns the number of entries in the cache
func (*MemoryCache) Stats ¶ added in v1.0.1
func (c *MemoryCache) Stats() CacheStats
Stats returns cache statistics
type Metrics ¶
type Metrics interface {
RecordErrorCount(ctx context.Context, errorType string)
RecordQueryLatency(ctx context.Context, duration time.Duration)
RecordQueryCount(ctx context.Context, status string)
RecordIndexedDocuments(ctx context.Context, count int)
RecordIndexingDocuments(ctx context.Context, count int)
RecordMonitoredDocuments(ctx context.Context, count int)
RecordSystemMetrics(ctx context.Context, cpuUsage float64, memoryUsage float64)
}
Metrics defines the interface for metrics collection
type QueryHandler ¶
type QueryHandler struct {
// contains filtered or unexported fields
}
QueryHandler handles RAG query operations
func NewQueryHandler ¶
func NewQueryHandler( embedder Embedder, store vectorstore.Store, llm llm.Client, retriever *retrieval.HybridRetriever, reranker *retrieval.Reranker, hydration HyDE, compressor ContextCompressor, multiHopRAG *retrieval.MultiHopRAG, agenticRAG *retrieval.AgenticRAG, cache Cache, router Router, metrics Metrics, logger Logger, tracer Tracer, ) *QueryHandler
NewQueryHandler creates a new query handler
func (*QueryHandler) BatchQuery ¶
func (q *QueryHandler) BatchQuery(ctx context.Context, questions []string, opts QueryOptions) ([]*Response, error)
BatchQuery performs multiple RAG queries in batch
func (*QueryHandler) Query ¶
func (q *QueryHandler) Query(ctx context.Context, question string, opts QueryOptions) (*Response, error)
Query performs a RAG query
func (*QueryHandler) QueryStream ¶
func (q *QueryHandler) QueryStream(ctx context.Context, question string, opts QueryOptions) (<-chan StreamResponse, error)
QueryStream performs a streaming RAG query
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
RerankMultiplier int // Multiplier for topK when fetching candidates for reranking (default: 2)
}
QueryOptions configures query behavior
type RouteResult ¶
RouteResult represents the result of query routing
type Router ¶
type Router interface {
Route(ctx context.Context, question string) (RouteResult, error)
}
Router defines the interface for query routing
type StreamResponse ¶
StreamResponse represents a streaming RAG query response