store

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultListLimit           = 100
	DefaultKeywordLimit        = 10
	DefaultSemanticLimit       = 3
	DefaultSemanticMaxDistance = 0.80
	DefaultRecentWindow        = 2000
	DefaultRecallCandidateMin  = 64
	MaxListLimit               = 1000
	MaxSearchLimit             = 100
	MaxSemanticLimit           = 100
	MaxRecentWindow            = 5000
	MaxRecallCandidates        = 1000
)

Variables

View Source
var ErrDatabaseNotFound = errors.New("database not found")
View Source
var ErrMemoryNotFound = errors.New("memory not found")
View Source
var ErrMigrationRequired = errors.New("database needs an automatic update but is not writable")

Functions

func CheckCompatible

func CheckCompatible(db *sql.DB) error

func IsDatabaseNotFound

func IsDatabaseNotFound(err error) bool

func IsMigrationRequired

func IsMigrationRequired(err error) bool

func Migrate

func Migrate(db *sql.DB) error

func Open

func Open(path string) (*sql.DB, error)

func OpenExisting

func OpenExisting(path string) (*sql.DB, error)

func OpenExistingWritable

func OpenExistingWritable(path string) (*sql.DB, error)

Types

type EmbeddingIdentity

type EmbeddingIdentity struct {
	ModelID        string
	ModelRevision  string
	ManifestSHA256 string
	Dimension      int
}

type IndexHealth

type IndexHealth struct {
	Memories          int64
	Indexed           int64
	Stale             int64
	MissingEmbeddings int64
}

type Repository

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

func NewRepository

func NewRepository(db *sql.DB) *Repository

func (*Repository) AddMemory

func (r *Repository) AddMemory(ctx context.Context, text string, embedding []float32, identity EmbeddingIdentity) (domain.Memory, error)

func (*Repository) CountMemories

func (r *Repository) CountMemories(ctx context.Context) (int64, error)

func (*Repository) EditMemory

func (r *Repository) EditMemory(ctx context.Context, id int64, text string, embedding []float32, identity EmbeddingIdentity) (domain.Memory, error)

func (*Repository) ForgetMemory

func (r *Repository) ForgetMemory(ctx context.Context, id int64) error

func (*Repository) GetMemory

func (r *Repository) GetMemory(ctx context.Context, id int64) (domain.Memory, error)

func (*Repository) IndexHealth

func (r *Repository) IndexHealth(ctx context.Context, identity EmbeddingIdentity) (IndexHealth, error)

func (*Repository) KeywordSearch

func (r *Repository) KeywordSearch(ctx context.Context, query string, limit int) ([]domain.Memory, error)

func (*Repository) ListMemories

func (r *Repository) ListMemories(ctx context.Context, limit int) ([]domain.Memory, error)

func (*Repository) ListMemoriesNeedingIndex

func (r *Repository) ListMemoriesNeedingIndex(ctx context.Context, identity EmbeddingIdentity) ([]domain.Memory, error)

func (*Repository) RecallSearch

func (r *Repository) RecallSearch(ctx context.Context, query string, limit int, recentWindow int, candidateLimit int) ([]domain.Memory, error)

func (*Repository) SemanticSearch

func (r *Repository) SemanticSearch(ctx context.Context, embedding []float32, limit int, identity EmbeddingIdentity, maxDistance float64) ([]SemanticHit, error)

func (*Repository) UpsertMemoryEmbedding

func (r *Repository) UpsertMemoryEmbedding(ctx context.Context, id int64, embedding []float32, identity EmbeddingIdentity) error

type SemanticHit

type SemanticHit struct {
	Memory   domain.Memory
	Distance float64
}

Jump to

Keyboard shortcuts

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