memory

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderName = "memory"
	ToolSearch   = "memory_search"
)

Variables

View Source
var ErrInvalidChange = errors.New("invalid memory change")

Functions

This section is empty.

Types

type Batch

type Batch struct {
	UserID      string          `json:"-"`
	Scope       db.MemoryScope  `json:"scope"`
	WorkspaceID string          `json:"workspaceId,omitempty"`
	ThreadID    string          `json:"threadId"`
	TurnID      string          `json:"turnId"`
	TurnStatus  db.TurnStatus   `json:"turnStatus"`
	TurnError   string          `json:"turnError,omitempty"`
	Facts       []Fact          `json:"facts"`
	Existing    []db.MemoryRow  `json:"existing"`
	Cursor      db.MemoryCursor `json:"-"`
	Entries     int             `json:"-"`
}

type Fact

type Fact struct {
	Source db.MemorySource `json:"source"`
	Data   json.RawMessage `json:"data"`
}

type Manager

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

func New

func New(store *db.DB, model llm.Client, opts Options) (*Manager, error)

func (*Manager) Edit

func (m *Manager) Edit(user, id, text string) (db.MemoryRow, error)

func (*Manager) Forget

func (m *Manager) Forget(user, id string) error

func (*Manager) Invoke

func (m *Manager) Invoke(ctx context.Context, caller tools.Caller, _ string, arguments map[string]any) (tools.Result, error)

func (*Manager) List

func (m *Manager) List(user string, scope db.MemoryScope, workspaceID string) ([]db.MemoryRow, error)

func (*Manager) Move

func (m *Manager) Move(user, id string) (db.MemoryRow, error)

func (*Manager) Name

func (*Manager) Name() (string, string)

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

func (*Manager) RunOnce

func (m *Manager) RunOnce(ctx context.Context) error

RunOnce takes one batch for each user on the shard; a user whose extraction fails does not hold up the others.

func (*Manager) Search added in v0.5.0

func (m *Manager) Search(user, query, workspaceID string, limit int) ([]db.MemoryRow, error)

Search finds active memories by words for the user: those of a workspace and the global ones, or with no workspace all of them.

func (*Manager) Snapshot

func (m *Manager) Snapshot(user, workspaceID string, budget int) (*Snapshot, error)

func (*Manager) Status

func (m *Manager) Status(user string) (db.MemoryStatus, error)

func (*Manager) ToolList

func (m *Manager) ToolList(context.Context) ([]*tools.Spec, error)

type Operation

type Operation struct {
	Action  string            `json:"action"`
	Scope   string            `json:"scope,omitempty"`
	ID      string            `json:"id,omitempty"`
	Topic   string            `json:"topic,omitempty"`
	Kind    string            `json:"kind,omitempty"`
	Text    string            `json:"text,omitempty"`
	Sources []db.MemorySource `json:"sources"`
}

type Options

type Options struct {
	Model    llm.Model
	Generate bool
	Use      bool
	// ClientFor gives the client that extracts a user's memories, so that it runs on the user's own key; the model
	// passed to New checks the limits. Without it users share that model.
	ClientFor func(user string) (llm.Client, error)
}

type SearchArgs

type SearchArgs struct {
	Query string `json:"query" jsonschema:"Words to look for in a memory's topic and text."`
}

func (SearchArgs) Constrain

func (SearchArgs) Constrain(s *jsonschema.Schema)

type SearchResult

type SearchResult struct {
	Memories []db.MemoryReference `json:"memories"`
}

type Snapshot added in v0.5.0

type Snapshot struct {
	Entries []db.MemoryReference
	Text    string
}

Jump to

Keyboard shortcuts

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