Documentation
¶
Overview ¶
Package evaluator provides typed assessments without applying decision policies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTerminal ¶ added in v1.147.0
IsTerminal reports whether err, or any error it wraps, is terminal.
func ObserveUsage ¶
func ObserveUsage(ctx context.Context, record UsageRecord)
ObserveUsage delivers an accounting record to the observer on ctx. Providers call it once per attempted HTTP request, even when answer validation fails. All callbacks must finish before Evaluate returns.
func WithUsageObserver ¶
func WithUsageObserver(ctx context.Context, observer func(UsageRecord)) context.Context
WithUsageObserver attaches a synchronous per-request observer to ctx, replacing any inherited observer. A nil observer disables observation. Callbacks shared by concurrent evaluations must synchronize their own state.
Types ¶
type Result ¶
type Result struct {
Type string `json:"type"`
Model string `json:"model"`
Probability *float64 `json:"probability,omitempty"`
Choice string `json:"choice,omitempty"`
Score *float64 `json:"score,omitempty"`
Probabilities map[string]float64 `json:"probabilities,omitempty"`
Confidence *float64 `json:"confidence,omitempty"`
Usage Usage `json:"usage"`
// Cost is the estimated USD charge; nil means usage or pricing is unknown.
Cost *float64 `json:"cost,omitempty"`
}
Result is an assessment; callers decide how its probabilities affect behavior.
type TerminalError ¶ added in v1.147.0
type TerminalError struct{ Err error }
TerminalError marks a failure that must end the run. Callers with a fallback for ordinary assessment failures must not apply it to a terminal one, such as an exhausted budget or untrustworthy usage accounting.
func (*TerminalError) Error ¶ added in v1.147.0
func (e *TerminalError) Error() string
func (*TerminalError) Unwrap ¶ added in v1.147.0
func (e *TerminalError) Unwrap() error
type Usage ¶
type Usage struct {
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
}
Usage records the tokens consumed by an evaluation.
type UsageRecord ¶
type UsageRecord struct {
// Model is the returned ID, or the requested ID when unavailable.
Model string
// Usage is nil when token counts are missing or invalid, not when they are zero.
Usage *Usage
// Cost is the estimated USD charge; nil means usage or pricing is unknown.
Cost *float64
}
UsageRecord reports request accounting independently of answer validity.