store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockStore

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

MockStore is an in-memory implementation of Store for testing.

func NewMockStore

func NewMockStore() *MockStore

NewMockStore creates a new mock store.

func (*MockStore) Close

func (m *MockStore) Close() error

func (*MockStore) Delete

func (m *MockStore) Delete(_ context.Context, id string) error

func (*MockStore) EnsureCollection

func (m *MockStore) EnsureCollection(_ context.Context) error

func (*MockStore) FindDuplicates

func (m *MockStore) FindDuplicates(_ context.Context, vector []float32, threshold float64) ([]models.SearchResult, error)

func (*MockStore) Get

func (m *MockStore) Get(_ context.Context, id string) (*models.Memory, error)

func (*MockStore) List

func (m *MockStore) List(_ context.Context, filters *SearchFilters, limit uint64, _ uint64) ([]models.Memory, error)

func (*MockStore) Search

func (m *MockStore) Search(_ context.Context, vector []float32, limit uint64, filters *SearchFilters) ([]models.SearchResult, error)

func (*MockStore) Stats

func (*MockStore) UpdateAccessMetadata

func (m *MockStore) UpdateAccessMetadata(_ context.Context, id string) error

func (*MockStore) Upsert

func (m *MockStore) Upsert(_ context.Context, memory models.Memory, vector []float32) error

type QdrantStore

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

QdrantStore implements Store using Qdrant's gRPC API.

func NewQdrantStore

func NewQdrantStore(host string, port int, collection string, dimension uint64, useTLS bool, logger *slog.Logger) (*QdrantStore, error)

NewQdrantStore creates a new Qdrant store connection.

func (*QdrantStore) Close

func (q *QdrantStore) Close() error

func (*QdrantStore) Delete

func (q *QdrantStore) Delete(ctx context.Context, id string) error

func (*QdrantStore) EnsureCollection

func (q *QdrantStore) EnsureCollection(ctx context.Context) error

func (*QdrantStore) FindDuplicates

func (q *QdrantStore) FindDuplicates(ctx context.Context, vector []float32, threshold float64) ([]models.SearchResult, error)

func (*QdrantStore) Get

func (q *QdrantStore) Get(ctx context.Context, id string) (*models.Memory, error)

func (*QdrantStore) List

func (q *QdrantStore) List(ctx context.Context, filters *SearchFilters, limit uint64, offset uint64) ([]models.Memory, error)

func (*QdrantStore) Search

func (q *QdrantStore) Search(ctx context.Context, vector []float32, limit uint64, filters *SearchFilters) ([]models.SearchResult, error)

func (*QdrantStore) Stats

func (*QdrantStore) UpdateAccessMetadata

func (q *QdrantStore) UpdateAccessMetadata(ctx context.Context, id string) error

func (*QdrantStore) Upsert

func (q *QdrantStore) Upsert(ctx context.Context, memory models.Memory, vector []float32) error

type SearchFilters

type SearchFilters struct {
	Type       *models.MemoryType       `json:"type,omitempty"`
	Scope      *models.MemoryScope      `json:"scope,omitempty"`
	Visibility *models.MemoryVisibility `json:"visibility,omitempty"`
	Project    *string                  `json:"project,omitempty"`
	Tags       []string                 `json:"tags,omitempty"`
	Source     *string                  `json:"source,omitempty"`
}

SearchFilters allows filtering search results.

type Store

type Store interface {
	// EnsureCollection creates the vector collection if it doesn't exist.
	EnsureCollection(ctx context.Context) error

	// Upsert inserts or updates a memory with its embedding vector.
	Upsert(ctx context.Context, memory models.Memory, vector []float32) error

	// Search finds memories similar to the query vector.
	Search(ctx context.Context, vector []float32, limit uint64, filters *SearchFilters) ([]models.SearchResult, error)

	// Get retrieves a single memory by ID.
	Get(ctx context.Context, id string) (*models.Memory, error)

	// Delete removes a memory by ID.
	Delete(ctx context.Context, id string) error

	// List returns memories matching the given filters.
	List(ctx context.Context, filters *SearchFilters, limit uint64, offset uint64) ([]models.Memory, error)

	// FindDuplicates returns memories with cosine similarity above the threshold.
	FindDuplicates(ctx context.Context, vector []float32, threshold float64) ([]models.SearchResult, error)

	// UpdateAccessMetadata increments access count and updates last_accessed time.
	UpdateAccessMetadata(ctx context.Context, id string) error

	// Stats returns collection statistics.
	Stats(ctx context.Context) (*models.CollectionStats, error)

	// Close cleans up resources.
	Close() error
}

Store defines the interface for memory persistence with vector search.

Jump to

Keyboard shortcuts

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