Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirMemoryWriter ¶
type DirMemoryWriter struct {
// contains filtered or unexported fields
}
DirMemoryWriter writes per-session files into a directory. Each session (identified by sessionID) gets its own file based on a configurable name pattern. Supported placeholders: {token_hash}, {session_id}, {date}.
func NewDirMemoryWriter ¶
func NewDirMemoryWriter(dir, pattern string) (*DirMemoryWriter, error)
NewDirMemoryWriter creates a writer that produces per-session files under dir. The pattern supports placeholders: {token_hash} (replaced with sessionID), {session_id} (replaced with sessionID), {date} (replaced with YYYY-MM-DD). Example: "{date}/{token_hash}.md".
func (*DirMemoryWriter) Append ¶
func (w *DirMemoryWriter) Append(sessionID, role, model, content string) error
func (*DirMemoryWriter) Close ¶
func (w *DirMemoryWriter) Close() error
func (*DirMemoryWriter) ResolvePath ¶
func (w *DirMemoryWriter) ResolvePath(sessionID string) string
ResolvePath returns the file path for a given session ID without opening the file.
type FileMemoryWriter ¶
type FileMemoryWriter struct {
// contains filtered or unexported fields
}
FileMemoryWriter appends markdown-formatted conversation logs to a file.
func NewFileMemoryWriter ¶
func NewFileMemoryWriter(path string) (*FileMemoryWriter, error)
NewFileMemoryWriter opens (or creates) a file for appending session content.
func (*FileMemoryWriter) Append ¶
func (w *FileMemoryWriter) Append(sessionID, role, model, content string) error
func (*FileMemoryWriter) Close ¶
func (w *FileMemoryWriter) Close() error
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) AddUsage ¶
func (m *MemoryStore) AddUsage(tokenHash string, count int64) (int64, error)
func (*MemoryStore) Reset ¶
func (m *MemoryStore) Reset(tokenHash string) error
type MemoryWriter ¶
type MemoryWriter interface {
// Append writes content to the session log.
Append(sessionID, role, model, content string) error
// Close cleans up resources.
Close() error
}
MemoryWriter handles writing conversation content to a session file or Redis.
type NopMemoryWriter ¶
type NopMemoryWriter struct{}
NopMemoryWriter is a no-op implementation when memory is disabled.
func (*NopMemoryWriter) Append ¶
func (w *NopMemoryWriter) Append(sessionID, role, model, content string) error
func (*NopMemoryWriter) Close ¶
func (w *NopMemoryWriter) Close() error
type RedisMemoryWriter ¶
type RedisMemoryWriter struct {
// contains filtered or unexported fields
}
RedisMemoryWriter pushes conversation entries to a Redis list keyed by session.
func NewRedisMemoryWriter ¶
func NewRedisMemoryWriter(client *redis.Client) *RedisMemoryWriter
NewRedisMemoryWriter creates a writer that pushes to Redis lists.
func (*RedisMemoryWriter) Append ¶
func (w *RedisMemoryWriter) Append(sessionID, role, model, content string) error
func (*RedisMemoryWriter) Close ¶
func (w *RedisMemoryWriter) Close() error
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(addr, password string, db int) *RedisStore
func (*RedisStore) AddUsage ¶
func (r *RedisStore) AddUsage(tokenHash string, count int64) (int64, error)
func (*RedisStore) Client ¶
func (r *RedisStore) Client() *redis.Client
Client returns the underlying Redis client for shared use (e.g., memory writers).
func (*RedisStore) Close ¶
func (r *RedisStore) Close() error
func (*RedisStore) Reset ¶
func (r *RedisStore) Reset(tokenHash string) error
type RotatingDirMemoryWriter ¶ added in v0.1.2
type RotatingDirMemoryWriter struct {
// contains filtered or unexported fields
}
RotatingDirMemoryWriter writes per-session files with automatic rotation when size limit is reached. It optionally gzips rotated files to save space.
func NewRotatingDirMemoryWriter ¶ added in v0.1.2
func NewRotatingDirMemoryWriter(dir, pattern string, maxSizeMB int, compressOld bool) (*RotatingDirMemoryWriter, error)
NewRotatingDirMemoryWriter creates a writer with size-based rotation and optional compression. maxSizeMB: max file size before rotation (0 = unlimited, defaults to 100 MB) compressOld: if true, gzips rotated files
func (*RotatingDirMemoryWriter) Append ¶ added in v0.1.2
func (w *RotatingDirMemoryWriter) Append(sessionID, role, model, content string) error
func (*RotatingDirMemoryWriter) Close ¶ added in v0.1.2
func (w *RotatingDirMemoryWriter) Close() error
func (*RotatingDirMemoryWriter) ResolvePath ¶ added in v0.1.2
func (w *RotatingDirMemoryWriter) ResolvePath(sessionID string) string
ResolvePath returns the file path for a given session ID without opening the file.