Documentation
¶
Overview ¶
Package derive turns raw transcript rows into the derived tables, exactly once per row.
Package derive turns parsed transcript events into derived facts such as cost.
Index ¶
Constants ¶
const ParserVersion = 2
ParserVersion is bumped whenever a parser or engine change requires re-deriving from raw data.
Variables ¶
This section is empty.
Functions ¶
func Cost ¶
Cost prices one message in USD. estimated is true when the base price of the model, or of its closest known family member, was used for an unknown model or for Speed == "fast". unknown is true (and usd 0) only when no family matches at all.
func NormalizeModel ¶
NormalizeModel strips a trailing "[...]" and a trailing "-YYYYMMDD".
func Snippet ¶
Snippet cuts a short plain-text excerpt for query q out of the raw line of a search hit (role "user" or "assistant"). Candidate texts: user = the prompt; assistant = each text block, then each tool call as "<tool> <summary>". The first candidate containing a query word (case-insensitive substring of any word of q) wins; the excerpt is a window of at most 160 runes around the match with "…" at cut ends and whitespace collapsed. No match: the start of the first candidate. Unparsable or empty input returns "".
Types ¶
type Deriver ¶
type Deriver struct {
DB *db.DB
BatchLines int // raw rows per transaction, default 5000
BatchBytes int // a chunk stops once this many raw bytes were read (at least one row), default 32 MiB
}
Deriver derives the pending raw rows of users.
func (*Deriver) DeriveUser ¶
DeriveUser derives everything pending for userID and returns the number of raw rows (lines + snapshots) processed.
type Price ¶
type Price struct{ Input, CacheWrite5m, CacheWrite1h, CacheRead, Output float64 }
Price is USD per million tokens.
type Worker ¶
type Worker struct {
D *Deriver
DB *db.DB
Sweep time.Duration // default 60 s
Debounce time.Duration // default 250 ms
Workers int // default 2
// OnReindexed (optional) is called after each finished Reindex with the raw rows re-derived.
OnReindexed func(userID string, rows int)
// contains filtered or unexported fields
}
Worker derives users whose raw data changed (LISTEN/NOTIFY plus a periodic sweep as safety net).
func (*Worker) Ready ¶
func (w *Worker) Ready() <-chan struct{}
Ready is closed once LISTEN is active and the first sweep and the startup version check finished.
func (*Worker) ReindexAll ¶
ReindexAll reindexes all users, one after the other.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package derivetest is test support for the derive engine: it stores raw data as ingest would and inspects the derived tables.
|
Package derivetest is test support for the derive engine: it stores raw data as ingest would and inspects the derived tables. |
|
Package parse turns raw transcript lines and snapshots into typed events, leniently and without I/O.
|
Package parse turns raw transcript lines and snapshots into typed events, leniently and without I/O. |