memory

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedMemory

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

BufferedMemory provides an in-memory store that keeps only the last N messages. It wraps an underlying agents.Memory implementation.

func NewBufferedMemory

func NewBufferedMemory(maxSize int) *BufferedMemory

NewBufferedMemory creates a new BufferedMemory instance with a default history key. It initializes an InMemoryStore as the underlying storage.

func (*BufferedMemory) Add

func (m *BufferedMemory) Add(ctx context.Context, role string, content string) error

Add appends a new message to the history, ensuring the buffer size limit is maintained.

func (*BufferedMemory) Clear

func (m *BufferedMemory) Clear(ctx context.Context) error

Clear removes the conversation history from the store.

func (*BufferedMemory) Get

func (m *BufferedMemory) Get(ctx context.Context) ([]Message, error)

Get retrieves the conversation history.

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a single entry in the conversation history.

type SQLiteStore

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

SQLiteStore implements the Memory interface using SQLite as the backend.

func NewSQLiteStore

func NewSQLiteStore(path string) (*SQLiteStore, error)

NewSQLiteStore creates a new SQLite-backed memory store. The path parameter specifies the database file location. If path is ":memory:", the database will be created in-memory.

func (*SQLiteStore) CleanExpired

func (s *SQLiteStore) CleanExpired(ctx context.Context) (int64, error)

CleanExpired removes all expired entries from the store.

func (*SQLiteStore) Clear

func (s *SQLiteStore) Clear() error

Clear implements the Memory interface Clear method.

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

Close closes the database connection.

func (*SQLiteStore) List

func (s *SQLiteStore) List() ([]string, error)

List implements the Memory interface List method.

func (*SQLiteStore) Retrieve

func (s *SQLiteStore) Retrieve(key string) (interface{}, error)

Retrieve implements the Memory interface Retrieve method.

func (*SQLiteStore) Store

func (s *SQLiteStore) Store(key string, value interface{}) error

Store implements the Memory interface Store method.

func (*SQLiteStore) StoreWithTTL

func (s *SQLiteStore) StoreWithTTL(ctx context.Context, key string, value interface{}, ttl time.Duration) error

StoreWithTTL stores a value with a time-to-live duration.

Jump to

Keyboard shortcuts

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