Documentation
¶
Overview ¶
Package local implements the material.Searcher interface using local vector embeddings for similarity search over a user's own asset library.
Index ¶
- type Config
- type IndexEntry
- type Searcher
- func (s *Searcher) EntryCount() int
- func (s *Searcher) IndexDir(ctx context.Context, dir string) (int, error)
- func (s *Searcher) IndexFile(ctx context.Context, path string) error
- func (s *Searcher) RemoveStale() int
- func (s *Searcher) SaveIndex() error
- func (s *Searcher) Search(ctx context.Context, req material.Request) (material.Result, error)
- func (s *Searcher) Source() string
- func (s *Searcher) SupportedMediaTypes() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// EmbedEngine is the embedding backend used for vectorizing queries and assets.
EmbedEngine embed.EmbedEngine
// IndexPath is where the vector index is persisted (JSON file).
IndexPath string
}
Config configures the local vector searcher.
type IndexEntry ¶
type IndexEntry struct {
Path string `json:"path"`
MediaType string `json:"media_type"`
Size int64 `json:"size,omitempty"`
ModTime int64 `json:"mod_time,omitempty"` // unix timestamp for change detection
Vector []float32 `json:"vector"`
Metadata map[string]string `json:"metadata,omitempty"`
}
IndexEntry represents a single indexed asset with its vector embedding.
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
Searcher performs vector similarity search over locally indexed assets.
func (*Searcher) EntryCount ¶
EntryCount returns the number of indexed assets.
func (*Searcher) IndexDir ¶
IndexDir scans a directory and indexes all supported files incrementally. Files already indexed with the same size and mod time are skipped.
func (*Searcher) IndexFile ¶
IndexFile adds or updates a single file in the vector index. If the file is already indexed and unchanged (same size + mod time), it is skipped.
func (*Searcher) RemoveStale ¶
RemoveStale removes index entries whose files no longer exist on disk.
func (*Searcher) Search ¶
Search vectorizes the query and finds the most similar assets in the index.