Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHistoryHook ¶
func NewHistoryHook(mem llm.History) llm.BeforeGenerateHook
NewHistoryHook returns a BeforeGenerateHook that reads the session history from the given History store and appends it to CurrentMessages.
Types ¶
type DiskBacked ¶
type DiskBacked struct {
// contains filtered or unexported fields
}
DiskBacked provides a persistence-backed implementation of the WorkingMemory interface. It loads historical sessions on instantiation and saves the state to disk upon every Append.
func NewDiskBacked ¶
func NewDiskBacked(path string, processors ...Processor) (*DiskBacked, error)
NewDiskBacked initializes a new DiskBacked history repository loaded from the provided directory.
func (*DiskBacked) Append ¶
Append adds a new message to the existing session history, runs processors, and writes the state to disk.
type InMemory ¶
type InMemory struct {
// contains filtered or unexported fields
}
InMemory provides a naive, memory-backed implementation of the WorkingMemory interface.
func NewInMemory ¶
NewInMemory initializes a new InMemory history repository.
type Processor ¶
type Processor interface {
Process(ctx context.Context, sessionID string, msgs []llm.Message) ([]llm.Message, error)
}
Processor inspects, mutates, or summarizes a slice of working memory. Processors can be chained together.
func NewTruncationCompactor ¶
NewTruncationCompactor creates a basic compactor that ensures the history size (number of messages) never exceeds maxMessages. If it is exceeded, it preserves the newest messages up to the limit.
type ProcessorFunc ¶
type ProcessorFunc func(ctx context.Context, sessionID string, msgs []llm.Message) ([]llm.Message, error)
ProcessorFunc allows simple functions to satisfy the Processor interface
type WorkingMemory ¶
WorkingMemory encapsulates context-window management for LLM sessions.