Documentation
¶
Index ¶
- type Cache
- type DefaultRouter
- type Engine
- func (e *Engine) AsyncBatchIndex(ctx context.Context, sources []Source) error
- func (e *Engine) AsyncIndex(ctx context.Context, source Source) error
- func (e *Engine) BatchIndex(ctx context.Context, sources []Source) error
- func (e *Engine) BatchQuery(ctx context.Context, questions []string, opts QueryOptions) ([]*Response, error)
- func (e *Engine) Index(ctx context.Context, source Source) error
- func (e *Engine) Query(ctx context.Context, question string, opts QueryOptions) (*Response, error)
- func (e *Engine) QueryStream(ctx context.Context, question string, opts QueryOptions) (<-chan StreamResponse, error)
- type MemoryCache
- type Option
- func WithCache(c Cache) Option
- func WithEmbedder(e embedding.Provider) Option
- func WithLLM(l llm.Client) Option
- func WithLogger(l observability.Logger) Option
- func WithMetrics(m observability.Metrics) Option
- func WithParser(p 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 retrieves a cached response for the given key
Get(ctx context.Context, key string) (*Response, bool)
// Set stores a response in the cache with the given key and expiration
Set(ctx context.Context, key string, value *Response, expiration time.Duration)
// Delete removes a cached response for the given key
Delete(ctx context.Context, key string)
// Clear removes all cached responses
Clear(ctx context.Context)
}
Cache defines the interface for query caching
type DefaultRouter ¶
type DefaultRouter struct{}
DefaultRouter implements a simple default router
func NewDefaultRouter ¶
func NewDefaultRouter() *DefaultRouter
NewDefaultRouter creates a new default router
func (*DefaultRouter) Route ¶
func (r *DefaultRouter) Route(ctx context.Context, query string) (RouteResult, error)
Route determines the appropriate routing for a given query
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine represents the RAG engine
func (*Engine) AsyncBatchIndex ¶
AsyncBatchIndex adds multiple documents to the RAG engine asynchronously
func (*Engine) AsyncIndex ¶
AsyncIndex adds documents to the RAG engine asynchronously
func (*Engine) BatchIndex ¶
BatchIndex adds multiple documents to the RAG engine in batch
func (*Engine) BatchQuery ¶
func (e *Engine) BatchQuery(ctx context.Context, questions []string, opts QueryOptions) ([]*Response, error)
BatchQuery performs multiple RAG queries in batch
func (*Engine) QueryStream ¶
func (e *Engine) QueryStream(ctx context.Context, question string, opts QueryOptions) (<-chan StreamResponse, error)
QueryStream performs a streaming RAG query
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements a simple in-memory cache
func NewMemoryCache ¶
func NewMemoryCache(expiry time.Duration) *MemoryCache
NewMemoryCache creates a new in-memory cache
func (*MemoryCache) Clear ¶
func (c *MemoryCache) Clear(ctx context.Context)
Clear removes all cached responses
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(ctx context.Context, key string)
Delete removes a cached response for the given key
type Option ¶
type Option func(*Engine)
Option configures the Engine
func WithEmbedder ¶
WithEmbedder sets the embedding provider
func WithMetrics ¶
func WithMetrics(m observability.Metrics) Option
WithMetrics sets the metrics collector
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 ¶
QueryOptions configures query behavior
type Response ¶
type Response struct {
Answer string
Sources []vectorstore.Result
}
Response represents the RAG query response
type RouteResult ¶
type RouteResult struct {
// Type indicates the type of route (e.g., "vector", "keyword", "hybrid")
Type string
// Params contains additional parameters for the route
Params map[string]interface{}
}
RouteResult represents the result of routing a query
type Router ¶
type Router interface {
// Route determines the appropriate routing for a given query
Route(ctx context.Context, query string) (RouteResult, error)
}
Router defines the interface for query routing
type StreamResponse ¶
type StreamResponse struct {
Chunk string
Sources []vectorstore.Result
Done bool
Error error
}
StreamResponse represents a streaming RAG query response