rag

package
v1.10.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAbsolutePaths

func GetAbsolutePaths(basePath string, docPaths []string) []string

GetAbsolutePaths converts doc paths to absolute paths

func NewManagers

func NewManagers(
	ctx context.Context,
	cfg *latest.Config,
	buildCfg ManagersBuildConfig,
) (map[string]*Manager, error)

NewManagers constructs all RAG managers defined in the config.

Types

type Config

type Config struct {
	Tool            ToolConfig
	Docs            []string
	Results         ResultsConfig
	FusionConfig    *FusionConfig
	StrategyConfigs []strategy.Config
}

Config represents RAG manager configuration in domain terms, independent of any particular config schema version.

type FusionConfig

type FusionConfig struct {
	Strategy string             // "rrf", "weighted", "max"
	K        int                // RRF parameter
	Weights  map[string]float64 // Strategy weights
}

FusionConfig holds configuration for result fusion

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager orchestrates RAG operations using pluggable strategies Supports both single-strategy and hybrid multi-strategy retrieval with fusion

func New

func New(_ context.Context, name string, config Config, strategyEvents <-chan types.Event) (*Manager, error)

New creates a new RAG manager with one or more strategies. Pass multiple strategy configs to enable hybrid retrieval. The strategyEvents channel should be shared across all strategies for this manager.

func (*Manager) CheckAndReindexChangedFiles

func (m *Manager) CheckAndReindexChangedFiles(ctx context.Context) error

CheckAndReindexChangedFiles checks for file changes and re-indexes if needed

func (*Manager) Close

func (m *Manager) Close() error

Close closes the manager and releases resources

func (*Manager) Description

func (m *Manager) Description() string

Description returns the RAG source description

func (*Manager) Events

func (m *Manager) Events() <-chan types.Event

Events returns the event channel shared by all strategies and RAG operations for this manager.

func (*Manager) Initialize

func (m *Manager) Initialize(ctx context.Context) error

Initialize indexes all documents using all configured strategies Each strategy indexes its own document set (shared + strategy-specific) Strategies are initialized in parallel for better performance

func (*Manager) Name

func (m *Manager) Name() string

Name returns the RAG source name

func (*Manager) Query

func (m *Manager) Query(ctx context.Context, query string) ([]database.SearchResult, error)

Query searches for relevant documents using all configured strategies If multiple strategies are configured, results are combined using the fusion strategy

func (*Manager) StartFileWatcher

func (m *Manager) StartFileWatcher(ctx context.Context) error

StartFileWatcher starts monitoring files and directories for changes

func (*Manager) ToolInstruction added in v1.9.26

func (m *Manager) ToolInstruction() string

ToolInstruction returns the tool instruction for this RAG source

func (*Manager) ToolName added in v1.9.26

func (m *Manager) ToolName() string

ToolName returns the custom tool name for this RAG source

type ManagersBuildConfig

type ManagersBuildConfig struct {
	ParentDir     string
	ModelsGateway string
	Env           environment.Provider
	Models        map[string]latest.ModelConfig // Model configurations from config
}

ManagersBuildConfig contains dependencies needed to build RAG managers from config.

type RerankingConfig added in v1.9.22

type RerankingConfig struct {
	Reranker  rerank.Reranker // The reranker instance (already configured)
	TopK      int             // Optional: only rerank top K results (0 = rerank all)
	Threshold float64         // Optional: minimum score threshold after reranking
}

RerankingConfig holds configuration for result reranking

type ResultsConfig

type ResultsConfig struct {
	Limit             int              // Maximum number of results to return (top K)
	Deduplicate       bool             // Remove duplicate entries based on final content
	IncludeScore      bool             // Include relevance scores in results (if/when used)
	ReturnFullContent bool             // Return full document content instead of just matched chunks
	RerankingConfig   *RerankingConfig // Optional reranking configuration
}

ResultsConfig captures result-postprocessing behavior for the manager.

type ToolConfig added in v1.9.26

type ToolConfig struct {
	Name        string
	Description string
	Instruction string
}

ToolConfig represents tool-specific configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL