Documentation
¶
Index ¶
- type AgentService
- type AgentServiceConfig
- type CachedEmbedding
- type ChunkFilter
- type ChunkerService
- type ChunkingConfig
- type ChunkingEvaluationMetrics
- type ChunkingEvaluator
- func (ce *ChunkingEvaluator) CompareChunkingStrategies(doc *domain.Document) []ChunkingEvaluationMetrics
- func (ce *ChunkingEvaluator) EvaluateChunkingStrategy(doc *domain.Document, config ChunkingConfig) ChunkingEvaluationMetrics
- func (ce *ChunkingEvaluator) GetOptimalChunkingConfig(doc *domain.Document) ChunkingConfig
- func (ce *ChunkingEvaluator) PrintEvaluationResults(metrics ChunkingEvaluationMetrics)
- type DocumentLoader
- type DocumentLoaderOptions
- type EmbeddingCache
- type EmbeddingService
- func (es *EmbeddingService) GenerateChunkEmbeddings(chunks []*domain.DocumentChunk, modelName string) error
- func (es *EmbeddingService) GenerateEmbeddings(docs []*domain.Document, modelName string) error
- func (es *EmbeddingService) GenerateQueryEmbedding(query string, modelName string) ([]float32, error)
- func (es *EmbeddingService) SetMaxWorkers(workers int)
- type FileWatcher
- type RagService
- type RagServiceAdapter
- type RagServiceImpl
- func (rs *RagServiceImpl) AddDocsWithOptions(ragName string, folderPath string, options DocumentLoaderOptions) error
- func (rs *RagServiceImpl) CheckWatchedDirectory(ragName string) (int, error)
- func (rs *RagServiceImpl) CheckWatchedWebsite(ragName string) (int, error)
- func (rs *RagServiceImpl) CreateRagWithOptions(modelName, ragName, folderPath string, options DocumentLoaderOptions) error
- func (rs *RagServiceImpl) DisableDirectoryWatching(ragName string) error
- func (rs *RagServiceImpl) DisableWebWatching(ragName string) error
- func (rs *RagServiceImpl) GetOllamaClient() *client.OllamaClient
- func (rs *RagServiceImpl) GetRagChunks(ragName string, filter ChunkFilter) ([]*domain.DocumentChunk, error)
- func (rs *RagServiceImpl) ListAllRags() ([]string, error)
- func (rs *RagServiceImpl) LoadRag(ragName string) (*domain.RagSystem, error)
- func (rs *RagServiceImpl) Query(rag *domain.RagSystem, query string, contextSize int) (string, error)
- func (rs *RagServiceImpl) SetupDirectoryWatching(ragName string, dirPath string, watchInterval int, ...) error
- func (rs *RagServiceImpl) SetupWebWatching(ragName string, websiteURL string, watchInterval int, ...) error
- func (rs *RagServiceImpl) UpdateModel(ragName string, newModel string) error
- func (rs *RagServiceImpl) UpdateRag(rag *domain.RagSystem) error
- func (rs *RagServiceImpl) UpdateRerankerModel(ragName string, model string) error
- type RankedResult
- type RerankerOptions
- type RerankerService
- type WebWatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentService ¶ added in v0.1.37
type AgentService struct {
// contains filtered or unexported fields
}
AgentService orchestrates agent operations
func NewAgentService ¶ added in v0.1.37
func NewAgentService( ragService RagService, ragSystem *domain.RagSystem, llmClient agent.LLMClient, config AgentServiceConfig, ) *AgentService
NewAgentService creates a new AgentService
type AgentServiceConfig ¶ added in v0.1.37
AgentServiceConfig holds configuration for AgentService
type CachedEmbedding ¶
type CachedEmbedding struct { Embedding []float32 CreatedAt time.Time AccessedAt time.Time UseCount int // Pour garder trace des éléments les plus utilisés }
CachedEmbedding represents a cached embedding with metadata
type ChunkFilter ¶
ChunkFilter defines filtering criteria for retrieving chunks
type ChunkerService ¶
type ChunkerService struct {
// contains filtered or unexported fields
}
ChunkerService handles splitting documents into manageable chunks
func NewChunkerService ¶
func NewChunkerService(config ChunkingConfig) *ChunkerService
NewChunkerService creates a new chunker service with the specified config
func (*ChunkerService) ChunkDocument ¶
func (cs *ChunkerService) ChunkDocument(doc *domain.Document) []*domain.DocumentChunk
ChunkDocument splits a document into smaller chunks with metadata based on the selected chunking strategy
type ChunkingConfig ¶
type ChunkingConfig struct { ChunkSize int // Target size of each chunk in characters ChunkOverlap int // Number of characters to overlap between chunks IncludeMetadata bool // Whether to include metadata in chunk content ChunkingStrategy string // Strategy to use: "fixed", "semantic", "hybrid", "hierarchical" }
ChunkingConfig holds configuration for the document chunking process
func DefaultChunkingConfig ¶
func DefaultChunkingConfig() ChunkingConfig
DefaultChunkingConfig returns a default configuration for chunking
type ChunkingEvaluationMetrics ¶ added in v0.1.33
type ChunkingEvaluationMetrics struct { // Basic metrics TotalChunks int // Total number of chunks produced AverageChunkSize float64 // Average chunk size in characters SizeStdDeviation float64 // Standard deviation of chunk sizes MaxChunkSize int // Size of the largest chunk MinChunkSize int // Size of the smallest chunk // Coherence metrics ChunksWithSplitSentences int // Number of chunks that split sentences ChunksWithSplitParagraphs int // Number of chunks that split paragraphs SemanticCoherenceScore float64 // Estimated semantic coherence score // Performance metrics ProcessingTimeMs int64 // Processing time in ms // Distribution metrics ContentCoverage float64 // % of original content covered by chunks RedundancyRate float64 // Redundancy rate due to overlap // Strategy info Strategy string // Strategy used ChunkSize int // Configured chunk size ChunkOverlap int // Configured overlap }
ChunkingEvaluationMetrics contains evaluation metrics for a chunking strategy
type ChunkingEvaluator ¶ added in v0.1.33
type ChunkingEvaluator struct {
// contains filtered or unexported fields
}
ChunkingEvaluator evaluates different chunking strategies
func NewChunkingEvaluator ¶ added in v0.1.33
func NewChunkingEvaluator(chunkerService *ChunkerService) *ChunkingEvaluator
NewChunkingEvaluator creates a new chunking evaluator
func (*ChunkingEvaluator) CompareChunkingStrategies ¶ added in v0.1.33
func (ce *ChunkingEvaluator) CompareChunkingStrategies(doc *domain.Document) []ChunkingEvaluationMetrics
CompareChunkingStrategies runs a comparative evaluation of different chunking configurations and returns the results sorted by relevance for this document
func (*ChunkingEvaluator) EvaluateChunkingStrategy ¶ added in v0.1.33
func (ce *ChunkingEvaluator) EvaluateChunkingStrategy(doc *domain.Document, config ChunkingConfig) ChunkingEvaluationMetrics
EvaluateChunkingStrategy evaluates a chunking strategy with the given parameters
func (*ChunkingEvaluator) GetOptimalChunkingConfig ¶ added in v0.1.33
func (ce *ChunkingEvaluator) GetOptimalChunkingConfig(doc *domain.Document) ChunkingConfig
GetOptimalChunkingConfig returns the optimal chunking configuration for the given document
func (*ChunkingEvaluator) PrintEvaluationResults ¶ added in v0.1.33
func (ce *ChunkingEvaluator) PrintEvaluationResults(metrics ChunkingEvaluationMetrics)
PrintEvaluationResults displays evaluation results in a readable format
type DocumentLoader ¶
type DocumentLoader struct {
// contains filtered or unexported fields
}
DocumentLoader is responsible for loading documents from the file system
func NewDocumentLoader ¶
func NewDocumentLoader() *DocumentLoader
NewDocumentLoader creates a new instance of DocumentLoader
func (*DocumentLoader) CreateRagWithOptions ¶ added in v0.1.33
func (dl *DocumentLoader) CreateRagWithOptions(options DocumentLoaderOptions) (*domain.RagSystem, error)
CreateRagWithOptions creates a new RAG with the specified options
func (*DocumentLoader) LoadDocumentsFromFolderWithOptions ¶
func (dl *DocumentLoader) LoadDocumentsFromFolderWithOptions(folderPath string, options DocumentLoaderOptions) ([]*domain.Document, error)
LoadDocumentsFromFolderWithOptions loads documents with filtering options
type DocumentLoaderOptions ¶
type DocumentLoaderOptions struct { ExcludeDirs []string ExcludeExts []string ProcessExts []string ChunkSize int ChunkOverlap int ChunkingStrategy string // Chunking strategy: "fixed", "semantic", "hybrid", "hierarchical" APIProfileName string // Name of the API profile to use EnableReranker bool // Whether to enable reranking - now true by default RerankerModel string // Model to use for reranking RerankerWeight float64 // Weight for reranker scores (0-1) }
DocumentLoaderOptions defines filtering options for document loading
func NewDocumentLoaderOptions ¶ added in v0.1.33
func NewDocumentLoaderOptions() DocumentLoaderOptions
NewDocumentLoaderOptions creates default document loader options with reranking enabled
type EmbeddingCache ¶
type EmbeddingCache struct {
// contains filtered or unexported fields
}
EmbeddingCache provides caching for embeddings to avoid regeneration of the same content
func NewEmbeddingCache ¶
func NewEmbeddingCache(maxSize int, ttl time.Duration) *EmbeddingCache
NewEmbeddingCache creates a new embedding cache
type EmbeddingService ¶
type EmbeddingService struct {
// contains filtered or unexported fields
}
EmbeddingService manages the generation of embeddings for documents
func NewEmbeddingService ¶
func NewEmbeddingService(ollamaClient *client.OllamaClient) *EmbeddingService
NewEmbeddingService creates a new instance of EmbeddingService
func (*EmbeddingService) GenerateChunkEmbeddings ¶
func (es *EmbeddingService) GenerateChunkEmbeddings(chunks []*domain.DocumentChunk, modelName string) error
GenerateChunkEmbeddings generates embeddings for document chunks in parallel
func (*EmbeddingService) GenerateEmbeddings ¶
func (es *EmbeddingService) GenerateEmbeddings(docs []*domain.Document, modelName string) error
GenerateEmbeddings generates embeddings for a list of documents
func (*EmbeddingService) GenerateQueryEmbedding ¶
func (es *EmbeddingService) GenerateQueryEmbedding(query string, modelName string) ([]float32, error)
GenerateQueryEmbedding generates an embedding for a query
func (*EmbeddingService) SetMaxWorkers ¶ added in v0.1.32
func (es *EmbeddingService) SetMaxWorkers(workers int)
SetMaxWorkers sets the maximum number of parallel workers for embedding generation
type FileWatcher ¶ added in v0.1.29
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatcher is responsible for watching directories for file changes
func NewFileWatcher ¶ added in v0.1.29
func NewFileWatcher(ragService RagService) *FileWatcher
NewFileWatcher creates a new file watcher service
func (*FileWatcher) CheckAndUpdateRag ¶ added in v0.1.29
func (fw *FileWatcher) CheckAndUpdateRag(rag *domain.RagSystem) (int, error)
CheckAndUpdateRag checks for new files in the watched directory and updates the RAG
func (*FileWatcher) StartWatcherDaemon ¶ added in v0.1.29
func (fw *FileWatcher) StartWatcherDaemon(interval time.Duration)
StartWatcherDaemon starts a background daemon to watch directories for all RAGs that have watching enabled with intervals
type RagService ¶
type RagService interface { CreateRagWithOptions(modelName, ragName, folderPath string, options DocumentLoaderOptions) error GetRagChunks(ragName string, filter ChunkFilter) ([]*domain.DocumentChunk, error) LoadRag(ragName string) (*domain.RagSystem, error) Query(rag *domain.RagSystem, query string, contextSize int) (string, error) AddDocsWithOptions(ragName string, folderPath string, options DocumentLoaderOptions) error UpdateModel(ragName string, newModel string) error UpdateRag(rag *domain.RagSystem) error UpdateRerankerModel(ragName string, model string) error ListAllRags() ([]string, error) GetOllamaClient() *client.OllamaClient // Directory watching methods SetupDirectoryWatching(ragName string, dirPath string, watchInterval int, options DocumentLoaderOptions) error DisableDirectoryWatching(ragName string) error CheckWatchedDirectory(ragName string) (int, error) // Web watching methods SetupWebWatching(ragName string, websiteURL string, watchInterval int, options domain.WebWatchOptions) error DisableWebWatching(ragName string) error CheckWatchedWebsite(ragName string) (int, error) }
RagService interface defines the contract for RAG operations
func NewRagService ¶
func NewRagService(ollamaClient *client.OllamaClient) RagService
NewRagService creates a new instance of RagService
func NewRagServiceWithEmbedding ¶ added in v0.1.32
func NewRagServiceWithEmbedding(ollamaClient *client.OllamaClient, embeddingService *EmbeddingService) RagService
NewRagServiceWithEmbedding creates a new RagService with a specific embedding service
type RagServiceAdapter ¶ added in v0.1.37
type RagServiceAdapter struct {
// contains filtered or unexported fields
}
RagServiceAdapter adapts the existing RagService to the agent's RagService interface
func NewRagServiceAdapter ¶ added in v0.1.37
func NewRagServiceAdapter(ragService RagService, ragSystem *domain.RagSystem) *RagServiceAdapter
NewRagServiceAdapter creates a new adapter for RagService
type RagServiceImpl ¶
type RagServiceImpl struct {
// contains filtered or unexported fields
}
RagServiceImpl implements the RagService interface
func (*RagServiceImpl) AddDocsWithOptions ¶
func (rs *RagServiceImpl) AddDocsWithOptions(ragName string, folderPath string, options DocumentLoaderOptions) error
AddDocsWithOptions adds documents to a RAG with options
func (*RagServiceImpl) CheckWatchedDirectory ¶ added in v0.1.29
func (rs *RagServiceImpl) CheckWatchedDirectory(ragName string) (int, error)
CheckWatchedDirectory checks a watched directory for changes
func (*RagServiceImpl) CheckWatchedWebsite ¶ added in v0.1.32
func (rs *RagServiceImpl) CheckWatchedWebsite(ragName string) (int, error)
CheckWatchedWebsite checks a watched website for changes
func (*RagServiceImpl) CreateRagWithOptions ¶
func (rs *RagServiceImpl) CreateRagWithOptions(modelName, ragName, folderPath string, options DocumentLoaderOptions) error
CreateRagWithOptions creates a new RAG system with options
func (*RagServiceImpl) DisableDirectoryWatching ¶ added in v0.1.29
func (rs *RagServiceImpl) DisableDirectoryWatching(ragName string) error
DisableDirectoryWatching disables directory watching for a RAG
func (*RagServiceImpl) DisableWebWatching ¶ added in v0.1.32
func (rs *RagServiceImpl) DisableWebWatching(ragName string) error
DisableWebWatching disables web watching for a RAG
func (*RagServiceImpl) GetOllamaClient ¶ added in v0.1.29
func (rs *RagServiceImpl) GetOllamaClient() *client.OllamaClient
GetOllamaClient returns the Ollama client
func (*RagServiceImpl) GetRagChunks ¶
func (rs *RagServiceImpl) GetRagChunks(ragName string, filter ChunkFilter) ([]*domain.DocumentChunk, error)
GetRagChunks gets chunks from a RAG with filtering
func (*RagServiceImpl) ListAllRags ¶ added in v0.1.29
func (rs *RagServiceImpl) ListAllRags() ([]string, error)
ListAllRags lists all available RAGs
func (*RagServiceImpl) LoadRag ¶
func (rs *RagServiceImpl) LoadRag(ragName string) (*domain.RagSystem, error)
LoadRag loads a RAG system
func (*RagServiceImpl) Query ¶
func (rs *RagServiceImpl) Query(rag *domain.RagSystem, query string, contextSize int) (string, error)
Query performs a query on a RAG system
func (*RagServiceImpl) SetupDirectoryWatching ¶ added in v0.1.29
func (rs *RagServiceImpl) SetupDirectoryWatching(ragName string, dirPath string, watchInterval int, options DocumentLoaderOptions) error
SetupDirectoryWatching sets up directory watching for a RAG
func (*RagServiceImpl) SetupWebWatching ¶ added in v0.1.32
func (rs *RagServiceImpl) SetupWebWatching(ragName string, websiteURL string, watchInterval int, options domain.WebWatchOptions) error
SetupWebWatching sets up web watching for a RAG
func (*RagServiceImpl) UpdateModel ¶
func (rs *RagServiceImpl) UpdateModel(ragName string, newModel string) error
UpdateModel updates the model of a RAG
func (*RagServiceImpl) UpdateRag ¶
func (rs *RagServiceImpl) UpdateRag(rag *domain.RagSystem) error
UpdateRag updates a RAG system
func (*RagServiceImpl) UpdateRerankerModel ¶ added in v0.1.34
func (rs *RagServiceImpl) UpdateRerankerModel(ragName string, model string) error
UpdateRerankerModel updates the reranker model of a RAG
type RankedResult ¶ added in v0.1.33
type RankedResult struct { Chunk *domain.DocumentChunk VectorScore float64 RerankerScore float64 FinalScore float64 }
RankedResult represents a document with its relevance score after reranking
type RerankerOptions ¶ added in v0.1.33
type RerankerOptions struct { // TopK is the number of documents to return after reranking TopK int // InitialK is the number of documents to retrieve from the initial search // before reranking (should be >= TopK) InitialK int // RerankerModel is the model to use for reranking // If empty, will default to the same model used for embedding RerankerModel string // ScoreThreshold is the minimum relevance score (0-1) for a document to be included // Documents with scores below this threshold will be filtered out ScoreThreshold float64 // RerankerWeight defines the weight of the reranker score vs vector similarity // 0.0 = use only vector similarity, 1.0 = use only reranker scores RerankerWeight float64 // AdaptiveFiltering when true, uses content relevance to select chunks // rather than a fixed top-k approach AdaptiveFiltering bool }
RerankerOptions defines configuration options for the reranking process
func DefaultRerankerOptions ¶ added in v0.1.33
func DefaultRerankerOptions() RerankerOptions
DefaultRerankerOptions returns the default options for reranking
type RerankerService ¶ added in v0.1.33
type RerankerService struct {
// contains filtered or unexported fields
}
RerankerService handles document reranking using cross-encoder models
func NewRerankerService ¶ added in v0.1.33
func NewRerankerService(ollamaClient *client.OllamaClient) *RerankerService
NewRerankerService creates a new instance of RerankerService
func (*RerankerService) Rerank ¶ added in v0.1.33
func (rs *RerankerService) Rerank( query string, rag *domain.RagSystem, initialResults []vector.SearchResult, options RerankerOptions, ) ([]RankedResult, error)
Rerank takes initial retrieval results and reruns them through a cross-encoder for more accurate ranking
type WebWatcher ¶ added in v0.1.32
type WebWatcher struct {
// contains filtered or unexported fields
}
WebWatcher is responsible for watching websites for content changes
func NewWebWatcher ¶ added in v0.1.32
func NewWebWatcher(ragService RagService) *WebWatcher
NewWebWatcher creates a new web watcher service
func (*WebWatcher) CheckAndUpdateRag ¶ added in v0.1.32
func (ww *WebWatcher) CheckAndUpdateRag(rag *domain.RagSystem) (int, error)
CheckAndUpdateRag checks for new content on the watched website and updates the RAG
func (*WebWatcher) StartWebWatcherDaemon ¶ added in v0.1.32
func (ww *WebWatcher) StartWebWatcherDaemon(interval time.Duration)
StartWebWatcherDaemon starts a background daemon to watch websites