Documentation
¶
Index ¶
- func GenerateID() string
- type SessionRecord
- type SessionStore
- func (s *SessionStore) AppendMessage(sessionID string, msg provider.Message) error
- func (s *SessionStore) Close() error
- func (s *SessionStore) CreateSession(id, title, providerName, model string) (*SessionRecord, error)
- func (s *SessionStore) DeleteSession(id string) error
- func (s *SessionStore) GetLastSession() (*SessionRecord, error)
- func (s *SessionStore) GetSession(id string) (*SessionRecord, error)
- func (s *SessionStore) ListSessions(limit int) ([]SessionSummary, error)
- func (s *SessionStore) SaveSession(rec *SessionRecord) error
- func (s *SessionStore) UpdateModel(id, providerName, model string) error
- type SessionSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SessionRecord ¶
type SessionRecord struct {
ID string `json:"id"`
Title string `json:"title"`
Provider string `json:"provider"`
Model string `json:"model"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Messages []provider.Message `json:"messages"`
}
SessionRecord holds the full data of a persisted session.
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore handles session persistence using SQLite.
func NewStore ¶
func NewStore(dbPath string) (*SessionStore, error)
NewStore opens or creates a SQLite session database at dbPath.
func (*SessionStore) AppendMessage ¶
func (s *SessionStore) AppendMessage(sessionID string, msg provider.Message) error
AppendMessage persists a single message to the given session and updates timestamps.
func (*SessionStore) Close ¶
func (s *SessionStore) Close() error
Close closes the underlying SQLite database.
func (*SessionStore) CreateSession ¶
func (s *SessionStore) CreateSession(id, title, providerName, model string) (*SessionRecord, error)
CreateSession initializes a new session record in the database.
func (*SessionStore) DeleteSession ¶
func (s *SessionStore) DeleteSession(id string) error
DeleteSession deletes a session and all its messages.
func (*SessionStore) GetLastSession ¶
func (s *SessionStore) GetLastSession() (*SessionRecord, error)
GetLastSession returns the most recently updated session, or nil if no sessions exist.
func (*SessionStore) GetSession ¶
func (s *SessionStore) GetSession(id string) (*SessionRecord, error)
GetSession retrieves a session record and its full message history.
func (*SessionStore) ListSessions ¶
func (s *SessionStore) ListSessions(limit int) ([]SessionSummary, error)
ListSessions returns a summary of recent sessions up to limit.
func (*SessionStore) SaveSession ¶
func (s *SessionStore) SaveSession(rec *SessionRecord) error
SaveSession updates session metadata and overwrites all messages.
func (*SessionStore) UpdateModel ¶
func (s *SessionStore) UpdateModel(id, providerName, model string) error
UpdateModel updates the model and provider of an existing session.
type SessionSummary ¶
type SessionSummary struct {
ID string `json:"id"`
Title string `json:"title"`
Provider string `json:"provider"`
Model string `json:"model"`
MessageCount int `json:"message_count"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SessionSummary holds brief metadata about a session for listing.