Documentation
¶
Overview ¶
Package eval measures the Slack extractor: an oracle reads a conversation and writes the viewer's briefing, a blind reader writes the same briefing from the extractor's ledger alone, and a judge with the conversation compares them.
Index ¶
- Constants
- Variables
- func BlindPrompt(base map[string]string, toolOutput string) string
- func CheckTemplate(t string) error
- func ExtractorPrompt(tmpl string, in extract.Input) (string, error)
- func JudgePrompt(base map[string]string, conversation string, reference, blind json.RawMessage, ...) string
- func LedgerView(f Fixture, r extract.Result, names map[string]string, now time.Time) string
- func Optimize(ctx context.Context, o OptimizeOptions) (changelog []string, cost float64, err error)
- func OraclePrompt(base map[string]string, conversation string) string
- func Plain(in extract.Input) extract.Input
- type ExportOptions
- type ExportReport
- type Fixture
- type Judgment
- type Key
- type Message
- type OptimizeOptions
- type Options
- type PassUsage
- type Reaction
- type Report
- type RootCause
- type Score
- type Section
- type Set
- type SplitScore
- type StaleError
- type Usage
Constants ¶
const ( SplitDev = "dev" SplitHoldout = "holdout" )
const ( ExtractorCallUSD = 0.5 JudgeCallUSD = 1.0 )
Per-call caps: every call carries one, and the run's budget reserves it before the call starts.
const DefaultNow = "2026-10-21T21:00:00-03:00"
DefaultNow is the "now" of a fixture that names none: when the first fixtures were measured.
const OptimizeCallUSD = 5.0
OptimizeCallUSD caps the optimizer's call.
Variables ¶
var Causes = []string{"missing_item", "spurious_item", "wrong_assignee", "wrong_waiting_on", "wrong_state", "wrong_resolution",
"missing_link", "vague_summary", "missing_context", "wrong_verdict", "other"}
Causes are the ledger root causes a judge may name.
var ErrBudget = errors.New("the run stopped before passing --max-usd")
var Placeholders = []string{"{{VIEWER_ID}}", "{{VIEWER_NAME}}", "{{NOW}}", "{{LANGUAGE}}", "{{LEDGER}}", "{{CITED}}", "{{CONTEXTS}}", "{{CONVERSATION}}"}
Placeholders are the extractor template's, each exactly once.
Functions ¶
func BlindPrompt ¶
BlindPrompt asks for the viewer's briefing from the tool's output alone.
func CheckTemplate ¶
CheckTemplate refuses a template over the word cap or that drops or repeats a placeholder.
func ExtractorPrompt ¶
ExtractorPrompt fills tmpl for in exactly as extract.Prompt fills the shipped template; "" is the shipped template itself.
func JudgePrompt ¶
func JudgePrompt(base map[string]string, conversation string, reference, blind json.RawMessage, toolOutput string) string
JudgePrompt asks to compare the blind briefing with the reference.
func LedgerView ¶
LedgerView is what the tool shows the viewer about f: the extracted items with names, never the messages.
func Optimize ¶
Optimize asks for a better template from the label's dev judgments alone and writes it to New, with its changelog beside it, only when it passes CheckTemplate.
func OraclePrompt ¶
OraclePrompt asks for the briefing of someone who read the conversation.
Types ¶
type ExportOptions ¶
type ExportOptions struct {
DB *store.SlackStore
Facts slack.FactsReader
Segments slack.Segments // nil leaves every DM unsegmented
// Since and Until bound the activity: a unit with a message in [Since, Until).
Since, Until time.Time
Out string
Exclude []string // fixtures directories; a unit sharing any (channel, message ts) with one of their fixtures is skipped
Now time.Time
// Before reads the newest n messages of a conversation anchored before a ts; nil exports no context.
Before func(ctx context.Context, conv, before string, n int) ([]slack.Message, error)
ContextMessages, ContextChars int
}
type ExportReport ¶
type ExportReport struct {
Written, Excluded, Unsegmented int
}
func Export ¶
func Export(ctx context.Context, o ExportOptions) (ExportReport, error)
Export writes one holdout fixture per Slack unit with activity in the window, users.json and viewer.json.
type Fixture ¶
type Fixture struct {
ID string `json:"id"`
Kind string `json:"kind"`
Split string `json:"split,omitempty"`
Now string `json:"now,omitempty"`
ChannelID string `json:"channel_id"`
ChannelName string `json:"channel_name"`
ChannelType string `json:"channel_type"`
Permalink string `json:"permalink"`
FocusTS string `json:"focus_ts"`
// Context are the messages before a DM segment, shown to the extractor only, read only.
Context []Message `json:"context,omitempty"`
Messages []Message `json:"messages"`
}
func (Fixture) Input ¶
func (f Fixture) Input(v extract.Viewer, names map[string]string, now time.Time, language string) extract.Input
Input is the extractor's input for f: an empty ledger, no segments and no window, so Render shows the whole fixture; a DM segment's context, bounds and focus are marked.
type Judgment ¶
type Judgment struct {
SameActions bool `json:"same_actions"`
Severity string `json:"severity"`
Sections map[string]Section `json:"sections"`
ReferenceErrors []string `json:"reference_errors"`
LedgerRootCauses []RootCause `json:"ledger_root_causes"`
PromptFixHints []string `json:"prompt_fix_hints"`
}
type Key ¶
type Key struct {
Tier string `json:"tier"`
Language string `json:"language"`
Now string `json:"now"`
PromptSHA string `json:"prompt_sha"`
}
Key says what produced a stage file; a cached file is reused only under the same key.
type Message ¶
type Message struct {
TS string `json:"ts"`
ThreadTS string `json:"thread_ts"`
UserID string `json:"user_id"`
UserName string `json:"user_name"`
IsBot bool `json:"is_bot"`
AppName string `json:"app_name"`
Text string `json:"text"`
Reactions []Reaction `json:"reactions"`
ReplyCount int `json:"reply_count"`
Edited bool `json:"edited"`
Files []string `json:"files,omitempty"`
}
type OptimizeOptions ¶
type Options ¶
type Options struct {
Asker host.Asker
Set Set
Out string
Label string
Split string // dev, holdout or all ("" is all)
Template string // the extractor's prompt template; "" is the shipped one
// Prompts are the shipped extraction prompts.
Prompts *extract.Prompts
Viewer extract.Viewer
Language string
Now string // RFC3339, overrides every fixture's now
MaxUSD float64
Jobs int
ExtractorTier, JudgeTier host.Tier
// EscalateOverChars sends an extraction whose conversation renders longer to the frontier tier; 0 never.
EscalateOverChars int
Log io.Writer
}
type PassUsage ¶
type PassUsage struct {
Conversations int `json:"conversations"`
TokensReported int `json:"tokens_reported"`
Total Usage `json:"total"`
Mean Usage `json:"mean"`
}
PassUsage is what one pass spent on the conversations it answered; the token means are over the calls that reported tokens.
type Score ¶
type Score map[string]SplitScore
Score is by split, "dev" and "holdout".
func WriteScore ¶
WriteScore scores label's judgments under out against the run's manifest and writes <out>/<label>/score.json.
type Set ¶
Set is a fixtures directory: its fixtures by id, the user names of users.json and the viewer of viewer.json, when present.
type SplitScore ¶
type SplitScore struct {
N int `json:"n"`
Expected int `json:"expected"`
SameActions float64 `json:"same_actions"`
CriticalOrMajor int `json:"critical_or_major"`
Recall map[string]float64 `json:"recall"`
Contradictions int `json:"contradictions"`
Extras int `json:"extras"`
Causes map[string]int `json:"causes"`
CostUSD float64 `json:"cost_usd"`
Extractor PassUsage `json:"extractor"`
}
func ScoreSplit ¶
func ScoreSplit(js []Judgment, expected int) SplitScore
ScoreSplit scores the judgments present of a split of expected fixtures; a missing one counts as a critical failure with different actions.
type StaleError ¶
type StaleError struct{ Path string }
StaleError is a stage file whose key differs from the call's.
func (*StaleError) Error ¶
func (e *StaleError) Error() string