Documentation
¶
Overview ¶
Title normalization matches session-title/normalize: remove escapes, control and directional characters, normalize whitespace, and truncate to a UTF-8 byte budget without splitting characters.
Package sessiontitle generates session titles (S08), matching storage/session-title. Session events and FoldSessionTitle already provide latest-wins title projection. This package generates titles from the first user message: Fallback takes a 30-rune prefix by default, while an optional LLMAdapter generates a concise title. Missing or failed LLM generation falls back to the prefix. Rune-based truncation preserves UTF-8 characters. Generate returns both Title and Source (llm/fallback).
Index ¶
- Variables
- func CleanTitle(input string) string
- func Fallback(firstUserMessage string) string
- func FallbackMax(firstUserMessage string, maxRunes int) string
- func Normalize(input string, maxBytes int) string
- func TrimTitle(s string) string
- func TruncateUTF8(input string, maxBytes int) string
- type Generator
- type Result
- type Source
Constants ¶
This section is empty.
Variables ¶
var FallbackSystemPrompt = "" /* 166-byte string literal not displayed */
FallbackSystemPrompt asks the model for a concise single-sentence title.
Functions ¶
func CleanTitle ¶
CleanTitle removes escape/control characters and collapses whitespace to one line.
func Fallback ¶
Fallback uses the first user-message prefix, up to 30 runes by default. Empty input returns empty; callers decide whether to emit session/title.
func FallbackMax ¶
FallbackMax generates a prefix title with the supplied rune limit.
func TruncateUTF8 ¶
TruncateUTF8 returns the longest complete-rune prefix within a UTF-8 byte budget.
Types ¶
type Generator ¶
type Generator struct {
// LLM optionally summarizes the first user message; nil always uses fallback.
LLM llm.LLMAdapter
// Model selects the title model; empty uses the adapter default.
Model string
// MaxRunes limits fallback titles; nonpositive values use 30.
MaxRunes int
// System optionally overrides the built-in title-generation prompt.
System string
// MaxTokens limits tokens for one LLM title request.
MaxTokens int
}
Generator creates session titles using an optional LLM helper.