store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package store provides session persistence using SQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProviderConfig

type ProviderConfig struct {
	Provider string `json:"provider"`
	Model    string `json:"model"`
	APIKey   string `json:"api_key,omitempty"`
	BaseURL  string `json:"base_url,omitempty"`
}

ProviderConfig holds configuration for the LLM provider

type Session

type Session struct {
	ID        string             `json:"id"`
	Title     string             `json:"title"`
	Messages  []provider.Message `json:"messages"`
	Config    ProviderConfig     `json:"config"`
	CreatedAt time.Time          `json:"created_at"`
	UpdatedAt time.Time          `json:"updated_at"`

	// Token tracking
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
}

Session represents a chat session with message history

type Store

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

Store provides session persistence using SQLite

func New

func New(dbPath string) (*Store, error)

New creates a new Store with SQLite backend. If dbPath is empty, uses ~/.palm/sessions.db

func NewInMemory

func NewInMemory() (*Store, error)

NewInMemory creates an in-memory store (useful for testing)

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection

func (*Store) Create

func (s *Store) Create(config ProviderConfig) (*Session, error)

Create creates a new session

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete deletes a session by ID

func (*Store) Get

func (s *Store) Get(id string) (*Session, error)

Get retrieves a session by ID

func (*Store) GetStats

func (s *Store) GetStats() (totalSessions int, totalInputTokens int, totalOutputTokens int, err error)

GetStats returns aggregate statistics

func (*Store) List

func (s *Store) List(limit int) ([]*Session, error)

List returns all sessions, ordered by update time (most recent first)

func (*Store) SetTitle

func (s *Store) SetTitle(id, title string) error

SetTitle updates the session title

func (*Store) Update

func (s *Store) Update(session *Session) error

Update updates a session

func (*Store) UpdateTokens

func (s *Store) UpdateTokens(id string, inputTokens, outputTokens int) error

UpdateTokens updates the token counts for a session

Jump to

Keyboard shortcuts

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