Documentation
¶
Index ¶
- type Cache
- type ComponentHealth
- type ContextCompressor
- func (c *ContextCompressor) Compress(ctx context.Context, query string, results []core.Result) ([]core.Result, error)
- func (c *ContextCompressor) WithMaxContextSize(size int) *ContextCompressor
- func (c *ContextCompressor) WithMinRelevanceScore(score float32) *ContextCompressor
- func (c *ContextCompressor) WithSimilarityThreshold(threshold float32) *ContextCompressor
- func (c *ContextCompressor) WithSummaryPrompt(prompt string) *ContextCompressor
- type Conversation
- type ConversationManager
- func (cm *ConversationManager) CreateConversation() *Conversation
- func (cm *ConversationManager) DeleteConversation(id string)
- func (cm *ConversationManager) GetConversation(id string) *Conversation
- func (cm *ConversationManager) ListConversations() []*Conversation
- func (cm *ConversationManager) UpdateConversation(conv *Conversation)
- type ConversationOptions
- type DefaultRouter
- type Engine
- func (e *Engine) AddParser(format string, p parser.Parser)
- func (e *Engine) AsyncBatchIndex(ctx context.Context, sources []Source) error
- func (e *Engine) AsyncIndex(ctx context.Context, source Source) error
- func (e *Engine) AsyncIndexDirectory(ctx context.Context, directoryPath string) 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) Debug(ctx context.Context, message string, fields map[string]interface{})
- func (e *Engine) Error(ctx context.Context, message string, err error, fields map[string]interface{})
- func (e *Engine) Extract(ctx context.Context) (observability.Span, bool)
- func (e *Engine) Get(ctx context.Context, key string) (*query.Response, bool)
- func (e *Engine) Index(ctx context.Context, source Source) error
- func (e *Engine) IndexDirectory(ctx context.Context, directoryPath string) error
- func (e *Engine) Info(ctx context.Context, message string, fields map[string]interface{})
- 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)
- func (e *Engine) QueryWithConversation(ctx context.Context, question string, opts ConversationOptions) (*Response, error)
- func (e *Engine) RecordErrorCount(ctx context.Context, errorType string)
- func (e *Engine) RecordIndexCount(ctx context.Context, status string)
- func (e *Engine) RecordIndexLatency(ctx context.Context, duration time.Duration)
- func (e *Engine) RecordIndexedDocuments(ctx context.Context, count int)
- func (e *Engine) RecordIndexingDocuments(ctx context.Context, count int)
- func (e *Engine) RecordMonitoredDocuments(ctx context.Context, count int)
- func (e *Engine) RecordQueryCount(ctx context.Context, status string)
- func (e *Engine) RecordQueryLatency(ctx context.Context, duration time.Duration)
- func (e *Engine) RecordSystemMetrics(ctx context.Context, cpuUsage float64, memoryUsage float64)
- func (e *Engine) ReindexFile(ctx context.Context, filePath string, sourceType string) error
- func (e *Engine) Set(ctx context.Context, key string, value *query.Response, ...)
- func (e *Engine) SetDefaultParser(p parser.Parser)
- func (e *Engine) StartSpan(ctx context.Context, name string) (context.Context, observability.Span)
- func (e *Engine) StartWatch(targetIndexDir string) error
- func (e *Engine) StartWatchAsync(targetIndexDir string) (context.CancelFunc, error)
- func (e *Engine) StartWatchWithContext(ctx context.Context, targetIndexDir string) error
- func (e *Engine) Warn(ctx context.Context, message string, fields map[string]interface{})
- type HealthChecker
- type HealthReport
- type HealthStatus
- type HyDE
- type MemoryCache
- func (c *MemoryCache) Clear(ctx context.Context)
- func (c *MemoryCache) Close() error
- 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, expiration time.Duration)
- type Message
- type Option
- func WithAgenticRAG(agentic *retrieval.AgenticRAG) Option
- func WithBatchProcessor(batchSize, maxWorkers int, rateLimit time.Duration) Option
- func WithCache(c Cache) Option
- func WithCircuitBreaker(maxFailures int, timeout time.Duration, halfOpenMax int) Option
- func WithConnectionPool(maxConns, idleConns int, idleTimeout time.Duration) 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 WithPluginConfig(config map[string]interface{}) Option
- func WithPluginDirectory(directory string) Option
- func WithQueryCache(ttl time.Duration, maxSize int) 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 PluginOptions
- type Progress
- func (p *Progress) AddFailedFile(file string)
- func (p *Progress) Cancel()
- func (p *Progress) Complete()
- func (p *Progress) Duration() time.Duration
- func (p *Progress) Fail(err error)
- func (p *Progress) IncrementProcessed()
- func (p *Progress) IsComplete() bool
- func (p *Progress) Percentage() float64
- func (p *Progress) SetCurrentFile(file string)
- func (p *Progress) Snapshot() ProgressSnapshot
- func (p *Progress) Start()
- type ProgressChannel
- type ProgressSnapshot
- type ProgressStatus
- type ProgressTracker
- 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)
// Close stops the cache and releases resources
Close() error
}
Cache defines the interface for query caching
type ComponentHealth ¶ added in v0.6.0
type ComponentHealth struct {
Name string `json:"name"`
Status HealthStatus `json:"status"`
Latency time.Duration `json:"latency"`
Error string `json:"error,omitempty"`
Details map[string]string `json:"details,omitempty"`
}
ComponentHealth represents the health of a single component
type ContextCompressor ¶ added in v0.6.0
type ContextCompressor struct {
// contains filtered or unexported fields
}
ContextCompressor compresses and optimizes context for LLM input
func NewContextCompressor ¶ added in v0.6.0
func NewContextCompressor(llm llm.Client) *ContextCompressor
NewContextCompressor creates a new context compressor
func (*ContextCompressor) Compress ¶ added in v0.6.0
func (c *ContextCompressor) Compress(ctx context.Context, query string, results []core.Result) ([]core.Result, error)
Compress compresses and optimizes context
func (*ContextCompressor) WithMaxContextSize ¶ added in v0.6.0
func (c *ContextCompressor) WithMaxContextSize(size int) *ContextCompressor
WithMaxContextSize sets the maximum context size
func (*ContextCompressor) WithMinRelevanceScore ¶ added in v1.0.2
func (c *ContextCompressor) WithMinRelevanceScore(score float32) *ContextCompressor
WithMinRelevanceScore sets the minimum relevance score for filtering
func (*ContextCompressor) WithSimilarityThreshold ¶ added in v0.6.0
func (c *ContextCompressor) WithSimilarityThreshold(threshold float32) *ContextCompressor
WithSimilarityThreshold sets the similarity threshold for redundancy removal
func (*ContextCompressor) WithSummaryPrompt ¶ added in v0.6.0
func (c *ContextCompressor) WithSummaryPrompt(prompt string) *ContextCompressor
WithSummaryPrompt sets a custom summary prompt
type Conversation ¶ added in v0.6.0
type Conversation struct {
ID string
Messages []Message
CreatedAt time.Time
UpdatedAt time.Time
// contains filtered or unexported fields
}
Conversation represents a multi-turn conversation
func NewConversation ¶ added in v0.6.0
func NewConversation() *Conversation
NewConversation creates a new conversation
func (*Conversation) AddMessage ¶ added in v0.6.0
func (c *Conversation) AddMessage(role, content string)
AddMessage adds a message to the conversation
func (*Conversation) GetContext ¶ added in v0.6.0
func (c *Conversation) GetContext(maxMessages int) string
GetContext returns the conversation context as a string
func (*Conversation) GetRecentMessages ¶ added in v0.6.0
func (c *Conversation) GetRecentMessages(max int) []Message
GetRecentMessages gets the most recent messages
type ConversationManager ¶ added in v0.6.0
type ConversationManager struct {
// contains filtered or unexported fields
}
ConversationManager manages multiple conversations
func NewConversationManager ¶ added in v0.6.0
func NewConversationManager() *ConversationManager
NewConversationManager creates a new conversation manager
func (*ConversationManager) CreateConversation ¶ added in v0.6.0
func (cm *ConversationManager) CreateConversation() *Conversation
CreateConversation creates a new conversation
func (*ConversationManager) DeleteConversation ¶ added in v0.6.0
func (cm *ConversationManager) DeleteConversation(id string)
DeleteConversation deletes a conversation
func (*ConversationManager) GetConversation ¶ added in v0.6.0
func (cm *ConversationManager) GetConversation(id string) *Conversation
GetConversation gets a conversation by ID
func (*ConversationManager) ListConversations ¶ added in v0.6.0
func (cm *ConversationManager) ListConversations() []*Conversation
ListConversations lists all conversations
func (*ConversationManager) UpdateConversation ¶ added in v0.6.0
func (cm *ConversationManager) UpdateConversation(conv *Conversation)
UpdateConversation updates a conversation
type ConversationOptions ¶ added in v0.6.0
ConversationOptions configures conversation behavior
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 (Retrieval-Augmented Generation) engine
Engine is the central component of the GoRAG framework that orchestrates the entire RAG process: document parsing, embedding generation, vector storage, retrieval, and LLM interaction.
Key features: - Concurrent directory indexing with 10 workers - Automatic parser selection by file extension - Streaming large file support (100M+) - Hybrid retrieval (vector + keyword search) - LLM-based reranking - Custom prompt templates - Multi-hop RAG for complex questions - Agentic RAG with autonomous retrieval
Example:
engine, err := rag.New(
rag.WithVectorStore(memory.NewStore()),
rag.WithEmbedder(embedderInstance),
rag.WithLLM(llmInstance),
)
// Index entire directory with 10 concurrent workers
err = engine.IndexDirectory(ctx, "./documents")
// Query with custom prompt
resp, err := engine.Query(ctx, "What is Go?", rag.QueryOptions{
TopK: 5,
PromptTemplate: "Answer based on context: {context}\nQuestion: {question}",
})
func New ¶
New creates a new RAG engine with the provided options
This function creates a new Engine instance and applies the provided options. It automatically loads all built-in parsers for 9 file formats: - Text (.txt, .md) - PDF (.pdf) - DOCX (.docx) - HTML (.html) - JSON (.json) - YAML (.yaml, .yml) - Excel (.xlsx) - PPT (.pptx) - Image (.jpg, .jpeg, .png)
Required options: - WithVectorStore: Vector storage backend - WithEmbedder: Embedding model provider - WithLLM: LLM client for generation
Optional options: - WithParser: Default parser for unknown file types - WithParsers: Custom parsers for specific file formats - WithRetriever: Custom hybrid retriever - WithReranker: Custom LLM reranker - WithLogger: Custom logger - WithMetrics: Custom metrics collector - WithTracer: Custom tracer - WithPluginDirectory: Directory to load plugins from
Returns: - *Engine: Newly created RAG engine - error: Error if required components are missing
Example:
// Create embedding provider
embedderInstance, err := embedder.New(embedder.Config{APIKey: apiKey})
if err != nil {
log.Fatal(err)
}
// Create LLM client
llmInstance, err := llm.New(llm.Config{APIKey: apiKey})
if err != nil {
log.Fatal(err)
}
// Create RAG engine
engine, err := rag.New(
rag.WithVectorStore(memory.NewStore()),
rag.WithEmbedder(embedderInstance),
rag.WithLLM(llmInstance),
rag.WithPluginDirectory("./plugins"),
)
if err != nil {
log.Fatal(err)
}
// Engine is ready with all 9 built-in parsers loaded and plugins from directory
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) AsyncIndexDirectory ¶ added in v0.6.0
AsyncIndexDirectory indexes all files in a directory recursively 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) Error ¶ added in v0.6.0
func (e *Engine) Error(ctx context.Context, message string, err error, fields map[string]interface{})
Error logs error level message
func (*Engine) IndexDirectory ¶ added in v0.6.0
IndexDirectory indexes all files in a directory recursively with concurrent workers
func (*Engine) QueryStream ¶
func (e *Engine) QueryStream(ctx context.Context, question string, opts QueryOptions) (<-chan StreamResponse, error)
QueryStream performs a streaming RAG query
func (*Engine) QueryWithConversation ¶ added in v0.6.0
func (e *Engine) QueryWithConversation(ctx context.Context, question string, opts ConversationOptions) (*Response, error)
QueryWithConversation performs a RAG query with conversation history
func (*Engine) RecordErrorCount ¶ added in v0.6.0
RecordErrorCount records error metrics
func (*Engine) RecordIndexCount ¶ added in v0.6.0
RecordIndexCount records index count metrics
func (*Engine) RecordIndexLatency ¶ added in v0.6.0
RecordIndexLatency records index latency metrics
func (*Engine) RecordIndexedDocuments ¶ added in v1.0.1
RecordIndexedDocuments records the number of indexed documents
func (*Engine) RecordIndexingDocuments ¶ added in v1.0.1
RecordIndexingDocuments records the number of documents being indexed
func (*Engine) RecordMonitoredDocuments ¶ added in v1.0.1
RecordMonitoredDocuments records the number of monitored documents
func (*Engine) RecordQueryCount ¶ added in v0.6.0
RecordQueryCount records query count metrics
func (*Engine) RecordQueryLatency ¶ added in v0.6.0
RecordQueryLatency records query latency metrics
func (*Engine) RecordSystemMetrics ¶ added in v1.0.1
RecordSystemMetrics records system metrics (CPU, memory)
func (*Engine) ReindexFile ¶ added in v1.0.1
ReindexFile reindexes a file by first deleting existing chunks and then reindexing
func (*Engine) Set ¶ added in v0.6.0
func (e *Engine) Set(ctx context.Context, key string, value *query.Response, expiration time.Duration)
Set stores a response in cache
func (*Engine) SetDefaultParser ¶ added in v0.6.0
SetDefaultParser sets the default parser for unknown formats
func (*Engine) StartWatch ¶ added in v1.0.1
StartWatch starts watching a directory for changes and automatically indexes files
Parameters: - targetIndexDir: Directory to watch for changes
Returns: - error: Error if watching fails
This method will: 1. First perform an initial indexing of the directory 2. Then start watching for file changes 3. Automatically reindex files when they change 4. Use asynchronous indexing to avoid blocking
func (*Engine) StartWatchAsync ¶ added in v1.0.1
func (e *Engine) StartWatchAsync(targetIndexDir string) (context.CancelFunc, error)
StartWatchAsync starts watching a directory for changes asynchronously Returns a cancel function to stop watching.
Parameters: - targetIndexDir: Directory to watch for changes
Returns: - context.CancelFunc: Call this to stop watching - error: Error if starting the watch fails
func (*Engine) StartWatchWithContext ¶ added in v1.0.2
StartWatchWithContext watches a directory for changes with context cancellation support
type HealthChecker ¶ added in v0.6.0
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker performs health checks on engine components
func NewHealthChecker ¶ added in v0.6.0
func NewHealthChecker(engine *Engine) *HealthChecker
NewHealthChecker creates a new health checker
func (*HealthChecker) Check ¶ added in v0.6.0
func (h *HealthChecker) Check(ctx context.Context) *HealthReport
Check performs a full health check
func (*HealthChecker) WithTimeout ¶ added in v0.6.0
func (h *HealthChecker) WithTimeout(timeout time.Duration) *HealthChecker
WithTimeout sets the health check timeout
func (*HealthChecker) WithVersion ¶ added in v0.6.0
func (h *HealthChecker) WithVersion(version string) *HealthChecker
WithVersion sets the version string
type HealthReport ¶ added in v0.6.0
type HealthReport struct {
Status HealthStatus `json:"status"`
Components []ComponentHealth `json:"components"`
Timestamp time.Time `json:"timestamp"`
Uptime time.Duration `json:"uptime"`
Version string `json:"version"`
}
HealthReport represents the overall health of the RAG engine
type HealthStatus ¶ added in v0.6.0
type HealthStatus string
HealthStatus represents the health status of a component
const ( // HealthStatusUp indicates the component is healthy HealthStatusUp HealthStatus = "up" // HealthStatusDown indicates the component is unhealthy HealthStatusDown HealthStatus = "down" // HealthStatusDegraded indicates the component is partially healthy HealthStatusDegraded HealthStatus = "degraded" )
type HyDE ¶ added in v0.6.0
type HyDE struct {
// contains filtered or unexported fields
}
HyDE (Hypothetical Document Embeddings) enhances query embeddings by generating a hypothetical document https://arxiv.org/abs/2212.10496
func (*HyDE) EnhanceQuery ¶ added in v0.6.0
EnhanceQuery enhances the query using HyDE
func (*HyDE) WithPromptTemplate ¶ added in v0.6.0
WithPromptTemplate sets a custom prompt template for HyDE
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) Close ¶ added in v1.0.2
func (c *MemoryCache) Close() error
Close stops the cache cleanup goroutine and releases resources
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(ctx context.Context, key string)
Delete removes a cached response for the given key
type Message ¶ added in v0.6.0
type Message struct {
ID string
Role string // "user" or "assistant"
Content string
Timestamp time.Time
}
Message represents a message in a conversation
type Option ¶
type Option func(*Engine)
Option configures the Engine
func WithAgenticRAG ¶ added in v0.6.0
func WithAgenticRAG(agentic *retrieval.AgenticRAG) Option
WithAgenticRAG sets the agentic RAG component
func WithBatchProcessor ¶ added in v1.0.1
WithBatchProcessor optimizes embedding batch processing
Parameters: - batchSize: Size of each batch - maxWorkers: Maximum number of concurrent workers - rateLimit: Minimum time between requests
Returns: - Option: Engine option
func WithCircuitBreaker ¶ added in v1.0.1
WithCircuitBreaker adds circuit breaker protection to the LLM client
Parameters: - maxFailures: Maximum number of failures before opening the circuit - timeout: Time to wait before attempting to close the circuit - halfOpenMax: Maximum number of requests in half-open state
Returns: - Option: Engine option
func WithConnectionPool ¶ added in v1.0.1
WithConnectionPool wraps the vector store with a connection pool
Parameters: - maxConns: Maximum number of connections - idleConns: Maximum number of idle connections - idleTimeout: Idle connection timeout
Returns: - Option: Engine option
func WithContextCompressor ¶ added in v0.6.0
func WithContextCompressor(c *ContextCompressor) Option
WithContextCompressor sets the context compressor for optimizing context
func WithConversationManager ¶ added in v0.6.0
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 ¶ added in v0.6.0
func WithMultiHopRAG(multiHop *retrieval.MultiHopRAG) Option
WithMultiHopRAG sets the multi-hop RAG component
func WithParser ¶
WithParser sets the default document parser
func WithParsers ¶ added in v0.6.0
WithParsers sets multiple parsers for different formats
func WithPluginConfig ¶ added in v1.0.1
WithPluginConfig sets the plugin configuration for the engine
func WithPluginDirectory ¶ added in v1.0.1
WithPluginDirectory sets the plugin directory for the engine
func WithQueryCache ¶ added in v1.0.1
WithQueryCache enables query result caching
Parameters: - ttl: Cache time-to-live
Returns: - Option: Engine option
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 PluginOptions ¶ added in v1.0.1
type PluginOptions struct {
// PluginDirectory is the directory to load plugins from
PluginDirectory string
// PluginConfig is the configuration for plugins
PluginConfig map[string]interface{}
}
PluginOptions holds plugin-related configuration
This struct defines options for plugin loading and management.
type Progress ¶ added in v0.6.0
type Progress struct {
ID string `json:"id"`
Status ProgressStatus `json:"status"`
TotalFiles int `json:"total_files"`
ProcessedFiles int `json:"processed_files"`
FailedFiles []string `json:"failed_files"`
CurrentFile string `json:"current_file"`
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time,omitempty"`
Error string `json:"error,omitempty"`
// contains filtered or unexported fields
}
Progress represents the progress of an indexing operation
func NewProgress ¶ added in v0.6.0
NewProgress creates a new progress tracker
func (*Progress) AddFailedFile ¶ added in v0.6.0
AddFailedFile adds a failed file to the list
func (*Progress) Cancel ¶ added in v0.6.0
func (p *Progress) Cancel()
Cancel marks the progress as cancelled
func (*Progress) Complete ¶ added in v0.6.0
func (p *Progress) Complete()
Complete marks the progress as completed
func (*Progress) IncrementProcessed ¶ added in v0.6.0
func (p *Progress) IncrementProcessed()
IncrementProcessed increments the processed files count
func (*Progress) IsComplete ¶ added in v0.6.0
IsComplete returns true if the operation is complete
func (*Progress) Percentage ¶ added in v0.6.0
Percentage returns the completion percentage
func (*Progress) SetCurrentFile ¶ added in v0.6.0
SetCurrentFile sets the current file being processed
func (*Progress) Snapshot ¶ added in v0.6.0
func (p *Progress) Snapshot() ProgressSnapshot
Snapshot returns a copy of the current progress state
type ProgressChannel ¶ added in v0.6.0
type ProgressChannel struct {
Progress *Progress
Updates chan ProgressSnapshot
// contains filtered or unexported fields
}
ProgressChannel wraps a progress instance with a channel for updates
func NewProgressChannel ¶ added in v0.6.0
func NewProgressChannel(ctx context.Context, progress *Progress) *ProgressChannel
NewProgressChannel creates a new progress channel
func (*ProgressChannel) Close ¶ added in v0.6.0
func (pc *ProgressChannel) Close()
Close closes the progress channel
func (*ProgressChannel) Send ¶ added in v0.6.0
func (pc *ProgressChannel) Send()
Send sends a progress update
func (*ProgressChannel) Watch ¶ added in v0.6.0
func (pc *ProgressChannel) Watch() <-chan ProgressSnapshot
Watch returns a channel that receives progress updates
type ProgressSnapshot ¶ added in v0.6.0
type ProgressSnapshot struct {
ID string `json:"id"`
Status ProgressStatus `json:"status"`
TotalFiles int `json:"total_files"`
ProcessedFiles int `json:"processed_files"`
FailedFiles []string `json:"failed_files"`
CurrentFile string `json:"current_file"`
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time,omitempty"`
Error string `json:"error,omitempty"`
}
ProgressSnapshot is a read-only copy of Progress state (safe to copy by value)
type ProgressStatus ¶ added in v0.6.0
type ProgressStatus string
ProgressStatus represents the status of an operation
const ( // ProgressStatusPending indicates the operation is pending ProgressStatusPending ProgressStatus = "pending" // ProgressStatusRunning indicates the operation is running ProgressStatusRunning ProgressStatus = "running" // ProgressStatusCompleted indicates the operation completed successfully ProgressStatusCompleted ProgressStatus = "completed" // ProgressStatusFailed indicates the operation failed ProgressStatusFailed ProgressStatus = "failed" // ProgressStatusCancelled indicates the operation was cancelled ProgressStatusCancelled ProgressStatus = "cancelled" )
type ProgressTracker ¶ added in v0.6.0
type ProgressTracker struct {
// contains filtered or unexported fields
}
ProgressTracker manages multiple progress instances
func NewProgressTracker ¶ added in v0.6.0
func NewProgressTracker() *ProgressTracker
NewProgressTracker creates a new progress tracker
func (*ProgressTracker) Cleanup ¶ added in v0.6.0
func (t *ProgressTracker) Cleanup(maxAge time.Duration) int
Cleanup removes completed progress instances older than the specified duration
func (*ProgressTracker) Create ¶ added in v0.6.0
func (t *ProgressTracker) Create(id string, totalFiles int) *Progress
Create creates a new progress instance
func (*ProgressTracker) Delete ¶ added in v0.6.0
func (t *ProgressTracker) Delete(id string)
Delete removes a progress instance
func (*ProgressTracker) Get ¶ added in v0.6.0
func (t *ProgressTracker) Get(id string) (*Progress, bool)
Get retrieves a progress instance by ID
func (*ProgressTracker) List ¶ added in v0.6.0
func (t *ProgressTracker) List() []ProgressSnapshot
List returns all progress instances
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 ¶
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 Source ¶
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 := core.Source{
Type: "text",
Content: "Go is an open source programming language...",
}
// Index a file
source2 := core.Source{
Type: ".pdf",
Path: "/path/to/document.pdf",
}