Documentation
¶
Index ¶
- Constants
- func BuildPrompt(segments []Segment, targetChars int, hint string) string
- func CacheKey(contentKey string, zoom ZoomLevel, contentHash string) string
- func ExtractSummary(segments []Segment, zoom ZoomLevel) string
- func IsAppleMLAvailable() bool
- type AnthropicProvider
- type AppleProvider
- type OllamaProvider
- type OpenAIProvider
- type Provider
- type Request
- type Result
- type Segment
- type Summarizer
- type SummaryCache
- type SummaryReadyMsg
- type ZoomLevel
Constants ¶
const ( HintGap = "gap" // summarizing missed messages HintTicker = "ticker" // one-line ambient display HintScan = "scan" // front page overview )
Hint types for prompt construction.
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
BuildPrompt constructs an LLM prompt for the given segments and hint.
func CacheKey ¶
CacheKey computes a content-aware cache key. key = sha256(contentKey + ":" + zoomBucket + ":" + contentHash)
func ExtractSummary ¶
ExtractSummary produces an extractive summary at the given zoom level.
func IsAppleMLAvailable ¶
func IsAppleMLAvailable() bool
IsAppleMLAvailable returns false on non-darwin platforms.
Types ¶
type AnthropicProvider ¶
type AnthropicProvider struct {
// contains filtered or unexported fields
}
AnthropicProvider calls the Anthropic Messages API.
func NewAnthropicProvider ¶
func NewAnthropicProvider(apiKey, model string) *AnthropicProvider
NewAnthropicProvider creates an Anthropic provider.
type AppleProvider ¶
type AppleProvider struct{}
AppleProvider is a stub for non-darwin platforms.
func NewAppleProvider ¶
func NewAppleProvider() *AppleProvider
NewAppleProvider returns nil on non-darwin platforms.
type OllamaProvider ¶
type OllamaProvider struct {
// contains filtered or unexported fields
}
OllamaProvider calls a local Ollama server.
func NewOllamaProvider ¶
func NewOllamaProvider(endpoint, model string) *OllamaProvider
NewOllamaProvider creates an Ollama provider.
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider calls any OpenAI-compatible API (OpenAI, OpenRouter, local).
func NewOpenAIProvider ¶
func NewOpenAIProvider(endpoint, apiKey, model string) *OpenAIProvider
NewOpenAIProvider creates an OpenAI-compatible provider.
type Provider ¶
type Provider interface {
Complete(ctx context.Context, prompt string, maxTokens int) (string, error)
}
Provider generates summaries via an LLM or similar service.
func DetectProvider ¶
DetectProvider returns the best available provider based on configuration.
type Request ¶
type Request struct {
ContentKey string // human-readable grouping key, e.g. "campfire:123:gap:45-67"
Content []Segment // the messages to summarize
TargetChars int // desired output length
Hint string // context hint: "gap", "ticker", "scan"
}
Request describes what to summarize and at what zoom level.
type Summarizer ¶
type Summarizer struct {
// contains filtered or unexported fields
}
Summarizer provides synchronous and async summary generation. When a Provider is available, it uses LLM; otherwise extractive fallback.
func NewSummarizer ¶
func NewSummarizer(provider Provider, cache *SummaryCache, maxConcurrent int) *Summarizer
NewSummarizer creates a Summarizer with the given provider and cache. If provider is nil, SummarizeSync always returns extractive fallback.
func (*Summarizer) Summarize ¶
Summarize returns a tea.Cmd that runs an async LLM summary. On completion, emits SummaryReadyMsg. The caller should then call SummarizeSync to get the (now cached) result. Returns nil if no provider is configured or request is already in-flight. The parent context is used to cancel in-flight LLM calls on shutdown.
func (*Summarizer) SummarizeSync ¶
func (s *Summarizer) SummarizeSync(req Request) Result
SummarizeSync returns a summary immediately. Never blocks on LLM. Returns cached LLM result if available, otherwise extractive fallback.
type SummaryCache ¶
type SummaryCache struct {
// contains filtered or unexported fields
}
SummaryCache provides disk-backed caching with in-memory eviction (oldest-first).
func NewSummaryCache ¶
func NewSummaryCache(dir string, ttl time.Duration, maxMemEntries int) *SummaryCache
NewSummaryCache creates a cache backed by the given directory.
func (*SummaryCache) Get ¶
func (c *SummaryCache) Get(key string) (string, bool)
Get looks up a cached summary. Returns ("", false) on miss.
func (*SummaryCache) Put ¶
func (c *SummaryCache) Put(key, summary string)
Put stores a summary in both memory and disk cache.
type SummaryReadyMsg ¶
type SummaryReadyMsg struct {
ContentKey string
}
SummaryReadyMsg is sent when an async summary completes.
type ZoomLevel ¶
type ZoomLevel int
ZoomLevel represents a target character budget for summaries.
func BucketZoom ¶
BucketZoom normalizes a target char count to the nearest zoom bucket.