Documentation
¶
Overview ¶
Package replay provides Model implementations that need no provider: a scripted model for unit tests, and a recorder and replayer pair so that a real model's responses can be captured once and served deterministically afterwards. Tests and CI never call a provider.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotRecorded = errors.New("replay: no recorded response for this request")
ErrNotRecorded means the replayer has no response for the request.
Functions ¶
Types ¶
type Recorder ¶
Recorder wraps a model and stores every successful exchange in Dir.
func (*Recorder) Generate ¶
func (r *Recorder) Generate(ctx context.Context, req agentrt.ModelRequest) (agentrt.ModelResponse, error)
Generate implements agentrt.Model.
type Replayer ¶
Replayer serves recorded responses and fails on anything unrecorded.
func (*Replayer) Generate ¶
func (p *Replayer) Generate(_ context.Context, req agentrt.ModelRequest) (agentrt.ModelResponse, error)
Generate implements agentrt.Model.
type Scripted ¶
type Scripted struct {
ModelName string
Responses []agentrt.ModelResponse
// Errors, when set, is consulted first: a non-nil entry is returned
// instead of the response at that index.
Errors []error
// Requests records every request received.
Requests []agentrt.ModelRequest
// contains filtered or unexported fields
}
Scripted returns canned responses in order.
func (*Scripted) Generate ¶
func (s *Scripted) Generate(_ context.Context, req agentrt.ModelRequest) (agentrt.ModelResponse, error)
Generate implements agentrt.Model.
Click to show internal directories.
Click to hide internal directories.