evals

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 19 Imported by: ? 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

Index

Constants

View Source
const (
	DefaultOpenAIModel    = "gpt-6.1-terra"
	DefaultAnthropicModel = "claude-sonnet-5-5"
	// DefaultAzureModel is the deployment name in the CI Azure OpenAI resource.
	DefaultAzureModel   = "gpt-6.1-sol"
	DefaultMistralModel = "mistral-large-latest"
	DefaultBedrockModel = "global.anthropic.claude-sonnet-5-5"
	DefaultCohereModel  = "command-a-plus-05-2026"

	// DefaultGraderModel is pinned separately from DefaultOpenAIModel so that
	// bumping the model under test does not silently change the judge.
	DefaultGraderModel = "gpt-6-luna"
)

Default models for each provider. Update these when bumping model versions.

Variables

This section is empty.

Functions

func LLMRubricT

func LLMRubricT(e *EvalT, rubric, output string)

LLMRubricT grades output against a single rubric and records the result.

func LLMRubricsT added in v2.14.0

func LLMRubricsT(e *EvalT, rubrics []string, output string)

LLMRubricsT grades output against every rubric in one grader request and records a result for each rubric.

func NumEvalsOrSkip

func NumEvalsOrSkip(t *testing.T) int

func RecordScore

func RecordScore(e *EvalT, result *EvalResult)

RecordScore records the score of an eval in a JSONL file.

func Run

func Run(t *testing.T, name string, f func(e *EvalT))

Types

type Eval

type Eval struct {
	LLM       llm.LanguageModel
	GraderLLM llm.LanguageModel
	Prompts   *llm.Prompts

	Provider    string
	Model       string
	GraderModel string
	// contains filtered or unexported fields
}

func NewEval

func NewEval() (*Eval, error)

func NewEvalWithProvider

func NewEvalWithProvider(providerName string) (*Eval, error)

NewEvalWithProvider creates an Eval instance with a specific provider

func (*Eval) LLMRubric

func (e *Eval) LLMRubric(rubric, output string) (*RubricResult, error)

LLMRubric grades output against a single rubric.

func (*Eval) LLMRubrics added in v2.14.0

func (e *Eval) LLMRubrics(rubrics []string, output string) ([]RubricResult, error)

LLMRubrics grades output against every rubric in a single grader request, so the output is sent once rather than once per rubric. Results are in the order of rubrics.

type EvalLogLine

type EvalLogLine struct {
	Name      string  `json:"name"`
	Package   string  `json:"package,omitempty"`
	Timestamp string  `json:"timestamp"`
	RunNumber int     `json:"run_number"`
	Rubric    string  `json:"rubric"`
	Output    string  `json:"output"`
	Reasoning string  `json:"reasoning"`
	Score     float64 `json:"score"`
	Pass      bool    `json:"pass"`
	// Error is set when the run failed before any rubric could be graded,
	// for example because the provider rejected the request.
	Error string `json:"error,omitempty"`
	// Usage is the token usage of the whole trial, set on its last line.
	Usage *TrialUsage `json:"usage,omitempty"`
}

type EvalResult

type EvalResult struct {
	Rubric    string  `json:"rubric"`
	Output    string  `json:"output"`
	Reasoning string  `json:"reasoning"`
	Score     float64 `json:"score"`
	Pass      bool    `json:"pass"`
}

type EvalT

type EvalT struct {
	*testing.T
	*Eval
	// contains filtered or unexported fields
}

func (*EvalT) Errorf added in v2.11.0

func (e *EvalT) Errorf(format string, args ...any)

Errorf captures assertion failures (testify reports through it) so they are recorded with the run's results.

type RoleUsage added in v2.14.0

type RoleUsage struct {
	Model             string  `json:"model,omitempty"`
	Calls             int     `json:"calls"`
	InputTokens       int64   `json:"input_tokens"`
	CachedReadTokens  int64   `json:"cached_read_tokens,omitempty"`
	CachedWriteTokens int64   `json:"cached_write_tokens,omitempty"`
	OutputTokens      int64   `json:"output_tokens"`
	ReasoningTokens   int64   `json:"reasoning_tokens,omitempty"`
	CostUSD           float64 `json:"cost_usd,omitempty"`
}

RoleUsage is the token usage of one role (model under test or grader) in a trial, with its list-price cost when the model's price is known.

type RubricResult

type RubricResult struct {
	Reasoning string
	Score     float64
	Pass      bool
}

type ThreadExport

type ThreadExport struct {
	Posts     map[string]*model.Post     `json:"posts"`
	Channel   *model.Channel             `json:"channel"`
	Team      *model.Team                `json:"team"`
	Users     map[string]*model.User     `json:"users"`
	FileInfos map[string]*model.FileInfo `json:"file_infos"`
	Files     map[string][]byte          `json:"files"`

	// Helper fields not in the JSON
	RootPost *model.Post     `json:"-"`
	PostList *model.PostList `json:"-"`
}

ThreadExport represents the format of exported thread data

func LoadThreadFromJSON

func LoadThreadFromJSON(t *EvalT, path string) *ThreadExport

LoadThreadFromJSON loads post data from a JSON file containing exported Mattermost thread data and returns it as ThreadData containing Posts, RootPost, and PostList for testing

func (*ThreadExport) BotUser added in v2.11.0

func (t *ThreadExport) BotUser() *model.User

BotUser returns the first bot user in the export, or nil if there is none.

func (*ThreadExport) LatestPost

func (t *ThreadExport) LatestPost() *model.Post

func (*ThreadExport) RequestingUser

func (t *ThreadExport) RequestingUser() *model.User

func (*ThreadExport) String

func (t *ThreadExport) String() string

type TrialUsage added in v2.14.0

type TrialUsage struct {
	Agent  RoleUsage `json:"agent"`
	Grader RoleUsage `json:"grader"`
}

TrialUsage is the token usage of one trial of an eval.

Jump to

Keyboard shortcuts

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