sessions

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileChatMessageStore

type FileChatMessageStore struct {
	Path string
	// contains filtered or unexported fields
}

FileChatMessageStore implements api.ChatMessageStore by persisting history to disk.

func NewFileChatMessageStore

func NewFileChatMessageStore(path string) *FileChatMessageStore

NewFileChatMessageStore creates a new file-backed chat message store.

func (*FileChatMessageStore) AddChatMessage

func (s *FileChatMessageStore) AddChatMessage(record *api.Message) error

AddChatMessage appends a message to the existing history on disk.

func (*FileChatMessageStore) ChatMessages

func (s *FileChatMessageStore) ChatMessages() []*api.Message

ChatMessages returns all persisted chat messages.

func (*FileChatMessageStore) ClearChatMessages

func (s *FileChatMessageStore) ClearChatMessages() error

ClearChatMessages truncates the history file, leaving an empty array.

func (*FileChatMessageStore) HistoryPath

func (s *FileChatMessageStore) HistoryPath() string

HistoryPath returns the location of the history file for this session.

func (*FileChatMessageStore) SetChatMessages

func (s *FileChatMessageStore) SetChatMessages(newHistory []*api.Message) error

SetChatMessages replaces the history file with the provided messages.

type InMemoryChatStore

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

InMemoryChatStore is an in-memory implementation of the api.ChatMessageStore interface. It stores chat messages in a slice and is safe for concurrent use.

func NewInMemoryChatStore

func NewInMemoryChatStore() *InMemoryChatStore

NewInMemoryChatStore creates a new InMemoryChatStore.

func (*InMemoryChatStore) AddChatMessage

func (s *InMemoryChatStore) AddChatMessage(record *api.Message) error

AddChatMessage adds a message to the store.

func (*InMemoryChatStore) ChatMessages

func (s *InMemoryChatStore) ChatMessages() []*api.Message

ChatMessages returns all chat messages from the store.

func (*InMemoryChatStore) ClearChatMessages

func (s *InMemoryChatStore) ClearChatMessages() error

ClearChatMessages removes all messages from the store.

func (*InMemoryChatStore) SetChatMessages

func (s *InMemoryChatStore) SetChatMessages(newHistory []*api.Message) error

SetChatMessages replaces the entire chat history with a new one.

type Metadata

type Metadata struct {
	ProviderID   string    `json:"providerID"`
	ModelID      string    `json:"modelID"`
	CreatedAt    time.Time `json:"createdAt"`
	LastAccessed time.Time `json:"lastAccessed"`
}

type SessionManager

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

func NewSessionManager

func NewSessionManager(backend string) (*SessionManager, error)

func (*SessionManager) DeleteSession

func (sm *SessionManager) DeleteSession(id string) error

func (*SessionManager) FindSessionByID

func (sm *SessionManager) FindSessionByID(id string) (*api.Session, error)

func (*SessionManager) GetLatestSession

func (sm *SessionManager) GetLatestSession() (*api.Session, error)

func (*SessionManager) ListSessions

func (sm *SessionManager) ListSessions() ([]*api.Session, error)

func (*SessionManager) NewSession

func (sm *SessionManager) NewSession(meta Metadata) (*api.Session, error)

func (*SessionManager) UpdateLastAccessed

func (sm *SessionManager) UpdateLastAccessed(session *api.Session) error

type Store

type Store interface {
	GetSession(id string) (*api.Session, error)
	CreateSession(session *api.Session) error
	UpdateSession(session *api.Session) error
	ListSessions() ([]*api.Session, error)
	DeleteSession(id string) error
}

func NewStore

func NewStore(backend string) (Store, error)

Source Files

  • filesystem.go
  • manager.go
  • memory.go
  • store.go

Jump to

Keyboard shortcuts

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