facts

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package facts implements baifo's long-term memory store.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("memory entry not found")

ErrNotFound is returned when an entry id is unknown.

Functions

This section is empty.

Types

type FactEntry

type FactEntry struct {
	ID        uint64    `json:"id"`
	Content   string    `json:"content"`
	Category  string    `json:"category,omitempty"`
	Author    string    `json:"author"`
	Timestamp time.Time `json:"timestamp"`
	Embedding []float32 `json:"-"` // Parsed from BLOB
}

FactEntry is the record.

type Store

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

Store implements memorytypes.MemoryService and memorytypes.ExtendedMemoryService.

func New

func New(db *storage.DB, eng *embeddings.Engine) *Store

New wraps the given storage handle and an optional embeddings engine.

func (*Store) AddManualEntry

func (s *Store) AddManualEntry(ctx context.Context, appName, userID, content, author, category string) (uint64, error)

AddManualEntry inserts a brand-new fact without going through a session.

func (*Store) AddSessionToMemory

func (s *Store) AddSessionToMemory(ctx context.Context, sess session.Session) error

AddSessionToMemory persists every textual event of the given session as a FactEntry.

func (*Store) DeleteMemory

func (s *Store) DeleteMemory(ctx context.Context, appName, userID string, entryID int) error

DeleteMemory removes an entry by id.

func (*Store) List

func (s *Store) List(appName, userID string) ([]FactEntry, error)

List returns every entry of (app, user), newest first.

func (*Store) SearchMemory

func (s *Store) SearchMemory(ctx context.Context, req *memory.SearchRequest) (*memory.SearchResponse, error)

SearchMemory ranks entries by semantic similarity to the query when an embeddings engine is configured, falling back to a case-insensitive substring match across content, category and author otherwise.

func (*Store) SearchWithID

func (s *Store) SearchWithID(ctx context.Context, req *memory.SearchRequest) ([]memorytypes.EntryWithID, error)

SearchWithID is the ExtendedMemoryService variant.

func (*Store) UpdateMemory

func (s *Store) UpdateMemory(ctx context.Context, appName, userID string, entryID int, newContent string) error

UpdateMemory replaces the content of an existing entry.

Jump to

Keyboard shortcuts

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