Documentation
¶
Overview ¶
Package store provides interfaces and implementations for chat and message storage, supporting in-memory and Redis backends for agentic flows.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageStore ¶
type MessageStore interface {
// Messages returns the messages for a tenant and chat ID from context.
Messages(ctx context.Context) []llms.Message
// Add adds one or more messages to the chat history for a tenant and chat ID from context.
// Multiple messages are added atomically for better performance and consistency.
Add(ctx context.Context, msgs ...llms.Message) error
// Reset resets the chat history for a tenant and chat ID from context.
Reset(ctx context.Context) error
// UpdateChat creates or updates a chat with the title, and metadata for a tenant and chat ID from context.
UpdateChat(ctx context.Context, title string, metadata map[string]any) error
// ListChats returns a list of chat IDs for a tenant and chat ID from context.
ListChats(ctx context.Context) ([]string, error)
// GetChatInfo returns the chat information for a tenant and chat ID from context.
GetChatInfo(ctx context.Context, id string) (*ChatInfo, error)
// GetChatTitle returns the title for a tenant and chat ID from context.
// If the chat does not exist or not persisted, it returns an empty string.
GetChatTitle(ctx context.Context, id string) (string, error)
}
MessageStore is an interface for storing and retrieving chat messages. The supplied context must have ChatContext with tenantID and chatID, created by NewChatContext.
func NewMemoryStore ¶
func NewMemoryStore() MessageStore
func NewRedisStore ¶ added in v0.5.21
func NewRedisStore(client *redis.Client, prefix string) MessageStore
func PopulateMemoryStore ¶ added in v0.3.12
func PopulateMemoryStore(ctx context.Context, store MessageStore) (MessageStore, error)
type MessageStoreManager ¶ added in v0.7.39
type MessageStoreManager interface {
ListTenants(ctx context.Context) ([]string, error)
Cleanup(ctx context.Context, tenantID string, olderThan time.Duration) (uint32, error)
}
func NewMemoryStoreManager ¶ added in v0.7.39
func NewMemoryStoreManager(store MessageStore) MessageStoreManager
func NewRedisStoreManager ¶ added in v0.7.39
func NewRedisStoreManager(client *redis.Client, prefix string) MessageStoreManager
Click to show internal directories.
Click to hide internal directories.