evalhooks

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package evalhooks carries the callbacks the eval runner needs to observe a run while it is still in flight.

These live under internal/ deliberately. The remote eval runner needs to know which experiment a run is writing to, and needs each case's result as it lands, but the shape of eval callbacks is not settled across the Braintrust SDKs yet. Keeping the types here means github.com/braintrustdata/braintrust-sdk-go/eval can expose a hooks field that only this module can populate, so nothing is promised to callers before the design is agreed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaseProgress

type CaseProgress struct {
	Output any
	Scores map[string]float64
	Error  error

	// ID is the eval span ID, used to correlate SSE progress events with OTLP
	// span data.
	ID string

	// Origin contains dataset provenance when the case came from a dataset.
	Origin map[string]any
}

CaseProgress contains the result of a single completed evaluation case.

type ExperimentInfo

type ExperimentInfo struct {
	ExperimentID   string
	ExperimentName string
	ProjectID      string
	ProjectName    string

	// ExperimentURL links to the experiment in the Braintrust UI. Empty when
	// the org name or experiment ID could not be determined.
	ExperimentURL string
}

ExperimentInfo identifies the experiment a run is writing to.

type Hooks

type Hooks struct {
	// OnCaseComplete is called after each case completes (task + scorers).
	// It is called from worker goroutines and must be safe for concurrent use.
	OnCaseComplete func(CaseProgress)

	// OnExperimentStart is called once, after the experiment has been
	// registered and before any case runs. It is the only way to learn the
	// experiment's identity while the run is still going: the Result is not
	// available until the run finishes.
	OnExperimentStart func(ExperimentInfo)
}

Hooks are the callbacks fired during an eval run. A nil *Hooks is valid and fires nothing, so callers never need nil checks.

func (*Hooks) CaseComplete

func (h *Hooks) CaseComplete(cp CaseProgress)

CaseComplete fires OnCaseComplete if it is set.

func (*Hooks) ExperimentStart

func (h *Hooks) ExperimentStart(info ExperimentInfo)

ExperimentStart fires OnExperimentStart if it is set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL