Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions cmd/llmem/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ func loadConfig() (*config.Config, error) {
return cfg, nil
}

// openStore creates a MemoryStore and returns it with a cleanup function.
// Vec is disabled — use openStoreWithVec for operations that need embeddings.
// openStore creates a MemoryStore with vector search enabled.
func openStore() (*store.MemoryStore, error) {
cfg := store.StoreConfig{
DBPath: resolveDBPath(),
DisableVec: true,
DBPath: resolveDBPath(),
}
ms, err := store.NewMemoryStore(cfg)
if err != nil {
Expand All @@ -97,19 +95,6 @@ func openStore() (*store.MemoryStore, error) {
return ms, nil
}

// openStoreWithVec creates a MemoryStore with vec0 enabled for embedding operations.
func openStoreWithVec() (*store.MemoryStore, error) {
cfg := store.StoreConfig{
DBPath: resolveDBPath(),
DisableVec: false,
}
ms, err := store.NewMemoryStore(cfg)
if err != nil {
return nil, fmt.Errorf("llmem: failed to initialize store with vec: %w", err)
}
return ms, nil
}

// openAdapter creates an OpenCodeAdapter from configuration.
// If the OpenCode DB path is empty or the DB cannot be opened, returns nil
// (the coordinator gracefully handles a nil adapter by returning no_transcript).
Expand Down Expand Up @@ -1208,7 +1193,7 @@ func backfillEmbeddingsCmd() *cobra.Command {
Use: "backfill-embeddings",
Short: "Generate embeddings for memories that lack them",
RunE: func(cmd *cobra.Command, args []string) error {
ms, err := openStoreWithVec()
ms, err := openStore()
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/pressly/goose/v3 v3.27.1
github.com/spf13/cobra v1.10.2
github.com/viant/sqlite-vec v0.3.0
gopkg.in/yaml.v3 v3.0.1
modernc.org/sqlite v1.50.0
)
Expand All @@ -20,6 +21,7 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/viant/vec v0.2.3 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.43.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/viant/sqlite-vec v0.3.0 h1:D0wCrkJ0KsO3sanmHV/m+58UwCZMFxU0wcK8LsYk00o=
github.com/viant/sqlite-vec v0.3.0/go.mod h1:SA89LGdU/cxpc/gsvat2MYtJYrv3bg9mtW/uHMs2nBs=
github.com/viant/vec v0.2.3 h1:NMWW1WtBXJ3Q47LHMGrXZAb6pVL3MjJfWVcEMD8V2t8=
github.com/viant/vec v0.2.3/go.mod h1:d1coA6/d5WBePJe0nDhgE7aRYkMd7CMiRWSNid3tvds=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
Expand Down
1 change: 0 additions & 1 deletion internal/store/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
var (
reNonWord = regexp.MustCompile(`[^\w]+`)
reValidTypeName = regexp.MustCompile(`^[a-z][a-z0-9_]*$`)
reVecDimensions = regexp.MustCompile(`float\[(\d+)\]`)
)

// nowUTC returns the current UTC time formatted as ISO 8601 (RFC 3339).
Expand Down
6 changes: 3 additions & 3 deletions internal/store/models.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package store provides a SQLite-backed memory store with FTS5 full-text
// search and optional vec0 vector search for the LLMem project.
// search and vector search via sqlite-vec for the LLMem project.
package store

// Memory represents a single memory record in the store.
Expand Down Expand Up @@ -167,11 +167,11 @@ type StoreConfig struct {
// If empty, defaults to ~/.config/llmem/memory.db.
DBPath string

// VecDimensions is the dimensionality for the vec0 embedding index.
// VecDimensions is the dimensionality for the embedding index.
// Defaults to 768 if zero. Must be positive.
VecDimensions int

// DisableVec skips vec0 virtual table creation and vector search.
// DisableVec skips vec virtual table creation and vector search.
DisableVec bool

// RegisteredTypes lists the memory types to register at construction.
Expand Down
Loading
Loading