Documentation
¶
Index ¶
- Variables
- func FormatError(err error) string
- func GetChunkBuffer() *chunkBuffer
- func GetEmbeddingBuffer(size int) *[]byte
- func IndexPath(repoRoot string) string
- func LanguageFromExtension(filename string) string
- func PutChunkBuffer(buf *chunkBuffer)
- func PutEmbeddingBuffer(buf *[]byte)
- type Chunk
- type ChunkType
- type Chunker
- type ChunkerFactory
- type CohereConfig
- type CohereEmbedder
- func (e *CohereEmbedder) Dimensions() int
- func (e *CohereEmbedder) Embed(ctx context.Context, text string) ([]float32, error)
- func (e *CohereEmbedder) EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
- func (e *CohereEmbedder) Model() string
- func (e *CohereEmbedder) SetInputType(inputType string)
- type CompactEmbedding
- type Embedder
- type EmbedderConfig
- type EmbedderInterface
- type ErrorType
- type GenericChunker
- type GoChunker
- type HuggingFaceConfig
- type HuggingFaceEmbedder
- type IndexHealth
- type IndexManager
- type IndexOptions
- type IndexResult
- type IndexStats
- type JSChunker
- type ListOptions
- type MemoryStats
- type OfflineEmbedder
- type OfflineMode
- type OfflineSearcher
- type OpenRouterConfig
- type OpenRouterEmbedder
- type PHPChunker
- type PythonChunker
- type QdrantConfig
- type QdrantStorage
- func (s *QdrantStorage) Close() error
- func (s *QdrantStorage) Create(ctx context.Context, chunk Chunk, embedding []float32) error
- func (s *QdrantStorage) Delete(ctx context.Context, id string) error
- func (s *QdrantStorage) DeleteByFilePath(ctx context.Context, filePath string) (int, error)
- func (s *QdrantStorage) DeleteCollection() error
- func (s *QdrantStorage) List(ctx context.Context, opts ListOptions) ([]Chunk, error)
- func (s *QdrantStorage) Read(ctx context.Context, id string) (*Chunk, error)
- func (s *QdrantStorage) Search(ctx context.Context, queryEmbedding []float32, opts SearchOptions) ([]SearchResult, error)
- func (s *QdrantStorage) Stats(ctx context.Context) (*IndexStats, error)
- func (s *QdrantStorage) Update(ctx context.Context, chunk Chunk, embedding []float32) error
- type SQLiteStorage
- func (s *SQLiteStorage) Close() error
- func (s *SQLiteStorage) Create(ctx context.Context, chunk Chunk, embedding []float32) error
- func (s *SQLiteStorage) Delete(ctx context.Context, id string) error
- func (s *SQLiteStorage) DeleteByFilePath(ctx context.Context, filePath string) (int, error)
- func (s *SQLiteStorage) List(ctx context.Context, opts ListOptions) ([]Chunk, error)
- func (s *SQLiteStorage) Read(ctx context.Context, id string) (*Chunk, error)
- func (s *SQLiteStorage) Search(ctx context.Context, queryEmbedding []float32, opts SearchOptions) ([]SearchResult, error)
- func (s *SQLiteStorage) Stats(ctx context.Context) (*IndexStats, error)
- func (s *SQLiteStorage) Update(ctx context.Context, chunk Chunk, embedding []float32) error
- type SearchOptions
- type SearchResult
- type Searcher
- type SemanticError
- func ErrChunkingFailure(filePath string, cause error) *SemanticError
- func ErrConnectionFailed(cause error) *SemanticError
- func ErrEmbeddingFailure(cause error) *SemanticError
- func ErrIndexNotFound() *SemanticError
- func ErrInvalidPath(path string, cause error) *SemanticError
- func ErrInvalidQuery(query string) *SemanticError
- func ErrStorageFailure(operation string, cause error) *SemanticError
- type Storage
- type StreamingChunkProcessor
- type UpdateOptions
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound indicates that a chunk was not found in storage ErrNotFound = errors.New("chunk not found") // ErrStorageClosed indicates that the storage has been closed ErrStorageClosed = errors.New("storage is closed") )
Functions ¶
func FormatError ¶
FormatError formats an error with user-friendly output
func GetChunkBuffer ¶
func GetChunkBuffer() *chunkBuffer
GetChunkBuffer gets a chunk buffer from the pool
func GetEmbeddingBuffer ¶
GetEmbeddingBuffer gets a buffer from the pool, sized appropriately
func LanguageFromExtension ¶
LanguageFromExtension extracts the language identifier from a filename
func PutChunkBuffer ¶
func PutChunkBuffer(buf *chunkBuffer)
PutChunkBuffer returns a chunk buffer to the pool
func PutEmbeddingBuffer ¶
func PutEmbeddingBuffer(buf *[]byte)
PutEmbeddingBuffer returns a buffer to the pool
Types ¶
type Chunk ¶
type Chunk struct {
ID string `json:"id"`
FilePath string `json:"file_path"`
Type ChunkType `json:"type"`
Name string `json:"name"`
Signature string `json:"signature,omitempty"`
Content string `json:"content"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
Language string `json:"language"`
}
Chunk represents a semantic unit of code (function, struct, etc.)
func (*Chunk) GenerateID ¶
GenerateID creates a deterministic ID for the chunk based on its content
type ChunkType ¶
type ChunkType int
ChunkType represents the type of code chunk
func ParseChunkType ¶
ParseChunkType parses a string into a ChunkType
func (ChunkType) MarshalJSON ¶
MarshalJSON implements json.Marshaler for ChunkType
func (*ChunkType) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for ChunkType
type Chunker ¶
type Chunker interface {
// Chunk breaks source code into semantic chunks
Chunk(path string, content []byte) ([]Chunk, error)
// SupportedExtensions returns the file extensions this chunker handles
SupportedExtensions() []string
}
Chunker is the interface for language-specific code chunking
type ChunkerFactory ¶
type ChunkerFactory struct {
// contains filtered or unexported fields
}
ChunkerFactory manages language-specific chunkers
func NewChunkerFactory ¶
func NewChunkerFactory() *ChunkerFactory
NewChunkerFactory creates a new chunker factory
func (*ChunkerFactory) GetByExtension ¶
func (f *ChunkerFactory) GetByExtension(filename string) (Chunker, bool)
GetByExtension returns the appropriate chunker based on filename extension
func (*ChunkerFactory) GetChunker ¶
func (f *ChunkerFactory) GetChunker(ext string) (Chunker, bool)
GetChunker returns a chunker for the specified language/extension
func (*ChunkerFactory) Register ¶
func (f *ChunkerFactory) Register(ext string, chunker Chunker)
Register adds a chunker for a specific language/extension
func (*ChunkerFactory) SupportedExtensions ¶
func (f *ChunkerFactory) SupportedExtensions() []string
SupportedExtensions returns all registered extensions
type CohereConfig ¶
type CohereConfig struct {
APIKey string // Cohere API key (required)
Model string // Model name (default: embed-english-v3.0)
BaseURL string // Base URL (default: https://api.cohere.com)
InputType string // Input type: search_document, search_query, classification, clustering
Timeout time.Duration // Request timeout
}
CohereConfig holds configuration for the Cohere embedding client
func (*CohereConfig) Validate ¶
func (c *CohereConfig) Validate() error
Validate checks if the config is valid
type CohereEmbedder ¶
type CohereEmbedder struct {
// contains filtered or unexported fields
}
CohereEmbedder generates embeddings using the Cohere API
func NewCohereEmbedder ¶
func NewCohereEmbedder(cfg CohereConfig) (*CohereEmbedder, error)
NewCohereEmbedder creates a new Cohere embedding client
func NewCohereEmbedderFromEnv ¶
func NewCohereEmbedderFromEnv() (*CohereEmbedder, error)
NewCohereEmbedderFromEnv creates a CohereEmbedder from environment variables
func (*CohereEmbedder) Dimensions ¶
func (e *CohereEmbedder) Dimensions() int
Dimensions returns the embedding dimension (0 if unknown)
func (*CohereEmbedder) EmbedBatch ¶
EmbedBatch generates embeddings for multiple texts
func (*CohereEmbedder) SetInputType ¶
func (e *CohereEmbedder) SetInputType(inputType string)
SetInputType allows changing the input type for different use cases Use "search_query" for queries, "search_document" for documents to be searched
type CompactEmbedding ¶
CompactEmbedding reduces precision for storage (optional memory savings) Converts float32 embeddings to int8 quantized values (-127 to 127) This reduces memory by 75% but loses some precision
func Quantize ¶
func Quantize(embedding []float32) *CompactEmbedding
Quantize converts a float32 embedding to a quantized form
func (*CompactEmbedding) Dequantize ¶
func (c *CompactEmbedding) Dequantize() []float32
Dequantize converts a quantized embedding back to float32
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder generates embeddings using an OpenAI-compatible API
func NewEmbedder ¶
func NewEmbedder(cfg EmbedderConfig) (*Embedder, error)
NewEmbedder creates a new Embedder with the given configuration
func (*Embedder) Dimensions ¶
Dimensions returns the embedding dimension (0 if unknown)
func (*Embedder) EmbedBatch ¶
EmbedBatch generates embeddings for multiple texts
type EmbedderConfig ¶
type EmbedderConfig struct {
APIURL string // Base URL for embedding API (OpenAI-compatible)
Model string // Model name (e.g., "nomic-embed-text", "mxbai-embed-large", "text-embedding-ada-002")
APIKey string // API key (optional for local models)
Timeout time.Duration // Request timeout
MaxRetries int // Maximum retry attempts
}
EmbedderConfig holds configuration for the embedding client
func DefaultEmbedderConfig ¶
func DefaultEmbedderConfig() EmbedderConfig
DefaultEmbedderConfig returns sensible defaults
type EmbedderInterface ¶
type EmbedderInterface interface {
Embed(ctx context.Context, text string) ([]float32, error)
EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
Dimensions() int
}
EmbedderInterface defines the interface for embedding generation (separate from the concrete Embedder to allow mocking)
type GenericChunker ¶
type GenericChunker struct {
// contains filtered or unexported fields
}
GenericChunker implements a simple text-based chunker for unsupported file types
func NewGenericChunker ¶
func NewGenericChunker(maxChunkSize int) *GenericChunker
NewGenericChunker creates a new generic text chunker
func (*GenericChunker) Chunk ¶
func (c *GenericChunker) Chunk(path string, content []byte) ([]Chunk, error)
Chunk splits content into chunks based on paragraphs/size
func (*GenericChunker) SupportedExtensions ¶
func (c *GenericChunker) SupportedExtensions() []string
SupportedExtensions returns the file extensions this chunker handles
type GoChunker ¶
type GoChunker struct{}
GoChunker implements the Chunker interface for Go source code
func (*GoChunker) SupportedExtensions ¶
SupportedExtensions returns the file extensions this chunker handles
type HuggingFaceConfig ¶
type HuggingFaceConfig struct {
APIKey string // HuggingFace API key (required)
Model string // Model name (default: sentence-transformers/all-MiniLM-L6-v2)
BaseURL string // Base URL (default: https://api-inference.huggingface.co)
Timeout time.Duration // Request timeout
WaitForModel bool // Wait for model to load if not ready
}
HuggingFaceConfig holds configuration for the HuggingFace embedding client
func (*HuggingFaceConfig) Validate ¶
func (c *HuggingFaceConfig) Validate() error
Validate checks if the config is valid
type HuggingFaceEmbedder ¶
type HuggingFaceEmbedder struct {
// contains filtered or unexported fields
}
HuggingFaceEmbedder generates embeddings using the HuggingFace Inference API
func NewHuggingFaceEmbedder ¶
func NewHuggingFaceEmbedder(cfg HuggingFaceConfig) (*HuggingFaceEmbedder, error)
NewHuggingFaceEmbedder creates a new HuggingFace embedding client
func NewHuggingFaceEmbedderFromEnv ¶
func NewHuggingFaceEmbedderFromEnv() (*HuggingFaceEmbedder, error)
NewHuggingFaceEmbedderFromEnv creates a HuggingFaceEmbedder from environment variables
func (*HuggingFaceEmbedder) Dimensions ¶
func (e *HuggingFaceEmbedder) Dimensions() int
Dimensions returns the embedding dimension (0 if unknown)
func (*HuggingFaceEmbedder) EmbedBatch ¶
EmbedBatch generates embeddings for multiple texts
func (*HuggingFaceEmbedder) Model ¶
func (e *HuggingFaceEmbedder) Model() string
Model returns the model name
type IndexHealth ¶
type IndexHealth struct {
Status string `json:"status"` // "healthy", "stale", "missing"
Stats IndexStats `json:"stats"`
StaleFiles int `json:"stale_files"`
NewFiles int `json:"new_files"`
ModifiedFiles int `json:"modified_files"`
}
IndexHealth represents the health status of the index
type IndexManager ¶
type IndexManager struct {
// contains filtered or unexported fields
}
IndexManager handles indexing operations
func NewIndexManager ¶
func NewIndexManager(storage Storage, embedder EmbedderInterface, factory *ChunkerFactory) *IndexManager
NewIndexManager creates a new IndexManager
func (*IndexManager) Index ¶
func (m *IndexManager) Index(ctx context.Context, rootPath string, opts IndexOptions) (*IndexResult, error)
Index builds or rebuilds the semantic index for a directory
func (*IndexManager) Status ¶
func (m *IndexManager) Status(ctx context.Context) (*IndexStats, error)
Status returns index statistics
func (*IndexManager) Update ¶
func (m *IndexManager) Update(ctx context.Context, rootPath string, opts UpdateOptions) (*UpdateResult, error)
Update performs incremental index update
type IndexOptions ¶
type IndexOptions struct {
Includes []string // Glob patterns to include (e.g., "*.go")
Excludes []string // Directory/pattern names to exclude (e.g., "vendor", "node_modules")
Force bool // Re-index all files even if unchanged
}
IndexOptions configures indexing behavior
type IndexResult ¶
IndexResult contains statistics from an indexing operation
type IndexStats ¶
type IndexStats struct {
FilesIndexed int `json:"files_indexed"`
ChunksTotal int `json:"chunks_total"`
EmbeddingModel string `json:"embedding_model"`
IndexSizeBytes int64 `json:"index_size_bytes"`
LastUpdated string `json:"last_updated"`
}
IndexStats holds statistics about the semantic index
type JSChunker ¶
type JSChunker struct {
// contains filtered or unexported fields
}
JSChunker implements the Chunker interface for JavaScript/TypeScript
func NewJSChunker ¶
func NewJSChunker() *JSChunker
NewJSChunker creates a new JavaScript/TypeScript chunker
func (*JSChunker) Chunk ¶
Chunk parses JavaScript/TypeScript source code and extracts semantic chunks
func (*JSChunker) SupportedExtensions ¶
SupportedExtensions returns the file extensions this chunker handles
type ListOptions ¶
type ListOptions struct {
Limit int // Maximum number of chunks to return (0 = no limit)
Offset int // Number of chunks to skip
FilePath string // Filter by file path
Type string // Filter by chunk type
Language string // Filter by language
}
ListOptions configures how chunks are listed
type MemoryStats ¶
MemoryStats holds memory usage statistics
func EstimateMemory ¶
func EstimateMemory(chunks int, embeddingDim int) MemoryStats
EstimateMemory estimates memory usage for a set of chunks
type OfflineEmbedder ¶
type OfflineEmbedder struct {
// contains filtered or unexported fields
}
OfflineEmbedder wraps an embedder with offline mode support
func NewOfflineEmbedder ¶
func NewOfflineEmbedder(embedder EmbedderInterface, dimensions int) *OfflineEmbedder
NewOfflineEmbedder creates an embedder with offline fallback support
func (*OfflineEmbedder) Dimensions ¶
func (o *OfflineEmbedder) Dimensions() int
Dimensions returns the embedding dimensions
func (*OfflineEmbedder) Embed ¶
Embed tries to use the embedder, falls back to keyword embedding if unavailable
func (*OfflineEmbedder) EmbedBatch ¶
EmbedBatch tries to use the embedder batch, falls back if unavailable
func (*OfflineEmbedder) IsOffline ¶
func (o *OfflineEmbedder) IsOffline() bool
IsOffline returns true if operating in offline mode
type OfflineMode ¶
type OfflineMode int
OfflineMode represents the current offline mode state
const ( // OnlineMode indicates the embedder is working normally OnlineMode OfflineMode = iota // OfflineFallback indicates we're using keyword fallback OfflineFallback )
type OfflineSearcher ¶
type OfflineSearcher struct {
// contains filtered or unexported fields
}
OfflineSearcher provides search capabilities with offline fallback
func NewOfflineSearcher ¶
func NewOfflineSearcher(storage Storage, embedder *OfflineEmbedder) *OfflineSearcher
NewOfflineSearcher creates a searcher with offline support
func (*OfflineSearcher) IsOffline ¶
func (s *OfflineSearcher) IsOffline() bool
IsOffline returns true if the searcher is operating in offline mode
func (*OfflineSearcher) Search ¶
func (s *OfflineSearcher) Search(ctx context.Context, query string, opts SearchOptions) ([]SearchResult, error)
Search performs semantic or keyword-based search
type OpenRouterConfig ¶
type OpenRouterConfig struct {
APIKey string // OpenRouter API key (required)
Model string // Model name (default: mistralai/codestral-embed-2505)
BaseURL string // Base URL (default: https://openrouter.ai)
Timeout time.Duration // Request timeout
MaxRetries int // Maximum retry attempts for rate limiting
}
OpenRouterConfig holds configuration for the OpenRouter embedding client
func (*OpenRouterConfig) Validate ¶
func (c *OpenRouterConfig) Validate() error
Validate checks if the config is valid
type OpenRouterEmbedder ¶
type OpenRouterEmbedder struct {
// contains filtered or unexported fields
}
OpenRouterEmbedder generates embeddings using the OpenRouter API
func NewOpenRouterEmbedder ¶
func NewOpenRouterEmbedder(cfg OpenRouterConfig) (*OpenRouterEmbedder, error)
NewOpenRouterEmbedder creates a new OpenRouter embedding client
func NewOpenRouterEmbedderFromEnv ¶
func NewOpenRouterEmbedderFromEnv() (*OpenRouterEmbedder, error)
NewOpenRouterEmbedderFromEnv creates an OpenRouterEmbedder from environment variables
func (*OpenRouterEmbedder) Dimensions ¶
func (e *OpenRouterEmbedder) Dimensions() int
Dimensions returns the embedding dimension (0 if unknown)
func (*OpenRouterEmbedder) EmbedBatch ¶
EmbedBatch generates embeddings for multiple texts
func (*OpenRouterEmbedder) Model ¶
func (e *OpenRouterEmbedder) Model() string
Model returns the model name
type PHPChunker ¶
type PHPChunker struct {
// contains filtered or unexported fields
}
PHPChunker implements the Chunker interface for PHP
func (*PHPChunker) Chunk ¶
func (c *PHPChunker) Chunk(path string, content []byte) ([]Chunk, error)
Chunk parses PHP source code and extracts semantic chunks
func (*PHPChunker) SupportedExtensions ¶
func (c *PHPChunker) SupportedExtensions() []string
SupportedExtensions returns the file extensions this chunker handles
type PythonChunker ¶
type PythonChunker struct {
// contains filtered or unexported fields
}
PythonChunker implements the Chunker interface for Python
func NewPythonChunker ¶
func NewPythonChunker() *PythonChunker
NewPythonChunker creates a new Python chunker
func (*PythonChunker) Chunk ¶
func (c *PythonChunker) Chunk(path string, content []byte) ([]Chunk, error)
Chunk parses Python source code and extracts semantic chunks
func (*PythonChunker) SupportedExtensions ¶
func (c *PythonChunker) SupportedExtensions() []string
SupportedExtensions returns the file extensions this chunker handles
type QdrantConfig ¶
type QdrantConfig struct {
APIKey string
URL string // Full URL like https://abc123.qdrant.io:6334
CollectionName string
EmbeddingDim int
}
QdrantConfig holds configuration for Qdrant storage
func (*QdrantConfig) Validate ¶
func (c *QdrantConfig) Validate() error
Validate checks if the config is valid
type QdrantStorage ¶
type QdrantStorage struct {
// contains filtered or unexported fields
}
QdrantStorage implements the Storage interface using Qdrant cloud
func NewQdrantStorage ¶
func NewQdrantStorage(config QdrantConfig) (*QdrantStorage, error)
NewQdrantStorage creates a new Qdrant-based storage
func NewQdrantStorageFromEnv ¶
func NewQdrantStorageFromEnv(embeddingDim int) (*QdrantStorage, error)
NewQdrantStorageFromEnv creates a QdrantStorage from environment variables Env vars: QDRANT_API_KEY, QDRANT_API_URL, QDRANT_COLLECTION (optional, default: llm_semantic)
func (*QdrantStorage) Close ¶
func (s *QdrantStorage) Close() error
func (*QdrantStorage) DeleteByFilePath ¶
func (*QdrantStorage) DeleteCollection ¶
func (s *QdrantStorage) DeleteCollection() error
DeleteCollection removes the collection (used for testing cleanup)
func (*QdrantStorage) List ¶
func (s *QdrantStorage) List(ctx context.Context, opts ListOptions) ([]Chunk, error)
func (*QdrantStorage) Search ¶
func (s *QdrantStorage) Search(ctx context.Context, queryEmbedding []float32, opts SearchOptions) ([]SearchResult, error)
func (*QdrantStorage) Stats ¶
func (s *QdrantStorage) Stats(ctx context.Context) (*IndexStats, error)
type SQLiteStorage ¶
type SQLiteStorage struct {
// contains filtered or unexported fields
}
SQLiteStorage implements the Storage interface using SQLite
func NewSQLiteStorage ¶
func NewSQLiteStorage(dbPath string, embeddingDim int) (*SQLiteStorage, error)
NewSQLiteStorage creates a new SQLite-based storage
func (*SQLiteStorage) Close ¶
func (s *SQLiteStorage) Close() error
func (*SQLiteStorage) DeleteByFilePath ¶
func (*SQLiteStorage) List ¶
func (s *SQLiteStorage) List(ctx context.Context, opts ListOptions) ([]Chunk, error)
func (*SQLiteStorage) Search ¶
func (s *SQLiteStorage) Search(ctx context.Context, queryEmbedding []float32, opts SearchOptions) ([]SearchResult, error)
func (*SQLiteStorage) Stats ¶
func (s *SQLiteStorage) Stats(ctx context.Context) (*IndexStats, error)
type SearchOptions ¶
type SearchOptions struct {
TopK int // Maximum number of results to return
Threshold float32 // Minimum similarity score (0.0 - 1.0)
Type string // Filter by chunk type
PathFilter string // Filter by file path pattern (glob)
}
SearchOptions configures how vector search is performed
type SearchResult ¶
type SearchResult struct {
Chunk Chunk `json:"chunk"`
Score float32 `json:"score"`
Embedding []float32 `json:"-"` // Not included in JSON output
}
SearchResult represents a chunk with its similarity score
func (SearchResult) MinimalJSON ¶
func (sr SearchResult) MinimalJSON() string
MinimalJSON returns a compact JSON representation for --min output
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
Searcher orchestrates semantic search across the index
func NewSearcher ¶
func NewSearcher(storage Storage, embedder EmbedderInterface) *Searcher
NewSearcher creates a new Searcher with the given storage and embedder
func (*Searcher) Search ¶
func (s *Searcher) Search(ctx context.Context, query string, opts SearchOptions) ([]SearchResult, error)
Search performs semantic search using the query text
func (*Searcher) SearchMultiple ¶
func (s *Searcher) SearchMultiple(ctx context.Context, queries []string, opts SearchOptions) ([]SearchResult, error)
SearchMultiple performs search with multiple query terms and combines results
type SemanticError ¶
SemanticError provides structured error information
func ErrChunkingFailure ¶
func ErrChunkingFailure(filePath string, cause error) *SemanticError
ErrChunkingFailure creates an error for code chunking failures
func ErrConnectionFailed ¶
func ErrConnectionFailed(cause error) *SemanticError
ErrConnectionFailed creates an error for API connection failures
func ErrEmbeddingFailure ¶
func ErrEmbeddingFailure(cause error) *SemanticError
ErrEmbeddingFailure creates an error for embedding generation failures
func ErrIndexNotFound ¶
func ErrIndexNotFound() *SemanticError
ErrIndexNotFound creates an error for when the index doesn't exist
func ErrInvalidPath ¶
func ErrInvalidPath(path string, cause error) *SemanticError
ErrInvalidPath creates an error for invalid file paths
func ErrInvalidQuery ¶
func ErrInvalidQuery(query string) *SemanticError
ErrInvalidQuery creates an error for invalid search queries
func ErrStorageFailure ¶
func ErrStorageFailure(operation string, cause error) *SemanticError
ErrStorageFailure creates an error for storage-related issues
func (*SemanticError) Error ¶
func (e *SemanticError) Error() string
func (*SemanticError) FormatWithHint ¶
func (e *SemanticError) FormatWithHint() string
FormatWithHint returns the error message with hint if available
func (*SemanticError) Unwrap ¶
func (e *SemanticError) Unwrap() error
func (*SemanticError) WithHint ¶
func (e *SemanticError) WithHint(hint string) *SemanticError
WithHint adds a helpful hint to the error
type Storage ¶
type Storage interface {
// Create stores a new chunk with its embedding
Create(ctx context.Context, chunk Chunk, embedding []float32) error
// Read retrieves a chunk by its ID
Read(ctx context.Context, id string) (*Chunk, error)
// Update replaces an existing chunk and its embedding
Update(ctx context.Context, chunk Chunk, embedding []float32) error
// Delete removes a chunk by its ID
Delete(ctx context.Context, id string) error
// DeleteByFilePath removes all chunks for a given file path
DeleteByFilePath(ctx context.Context, filePath string) (int, error)
// List retrieves chunks based on filter options
List(ctx context.Context, opts ListOptions) ([]Chunk, error)
// Search finds chunks similar to the query embedding
Search(ctx context.Context, queryEmbedding []float32, opts SearchOptions) ([]SearchResult, error)
// Stats returns statistics about the stored index
Stats(ctx context.Context) (*IndexStats, error)
// Close releases any resources held by the storage
Close() error
}
Storage defines the interface for persisting and querying chunks with embeddings
type StreamingChunkProcessor ¶
type StreamingChunkProcessor struct {
// contains filtered or unexported fields
}
StreamingChunkProcessor processes chunks without loading all into memory
func NewStreamingChunkProcessor ¶
func NewStreamingChunkProcessor(batchSize int, processor func([]Chunk) error) *StreamingChunkProcessor
NewStreamingChunkProcessor creates a new streaming processor
func (*StreamingChunkProcessor) Process ¶
func (p *StreamingChunkProcessor) Process(chunks <-chan Chunk) error
Process processes chunks in batches
type UpdateOptions ¶
type UpdateOptions struct {
Includes []string // Glob patterns to include
Excludes []string // Patterns to exclude
}
UpdateOptions configures incremental update behavior