mocks

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mocks converts Arena run results into mock provider configurations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFiles

func WriteFiles(file File, opts WriteOptions) (map[string][]byte, error)

WriteFiles renders the provided File into YAML bytes and optionally writes them to disk. It returns a map of output path -> YAML bytes (useful for dry-run and testing).

Types

type File

type File struct {
	DefaultResponse string                         `yaml:"defaultResponse,omitempty"`
	Scenarios       map[string]ScenarioTurnHistory `yaml:"scenarios,omitempty"`
}

File represents a mock response YAML document compatible with the mock provider. It mirrors the structure used by mock repository config files.

func BuildFile

func BuildFile(results []engine.RunResult) (File, error)

BuildFile merges multiple RunResults into a mock config File grouped by ScenarioID.

type ScenarioTurnHistory

type ScenarioTurnHistory struct {
	// DefaultResponse can be used to set a scenario-specific fallback.
	DefaultResponse string               `yaml:"defaultResponse,omitempty"`
	Turns           map[int]TurnTemplate `yaml:"turns,omitempty"`
}

ScenarioTurnHistory contains the generated turns for a scenario.

func BuildScenarioFromResult

func BuildScenarioFromResult(result engine.RunResult) (ScenarioTurnHistory, error)

BuildScenarioFromResult converts a single Arena RunResult into a ScenarioTurnHistory. It extracts assistant messages in order, preserving tool calls and responses.

type TurnTemplate

type TurnTemplate struct {
	Response  string             `yaml:"response,omitempty"`
	ToolCalls []mock.ToolCall    `yaml:"tool_calls,omitempty"`
	Parts     []mock.ContentPart `yaml:"parts,omitempty"`
}

TurnTemplate captures either tool calls or an assistant response for a single turn.

type WriteOptions

type WriteOptions struct {
	// OutputPath controls the destination. If PerScenario is false, this is the file path.
	// If PerScenario is true, this is the directory that will contain one file per scenario.
	OutputPath      string
	PerScenario     bool
	Merge           bool
	DefaultResponse string
	DryRun          bool
}

WriteOptions controls how mock YAML files are emitted.

Jump to

Keyboard shortcuts

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