Documentation
¶
Overview ¶
Package llmtest provides public test helpers for the llm package.
StubClient is a scriptable llm.Client. Each Stream call consumes one TurnScript; the agent loop tests script multi-turn conversations as a slice of TurnScripts.
Index ¶
- Variables
- type ImageScript
- type StubClient
- func (s *StubClient) Complete(ctx context.Context, req llm.Request) (llm.Response, error)
- func (s *StubClient) GenerateImage(_ context.Context, req llm.ImageRequest) (llm.ImageResponse, error)
- func (s *StubClient) ImageRequests() []llm.ImageRequest
- func (s *StubClient) Requests() []llm.Request
- func (s *StubClient) ScriptImages(scripts ...ImageScript)
- func (s *StubClient) Stream(ctx context.Context, req llm.Request) (<-chan llm.Event, error)
- type TurnScript
Constants ¶
This section is empty.
Variables ¶
var ErrStubExhausted = errors.New("aikido/llmtest: stub client: script exhausted")
ErrStubExhausted is returned by Stream when no scripts remain.
Functions ¶
This section is empty.
Types ¶
type ImageScript ¶ added in v0.2.6
type ImageScript struct {
Response llm.ImageResponse
Err error
}
ImageScript is one scripted GenerateImage outcome. Err short-circuits the call; otherwise Response is returned verbatim.
type StubClient ¶
type StubClient struct {
// contains filtered or unexported fields
}
StubClient is a scriptable llm.Client that also implements the optional llm.ImageGenerator capability.
func NewStubClient ¶
func NewStubClient(turns ...TurnScript) *StubClient
NewStubClient returns a StubClient that plays the given turn scripts in order.
func (*StubClient) Complete ¶ added in v0.2.4
Complete consumes one TurnScript and folds its events into a Response. EventError short-circuits with that error (matching live-client semantics). Useful for testing non-streaming callers without a separate scripting type: the same TurnScript drives both Stream and Complete.
func (*StubClient) GenerateImage ¶ added in v0.2.6
func (s *StubClient) GenerateImage(_ context.Context, req llm.ImageRequest) (llm.ImageResponse, error)
GenerateImage consumes one ImageScript. Returns ErrStubExhausted when no image scripts remain.
func (*StubClient) ImageRequests ¶ added in v0.2.6
func (s *StubClient) ImageRequests() []llm.ImageRequest
ImageRequests returns a snapshot of every llm.ImageRequest the stub has been called with, in order.
func (*StubClient) Requests ¶
func (s *StubClient) Requests() []llm.Request
Requests returns a snapshot of every llm.Request the stub has been called with, in order. Useful for assertion in tests.
func (*StubClient) ScriptImages ¶ added in v0.2.6
func (s *StubClient) ScriptImages(scripts ...ImageScript)
ScriptImages appends image scripts consumed by GenerateImage in order. Separate from the turn scripts: a test can drive both endpoints on one stub.
type TurnScript ¶
type TurnScript struct {
Events []llm.Event
// Block, if non-nil, causes Stream's producer to block on receive from this
// channel before emitting any events. Closing it (or context cancellation)
// unblocks the goroutine. Useful for timeout tests.
Block <-chan struct{}
}
TurnScript is the events the stub emits for one Stream call.