Documentation
¶
Overview ¶
Package voicetest provides deterministic model doubles and assertion helpers for voice-agent tests. The package name avoids colliding with Go's testing package when imported without an alias.
Index ¶
- Constants
- Variables
- type AgentHandoffAssert
- type AgentHandoffAssertOptions
- type AssertionError
- type EventAssert
- func (a *EventAssert[T]) Event() RunEvent
- func (a *EventAssert[T]) IsAgentHandoff(options AgentHandoffAssertOptions) *AgentHandoffAssert[T]
- func (a *EventAssert[T]) IsFunctionCall(options FunctionCallAssertOptions) *FunctionCallAssert[T]
- func (a *EventAssert[T]) IsFunctionCallOutput(options FunctionCallOutputAssertOptions) *FunctionCallOutputAssert[T]
- func (a *EventAssert[T]) IsMessage(options MessageAssertOptions) *MessageAssert[T]
- type EventRangeAssert
- func (a *EventRangeAssert[T]) ContainsAgentHandoff(options AgentHandoffAssertOptions) *AgentHandoffAssert[T]
- func (a *EventRangeAssert[T]) ContainsFunctionCall(options FunctionCallAssertOptions) *FunctionCallAssert[T]
- func (a *EventRangeAssert[T]) ContainsFunctionCallOutput(options FunctionCallOutputAssertOptions) *FunctionCallOutputAssert[T]
- func (a *EventRangeAssert[T]) ContainsMessage(options MessageAssertOptions) *MessageAssert[T]
- type EventType
- type FakeLLM
- func (f *FakeLLM) AddResponses(responses ...FakeLLMResponse) error
- func (f *FakeLLM) Calls() stream.Reader[FakeLLMCall]
- func (f *FakeLLM) Chat(ctx context.Context, options llm.ChatOptions) (llm.LLMStream, error)
- func (f *FakeLLM) Close(ctx context.Context) error
- func (f *FakeLLM) DroppedObservations() uint64
- func (f *FakeLLM) RemoveResponse(input string) bool
- type FakeLLMCall
- type FakeLLMOptions
- type FakeLLMResponse
- type FakeLLMStream
- type FakeToolCall
- type FunctionCallAssert
- type FunctionCallAssertOptions
- type FunctionCallOutputAssert
- type FunctionCallOutputAssertOptions
- type MessageAssert
- type MessageAssertOptions
- type RunAssert
- func (a *RunAssert[T]) All() *EventRangeAssert[T]
- func (a *RunAssert[T]) At(index int) *EventAssert[T]
- func (a *RunAssert[T]) NextEvent(types ...EventType) *EventAssert[T]
- func (a *RunAssert[T]) NoMoreEvents()
- func (a *RunAssert[T]) Range(start, end int) *EventRangeAssert[T]
- func (a *RunAssert[T]) SkipNext(count int) *RunAssert[T]
- type RunEvent
- type RunOutputOptions
- type RunResult
- func (r *RunResult[T]) Complete(output T, hasOutput bool, err error)
- func (r *RunResult[T]) Done() bool
- func (r *RunResult[T]) Events() []RunEvent
- func (r *RunResult[T]) Expect() *RunAssert[T]
- func (r *RunResult[T]) FinalOutput() (T, error)
- func (r *RunResult[T]) Record(item llm.ChatItem) bool
- func (r *RunResult[T]) RecordHandoff(item *llm.AgentHandoffItem, oldAgent, newAgent any) bool
- func (r *RunResult[T]) Reject(err error)
- func (r *RunResult[T]) Require(t TestingT) *RunAssert[T]
- func (r *RunResult[T]) UserInput() string
- func (r *RunResult[T]) Wait(ctx context.Context) (*RunResult[T], error)
- type TestingT
Constants ¶
View Source
const ( DefaultFakeLLMChunkRunes = 3 DefaultFakeLLMStreamCapacity = 64 DefaultFakeLLMObserveCapacity = 128 )
Variables ¶
View Source
var ( ErrRunResultNotDone = errors.New("run result is not done") ErrNoFinalOutput = errors.New("run result has no final output") )
View Source
var ErrFakeLLMClosed = errors.New("fake LLM is closed")
Functions ¶
This section is empty.
Types ¶
type AgentHandoffAssert ¶
type AgentHandoffAssert[T any] struct { *EventAssert[T] Handoff *llm.AgentHandoffItem OldAgent any NewAgent any }
type AssertionError ¶
type AssertionError struct{ Message string }
func (*AssertionError) Error ¶
func (e *AssertionError) Error() string
type EventAssert ¶
type EventAssert[T any] struct { // contains filtered or unexported fields }
func (*EventAssert[T]) Event ¶
func (a *EventAssert[T]) Event() RunEvent
func (*EventAssert[T]) IsAgentHandoff ¶
func (a *EventAssert[T]) IsAgentHandoff(options AgentHandoffAssertOptions) *AgentHandoffAssert[T]
func (*EventAssert[T]) IsFunctionCall ¶
func (a *EventAssert[T]) IsFunctionCall(options FunctionCallAssertOptions) *FunctionCallAssert[T]
func (*EventAssert[T]) IsFunctionCallOutput ¶
func (a *EventAssert[T]) IsFunctionCallOutput(options FunctionCallOutputAssertOptions) *FunctionCallOutputAssert[T]
func (*EventAssert[T]) IsMessage ¶
func (a *EventAssert[T]) IsMessage(options MessageAssertOptions) *MessageAssert[T]
type EventRangeAssert ¶
type EventRangeAssert[T any] struct { // contains filtered or unexported fields }
func (*EventRangeAssert[T]) ContainsAgentHandoff ¶
func (a *EventRangeAssert[T]) ContainsAgentHandoff(options AgentHandoffAssertOptions) *AgentHandoffAssert[T]
func (*EventRangeAssert[T]) ContainsFunctionCall ¶
func (a *EventRangeAssert[T]) ContainsFunctionCall(options FunctionCallAssertOptions) *FunctionCallAssert[T]
func (*EventRangeAssert[T]) ContainsFunctionCallOutput ¶
func (a *EventRangeAssert[T]) ContainsFunctionCallOutput(options FunctionCallOutputAssertOptions) *FunctionCallOutputAssert[T]
func (*EventRangeAssert[T]) ContainsMessage ¶
func (a *EventRangeAssert[T]) ContainsMessage(options MessageAssertOptions) *MessageAssert[T]
type FakeLLM ¶
FakeLLM selects a scripted response by the latest user input, function output, or workflow instruction marker. It is safe to update between calls.
func NewFakeLLM ¶
func NewFakeLLM(options FakeLLMOptions) (*FakeLLM, error)
func (*FakeLLM) AddResponses ¶
func (f *FakeLLM) AddResponses(responses ...FakeLLMResponse) error
func (*FakeLLM) DroppedObservations ¶
func (*FakeLLM) RemoveResponse ¶
type FakeLLMCall ¶
type FakeLLMCall struct {
Input string
ChatContext *llm.ChatContext
ToolContext *llm.Context
Options llm.ChatOptions
}
type FakeLLMOptions ¶
type FakeLLMResponse ¶
type FakeLLMResponse struct {
Input string
Content string
TTFT time.Duration
Duration time.Duration
ToolCalls []FakeToolCall
Usage *llm.CompletionUsage
Err error
}
type FakeLLMStream ¶
type FakeLLMStream struct {
*llm.BaseStream
// contains filtered or unexported fields
}
type FakeToolCall ¶
type FunctionCallAssert ¶
type FunctionCallAssert[T any] struct { *EventAssert[T] Call *llm.FunctionCall }
type FunctionCallOutputAssert ¶
type FunctionCallOutputAssert[T any] struct { *EventAssert[T] Output *llm.FunctionCallOutput }
type MessageAssert ¶
type MessageAssert[T any] struct { *EventAssert[T] Message *llm.ChatMessage }
type MessageAssertOptions ¶
type RunAssert ¶
type RunAssert[T any] struct { // contains filtered or unexported fields }
func (*RunAssert[T]) All ¶
func (a *RunAssert[T]) All() *EventRangeAssert[T]
func (*RunAssert[T]) At ¶
func (a *RunAssert[T]) At(index int) *EventAssert[T]
func (*RunAssert[T]) NextEvent ¶
func (a *RunAssert[T]) NextEvent(types ...EventType) *EventAssert[T]
func (*RunAssert[T]) NoMoreEvents ¶
func (a *RunAssert[T]) NoMoreEvents()
func (*RunAssert[T]) Range ¶
func (a *RunAssert[T]) Range(start, end int) *EventRangeAssert[T]
type RunOutputOptions ¶
type RunResult ¶
type RunResult[T any] struct { // contains filtered or unexported fields }
RunResult records the ordered chat/tool/handoff trace of one test turn. It can be populated by AgentSession.Run or directly by deterministic harnesses.
func NewRunResult ¶
func (*RunResult[T]) FinalOutput ¶
func (*RunResult[T]) RecordHandoff ¶
func (r *RunResult[T]) RecordHandoff(item *llm.AgentHandoffItem, oldAgent, newAgent any) bool
Click to show internal directories.
Click to hide internal directories.