Documentation
¶
Index ¶
- Constants
- type Index
- func (i *Index) All(ctx context.Context, yield func(model.SectionID) bool) error
- func (i *Index) DeleteByID(ctx context.Context, ids ...model.SectionID) error
- func (i *Index) DeleteBySource(ctx context.Context, source *url.URL) error
- func (i *Index) GenerateSnapshot(ctx context.Context) (io.ReadCloser, error)
- func (i *Index) Index(ctx context.Context, document model.Document, funcs ...index.OptionFunc) error
- func (i *Index) RestoreSnapshot(ctx context.Context, r io.Reader) error
- func (i *Index) Search(ctx context.Context, query string, opts index.SearchOptions) ([]*index.SearchResult, error)
- func (i *Index) Semantic() bool
- type OptionFunc
- type Options
- type SnapshottedMetadata
- type SnapshottedRecord
Constants ¶
const DefaultMaxWords int = 500
DefaultMaxWords bounds, by default, the number of words per chunk sent to the embeddings model.
const DefaultVectorSize int = 768
DefaultVectorSize is the default dimension of the vec0 embedding column, matching common 768-dimension embedding models.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
func NewIndex ¶
NewIndex creates a sqlite-vec backed vector index on top of the given connection. The connection remains owned by the caller. The embeddings model (WithEmbeddingsModel) and vector size (WithVectorSize) are recorded in the index on first use; reopening an existing index with a different model or size is rejected to prevent silently mixing incompatible vectors.
func (*Index) DeleteByID ¶
DeleteByID implements index.Index.
func (*Index) DeleteBySource ¶
DeleteBySource implements index.Index.
func (*Index) GenerateSnapshot ¶
GenerateSnapshot implements snapshot.Snapshotable.
func (*Index) Index ¶
func (i *Index) Index(ctx context.Context, document model.Document, funcs ...index.OptionFunc) error
Index implements index.Index.
func (*Index) RestoreSnapshot ¶
RestoreSnapshot implements snapshot.Snapshotable.
type OptionFunc ¶ added in v0.0.2
type OptionFunc func(opts *Options)
func WithEmbeddingsModel ¶ added in v0.0.2
func WithEmbeddingsModel(model string) OptionFunc
WithEmbeddingsModel records the embeddings model backing the index.
func WithMaxWords ¶ added in v0.0.2
func WithMaxWords(maxWords int) OptionFunc
WithMaxWords bounds the size of the chunks sent to the embeddings model.
func WithVectorSize ¶ added in v0.0.2
func WithVectorSize(size int) OptionFunc
WithVectorSize sets the dimension of the vec0 embedding column.
type Options ¶ added in v0.0.2
type Options struct {
// EmbeddingsModel identifies the embeddings model. It is recorded in the
// index and opening an existing index with a different model is rejected
// (the stored vectors would no longer be comparable).
EmbeddingsModel string
// VectorSize is the dimension of the vec0 embedding column (default
// DefaultVectorSize). It is recorded in the index; opening an existing
// index with a different size is rejected.
VectorSize int
// MaxWords bounds the size of the chunks sent to the embeddings model.
MaxWords int
}
Options configures a sqlite-vec Index.
func NewOptions ¶ added in v0.0.2
func NewOptions(funcs ...OptionFunc) *Options
type SnapshottedMetadata ¶
type SnapshottedMetadata struct {
Model string
}