mem

package
v0.0.0-...-085a19f Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModuleMemory = fx.Module("memory",
	fx.Provide(NewSimpleMemory))

ModuleMemory provides a memory for messages

Functions

This section is empty.

Types

type Conversation

type Conversation struct {
	ID       string            `json:"id"`
	Messages []*schema.Message `json:"messages"`
	// contains filtered or unexported fields
}

Conversation is a conversation in the memory.

func (*Conversation) Append

func (c *Conversation) Append(msg *schema.Message)

Append appends a message to the conversation.

func (*Conversation) GetFullMessages

func (c *Conversation) GetFullMessages() []*schema.Message

GetFullMessages returns all messages in the conversation.

func (*Conversation) GetMessages

func (c *Conversation) GetMessages() []*schema.Message

GetMessages returns the last messages in the conversation.

type SimpleMemory

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

SimpleMemory is a simple in-memory memory implementation. It stores conversations in a directory.

func CreateConfiguredSimpleMemory

func CreateConfiguredSimpleMemory(cfg SimpleMemoryConfig) (*SimpleMemory, error)

CreateConfiguredSimpleMemory creates a new SimpleMemory instance with the given configuration

func NewSimpleMemory

func NewSimpleMemory() (*SimpleMemory, error)

NewSimpleMemory creates a new SimpleMemory instance

func (*SimpleMemory) DeleteConversation

func (m *SimpleMemory) DeleteConversation(id string) error

DeleteConversation deletes a conversation from the memory.

func (*SimpleMemory) GetConversation

func (m *SimpleMemory) GetConversation(id string, createIfNotExist bool) *Conversation

GetConversation returns the conversation with the given ID. If the conversation does not exist and createIfNotExist is true, a new conversation is created.

func (*SimpleMemory) ListConversations

func (m *SimpleMemory) ListConversations() []string

ListConversations returns a list of conversation IDs.

type SimpleMemoryConfig

type SimpleMemoryConfig struct {
	Dir           string
	MaxWindowSize int
}

SimpleMemoryConfig is the configuration for SimpleMemory

Jump to

Keyboard shortcuts

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