target

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package target defines the interface for evaluation targets — the system under test. Targets can be raw LLM APIs, agents, or plain functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCallOptions

func WithCallOptions(ctx context.Context, o CallOptions) context.Context

WithCallOptions attaches the run's choices to ctx.

Types

type AgentClient

type AgentClient interface {
	Run(ctx context.Context, agentID, personaRef, input string) (*AgentResponse, error)
}

AgentClient is the interface for invoking a Cortex agent and capturing the full run trace for persona-aware evaluation.

type AgentResponse

type AgentResponse struct {
	Output string
	Tokens int
	Cost   float64
	Trace  *evalrun.RunTrace
}

AgentResponse holds the response from an agent invocation.

type AgentTarget

type AgentTarget struct {
	AgentID    string
	PersonaRef string
	Client     AgentClient
}

AgentTarget invokes a Cortex agent and captures the full run trace. This enables persona-aware scoring by providing tool calls, steps, and execution metadata to the scorers.

func NewAgentTarget

func NewAgentTarget(client AgentClient, agentID, personaRef string) *AgentTarget

NewAgentTarget creates a target that invokes a Cortex agent.

func (*AgentTarget) Call

func (t *AgentTarget) Call(ctx context.Context, input string) (*Output, error)

func (*AgentTarget) Name

func (t *AgentTarget) Name() string

type CallOptions

type CallOptions struct {
	SystemPrompt string
	Model        string
	Temperature  float64
}

CallOptions carry what the run decided for this call: the prompt of the suite's current prompt version (or the suite's own prompt), the model and the temperature. A target that builds its own request should prefer these to whatever it was constructed with, so the prompt a run records is the prompt the model actually saw.

func CallOptionsFrom

func CallOptionsFrom(ctx context.Context) (CallOptions, bool)

CallOptionsFrom returns the run's choices, if the engine attached any.

type FuncTarget

type FuncTarget struct {
	// contains filtered or unexported fields
}

FuncTarget wraps a plain function as an eval target.

func FromFunc

func FromFunc(name string, fn func(ctx context.Context, input string) (string, error)) *FuncTarget

FromFunc creates a named target from a function. The function receives the input string and returns the output. Latency is measured automatically.

func (*FuncTarget) Call

func (t *FuncTarget) Call(ctx context.Context, input string) (*Output, error)

func (*FuncTarget) Name

func (t *FuncTarget) Name() string

type LLMClient

type LLMClient interface {
	Complete(ctx context.Context, model, systemPrompt, userInput string, temperature float64) (*LLMResponse, error)
}

LLMClient is the interface for calling a language model. Implementations bridge to specific LLM providers.

type LLMResponse

type LLMResponse struct {
	Output string
	Tokens int
	Cost   float64
}

LLMResponse holds the response from an LLM call.

type LLMTarget

type LLMTarget struct {
	Model        string
	SystemPrompt string
	Temperature  float64
	Client       LLMClient
}

LLMTarget calls a language model directly (traditional eval).

func NewLLMTarget

func NewLLMTarget(client LLMClient, model, systemPrompt string, temperature float64) *LLMTarget

NewLLMTarget creates a target that calls an LLM directly.

func (*LLMTarget) Call

func (t *LLMTarget) Call(ctx context.Context, input string) (*Output, error)

func (*LLMTarget) Name

func (t *LLMTarget) Name() string

type Output

type Output struct {
	Output  string            // The text response
	Latency time.Duration     // Response time
	Tokens  int               // Tokens used
	Cost    float64           // Estimated cost
	Trace   *evalrun.RunTrace // Agent execution trace (nil for raw LLM targets)
}

Output includes both the text output and optional execution trace.

type Target

type Target interface {
	Name() string
	Call(ctx context.Context, input string) (*Output, error)
}

Target is the interface for evaluation targets.

Jump to

Keyboard shortcuts

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