memory

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityMemory

type EntityMemory struct {
	ShortTerm
	// contains filtered or unexported fields
}

EntityMemory extends ShortTerm with entity-specific fact storage.

func NewEntityMemory

func NewEntityMemory(limit int) *EntityMemory

NewEntityMemory creates a new EntityMemory with the given entry limit.

func (*EntityMemory) GetAllEntities

func (e *EntityMemory) GetAllEntities(_ context.Context) ([]string, error)

GetAllEntities returns all entity names that have stored facts.

func (*EntityMemory) GetFacts

func (e *EntityMemory) GetFacts(_ context.Context, entity string) ([]string, error)

GetFacts retrieves all facts stored for an entity.

func (*EntityMemory) SaveFact

func (e *EntityMemory) SaveFact(_ context.Context, entity string, fact string) error

SaveFact stores a fact about an entity.

type EntityStore

type EntityStore interface {
	Store
	SaveFact(ctx context.Context, entity string, fact string) error
	GetFacts(ctx context.Context, entity string) ([]string, error)
	GetAllEntities(ctx context.Context) ([]string, error)
}

EntityStore extends Store with entity-specific fact storage and retrieval.

type Entry

type Entry struct {
	Role     string         `json:"role"`
	Content  string         `json:"content"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

Entry represents a single memory entry with role, content, and metadata.

type ShortTerm

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

ShortTerm is an in-memory circular buffer store for recent conversation entries.

func NewShortTerm

func NewShortTerm(limit int) *ShortTerm

NewShortTerm creates a new ShortTerm store with the given entry limit.

func (*ShortTerm) Clear

func (s *ShortTerm) Clear(_ context.Context) error

Clear removes all entries from short-term memory.

func (*ShortTerm) Save

func (s *ShortTerm) Save(_ context.Context, key string, entry Entry) error

Save stores an entry in the short-term memory buffer.

func (*ShortTerm) Search

func (s *ShortTerm) Search(_ context.Context, key string, query string, limit int) ([]Entry, error)

Search retrieves the most recent entries from short-term memory.

type Store

type Store interface {
	Save(ctx context.Context, key string, entry Entry) error
	Search(ctx context.Context, key string, query string, limit int) ([]Entry, error)
	Clear(ctx context.Context) error
}

Store is the interface for basic memory storage and retrieval.

Jump to

Keyboard shortcuts

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