memory

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRequest

type AddRequest struct {
	AgentID  string
	Content  string
	Metadata map[string]any
	Embed    bool // whether to generate embedding
}

AddRequest is the request to add a memory.

type Backend

type Backend interface {
	MemoryStore
	Initialize(ctx context.Context, config *BackendConfig) error
	Close() error
	Health() error
}

Backend is a MemoryStore with lifecycle management.

type BackendConfig

type BackendConfig struct {
	Type    string         `json:"type"` // sqlite, postgres, mem0, chroma
	DSN     string         `json:"dsn,omitempty"`
	Options map[string]any `json:"options,omitempty"`
}

BackendConfig configures a memory backend.

type ListOptions

type ListOptions struct {
	Limit  int
	Offset int
}

ListOptions configures a memory list operation.

type Memory

type Memory struct {
	ID        string
	AgentID   string
	Content   string
	Embedding []float64
	Metadata  map[string]any
	CreatedAt time.Time
	UpdatedAt time.Time
	Score     float64 // relevance score for search results
}

Memory represents a single memory entry.

type MemoryStore

type MemoryStore interface {
	Add(ctx context.Context, req *AddRequest) (*Memory, error)
	Get(ctx context.Context, id string) (*Memory, error)
	Update(ctx context.Context, id string, req *UpdateRequest) error
	Delete(ctx context.Context, id string) error
	Search(ctx context.Context, query string, opts *SearchOptions) ([]*Memory, error)
	SearchSimilar(ctx context.Context, embedding []float64, opts *SearchOptions) ([]*Memory, error)
	ListByAgent(ctx context.Context, agentID string, opts *ListOptions) ([]*Memory, error)
	ClearAgentMemory(ctx context.Context, agentID string) error
	BatchAdd(ctx context.Context, reqs []*AddRequest) ([]*Memory, error)
}

MemoryStore defines the interface for agent memory.

type SearchOptions

type SearchOptions struct {
	Limit     int
	Offset    int
	Threshold float64
	Filters   map[string]any
}

SearchOptions configures a memory search.

type SearchResult

type SearchResult struct {
	ID       string
	Score    float64
	Metadata map[string]any
}

SearchResult is a result from a vector similarity search.

type UpdateRequest

type UpdateRequest struct {
	Content  string
	Metadata map[string]any
}

UpdateRequest is the request to update a memory.

type VectorStore

type VectorStore interface {
	Insert(ctx context.Context, id string, embedding []float64, metadata map[string]any) error
	Search(ctx context.Context, embedding []float64, k int) ([]*SearchResult, error)
	Delete(ctx context.Context, id string) error
}

VectorStore handles vector operations for similarity search.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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