Documentation
¶
Overview ¶
Package replay provides a provider that replays recorded sessions deterministically.
Package replay provides a provider that replays recorded sessions deterministically.
Index ¶
- Variables
- type Config
- type MatchMode
- type Provider
- func (p *Provider) CalculateCost(inputTokens, outputTokens, cachedTokens int) types.CostInfo
- func (p *Provider) Close() error
- func (p *Provider) CurrentTurn() int
- func (p *Provider) GetMetadata() map[string]interface{}
- func (p *Provider) ID() string
- func (p *Provider) Model() string
- func (p *Provider) Predict(ctx context.Context, req providers.PredictionRequest) (providers.PredictionResponse, error)
- func (p *Provider) PredictStream(ctx context.Context, req providers.PredictionRequest) (<-chan providers.StreamChunk, error)
- func (p *Provider) Reset()
- func (p *Provider) ShouldIncludeRawOutput() bool
- func (p *Provider) SupportsStreaming() bool
- func (p *Provider) TurnCount() int
- type StreamSession
- func (s *StreamSession) Close() error
- func (s *StreamSession) Done() <-chan struct{}
- func (s *StreamSession) EndInput()
- func (s *StreamSession) Error() error
- func (s *StreamSession) RemainingTurns() int
- func (s *StreamSession) Response() <-chan providers.StreamChunk
- func (s *StreamSession) SendChunk(ctx context.Context, chunk *types.MediaChunk) error
- func (s *StreamSession) SendSystemContext(ctx context.Context, text string) error
- func (s *StreamSession) SendText(ctx context.Context, text string) error
- func (s *StreamSession) TriggerNextResponse(ctx context.Context) error
- type StreamingProvider
- type TimingMode
Constants ¶
This section is empty.
Variables ¶
var ErrSessionClosed = errors.New("session is closed")
ErrSessionClosed is returned when attempting to use a closed session.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Timing controls response delivery timing.
// Default: TimingInstant
Timing TimingMode
// Speed is the multiplier for TimingAccelerated mode.
// Default: 2.0 (2x speed)
Speed float64
// MatchMode controls how requests are matched to recorded responses.
// Default: MatchByTurn (sequential order)
MatchMode MatchMode
// Metadata contains additional information about the recording.
// This can include judge targets, tags, and provider information
// that should flow through to evaluation contexts.
Metadata map[string]interface{}
}
Config configures the replay provider.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for replay.
type MatchMode ¶
type MatchMode int
MatchMode controls how incoming requests are matched to recorded responses.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider replays recorded session responses without making LLM calls.
func NewProvider ¶
func NewProvider(rec *recording.SessionRecording, cfg *Config) (*Provider, error)
NewProvider creates a replay provider from a session recording.
func NewProviderFromFile ¶
NewProviderFromFile loads a recording file and creates a replay provider.
func (*Provider) CalculateCost ¶
CalculateCost returns zero cost as replays don't incur real costs.
func (*Provider) CurrentTurn ¶
CurrentTurn returns the current turn index (0-based).
func (*Provider) GetMetadata ¶ added in v1.1.9
GetMetadata returns metadata about the recording. This includes judge targets, tags, and provider information that can be used by evaluation frameworks and assertions.
func (*Provider) Model ¶ added in v1.1.8
Model returns the model name. For replay provider, this returns "replay".
func (*Provider) Predict ¶
func (p *Provider) Predict( ctx context.Context, req providers.PredictionRequest, ) (providers.PredictionResponse, error)
Predict returns the next recorded response.
func (*Provider) PredictStream ¶
func (p *Provider) PredictStream( ctx context.Context, req providers.PredictionRequest, ) (<-chan providers.StreamChunk, error)
PredictStream returns the recorded response as a single stream chunk.
func (*Provider) Reset ¶
func (p *Provider) Reset()
Reset resets the provider to replay from the beginning.
func (*Provider) ShouldIncludeRawOutput ¶
ShouldIncludeRawOutput returns false as replays don't have raw output.
func (*Provider) SupportsStreaming ¶
SupportsStreaming returns true as replay supports streaming.
type StreamSession ¶
type StreamSession struct {
// contains filtered or unexported fields
}
StreamSession implements StreamInputSession for replaying recorded sessions.
func (*StreamSession) Close ¶
func (s *StreamSession) Close() error
Close ends the streaming session.
func (*StreamSession) Done ¶
func (s *StreamSession) Done() <-chan struct{}
Done returns a channel that closes when the session ends.
func (*StreamSession) EndInput ¶
func (s *StreamSession) EndInput()
EndInput signals the end of input and triggers the next response. This implements the EndInputter interface expected by DuplexProviderStage.
func (*StreamSession) Error ¶
func (s *StreamSession) Error() error
Error returns any session error.
func (*StreamSession) RemainingTurns ¶
func (s *StreamSession) RemainingTurns() int
RemainingTurns returns the number of responses left to replay.
func (*StreamSession) Response ¶
func (s *StreamSession) Response() <-chan providers.StreamChunk
Response returns the response channel.
func (*StreamSession) SendChunk ¶
func (s *StreamSession) SendChunk(ctx context.Context, chunk *types.MediaChunk) error
SendChunk receives input chunks and triggers replay of the next response.
func (*StreamSession) SendSystemContext ¶
func (s *StreamSession) SendSystemContext(ctx context.Context, text string) error
SendSystemContext sends system context (ignored for replay).
func (*StreamSession) SendText ¶
func (s *StreamSession) SendText(ctx context.Context, text string) error
SendText receives text input and triggers replay of the next response.
func (*StreamSession) TriggerNextResponse ¶
func (s *StreamSession) TriggerNextResponse(ctx context.Context) error
TriggerNextResponse manually triggers the next response (for testing).
type StreamingProvider ¶
type StreamingProvider struct {
*Provider
// contains filtered or unexported fields
}
StreamingProvider extends Provider with streaming support for duplex replay.
func NewStreamingProviderFromArenaOutput ¶
func NewStreamingProviderFromArenaOutput(path string, cfg *Config) (*StreamingProvider, error)
NewStreamingProviderFromArenaOutput creates a streaming replay provider from an arena output file.
func (*StreamingProvider) CreateStreamSession ¶
func (p *StreamingProvider) CreateStreamSession( ctx context.Context, req *providers.StreamingInputConfig, ) (providers.StreamInputSession, error)
CreateStreamSession creates a new bidirectional streaming session for replay.
func (*StreamingProvider) GetStreamingCapabilities ¶
func (p *StreamingProvider) GetStreamingCapabilities() providers.StreamingCapabilities
GetStreamingCapabilities returns detailed information about streaming support.
func (*StreamingProvider) SupportsStreamInput ¶
func (p *StreamingProvider) SupportsStreamInput() []string
SupportsStreamInput returns the media types supported for streaming input.
type TimingMode ¶
type TimingMode int
TimingMode controls how response timing is handled during replay.
const ( // TimingInstant delivers responses immediately without delay. TimingInstant TimingMode = iota // TimingRealTime delivers responses with original timing preserved. TimingRealTime // TimingAccelerated delivers responses with accelerated timing. TimingAccelerated )