Documentation
¶
Overview ¶
Package facts implements baifo's long-term memory store.
Index ¶
- Variables
- type FactEntry
- type Store
- func (s *Store) AddManualEntry(ctx context.Context, appName, userID, content, author, category string) (uint64, error)
- func (s *Store) AddSessionToMemory(ctx context.Context, sess session.Session) error
- func (s *Store) DeleteMemory(ctx context.Context, appName, userID string, entryID int) error
- func (s *Store) List(appName, userID string) ([]FactEntry, error)
- func (s *Store) SearchMemory(ctx context.Context, req *memory.SearchRequest) (*memory.SearchResponse, error)
- func (s *Store) SearchWithID(ctx context.Context, req *memory.SearchRequest) ([]memorytypes.EntryWithID, error)
- func (s *Store) UpdateMemory(ctx context.Context, appName, userID string, entryID int, newContent string) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
AddSessionToMemory persists every textual event of the given session as a FactEntry.
func (*Store) DeleteMemory ¶
DeleteMemory removes an entry by id.
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.