memory

package
v0.0.99 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package memory contains implementations for managing conversation data and facilitating the persistence of state between chain or agent calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Combined added in v0.0.5

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

func NewCombined added in v0.0.5

func NewCombined(memories ...schema.Memory) (*Combined, error)

func (*Combined) Clear added in v0.0.5

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

func (*Combined) LoadMemoryVariables added in v0.0.5

func (m *Combined) LoadMemoryVariables(ctx context.Context, inputs map[string]any) (map[string]any, error)

func (*Combined) MemoryKeys added in v0.0.21

func (m *Combined) MemoryKeys() []string

func (*Combined) SaveContext added in v0.0.5

func (m *Combined) SaveContext(ctx context.Context, inputs map[string]any, outputs map[string]any) error

type ConversationBuffer added in v0.0.6

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

ConversationBuffer is a memory type that manages conversation buffers.

func NewConversationBuffer added in v0.0.6

func NewConversationBuffer(optFns ...func(o *ConversationBufferOptions)) *ConversationBuffer

NewConversationBuffer creates a new instance of ConversationBuffer memory type.

func (*ConversationBuffer) Clear added in v0.0.6

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

Clear clears the chat message history.

func (*ConversationBuffer) LoadMemoryVariables added in v0.0.6

func (m *ConversationBuffer) LoadMemoryVariables(ctx context.Context, inputs map[string]any) (map[string]any, error)

LoadMemoryVariables returns key-value pairs given the text input to the chain.

func (*ConversationBuffer) MemoryKeys added in v0.0.21

func (m *ConversationBuffer) MemoryKeys() []string

MemoryKeys returns the memory keys for ConversationBuffer.

func (*ConversationBuffer) SaveContext added in v0.0.6

func (m *ConversationBuffer) SaveContext(ctx context.Context, inputs map[string]any, outputs map[string]any) error

SaveContext saves the input and output messages to the chat message history.

type ConversationBufferOptions added in v0.0.6

type ConversationBufferOptions struct {
	HumanPrefix        string
	AIPrefix           string
	MemoryKey          string
	InputKey           string
	OutputKey          string
	ReturnMessages     bool
	ChatMessageHistory schema.ChatMessageHistory

	// Size of the interactions window
	K uint
}

ConversationBufferOptions contains options for configuring the ConversationBuffer memory type.

type ConversationTokenBuffer added in v0.0.89

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

ConversationTokenBuffer is a memory type that manages conversation token buffers.

func NewConversationTokenBuffer added in v0.0.89

func NewConversationTokenBuffer(tokenizer schema.Tokenizer, optFns ...func(o *ConversationTokenBufferOptions)) *ConversationTokenBuffer

NewConversationTokenBuffer creates a new instance of ConversationTokenBuffer memory type.

func (*ConversationTokenBuffer) Clear added in v0.0.89

Clear clears the chat message history.

func (*ConversationTokenBuffer) LoadMemoryVariables added in v0.0.89

func (m *ConversationTokenBuffer) LoadMemoryVariables(ctx context.Context, inputs map[string]any) (map[string]any, error)

LoadMemoryVariables returns key-value pairs given the text input to the chain.

func (*ConversationTokenBuffer) MemoryKeys added in v0.0.89

func (m *ConversationTokenBuffer) MemoryKeys() []string

MemoryKeys returns the memory keys for ConversationTokenBuffer.

func (*ConversationTokenBuffer) SaveContext added in v0.0.89

func (m *ConversationTokenBuffer) SaveContext(ctx context.Context, inputs map[string]any, outputs map[string]any) error

SaveContext saves the input and output messages to the chat message history.

type ConversationTokenBufferOptions added in v0.0.89

type ConversationTokenBufferOptions struct {
	HumanPrefix        string
	AIPrefix           string
	MemoryKey          string
	InputKey           string
	OutputKey          string
	ReturnMessages     bool
	ChatMessageHistory schema.ChatMessageHistory

	MaxTokenLimit uint
}

ConversationTokenBufferOptions contains options for configuring the ConversationTokenBuffer memory type.

type Readonly added in v0.0.5

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

func NewReadonly added in v0.0.5

func NewReadonly(memory schema.Memory) Readonly

func (*Readonly) Clear added in v0.0.5

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

func (*Readonly) LoadMemoryVariables added in v0.0.5

func (m *Readonly) LoadMemoryVariables(ctx context.Context, inputs map[string]any) (map[string]any, error)

func (*Readonly) MemoryKeys added in v0.0.21

func (m *Readonly) MemoryKeys() []string

func (*Readonly) SaveContext added in v0.0.5

func (m *Readonly) SaveContext(ctx context.Context, inputs map[string]any, outputs map[string]any) error

type Simple

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

func NewSimple

func NewSimple() Simple

func (*Simple) Clear

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

func (*Simple) LoadMemoryVariables

func (m *Simple) LoadMemoryVariables(ctx context.Context, inputs map[string]any) (map[string]any, error)

func (*Simple) MemoryKeys added in v0.0.21

func (m *Simple) MemoryKeys() []string

func (*Simple) SaveContext

func (m *Simple) SaveContext(ctx context.Context, inputs map[string]any, outputs map[string]any) error

Jump to

Keyboard shortcuts

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