voicetest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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 AgentHandoffAssertOptions

type AgentHandoffAssertOptions struct {
	NewAgentType reflect.Type
	NewAgentID   string
}

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 EventType

type EventType string
const (
	EventMessage            EventType = "message"
	EventFunctionCall       EventType = "function_call"
	EventFunctionCallOutput EventType = "function_call_output"
	EventAgentHandoff       EventType = "agent_handoff"
)

type FakeLLM

type FakeLLM struct {
	*llm.Base
	// contains filtered or unexported fields
}

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) Calls

func (f *FakeLLM) Calls() stream.Reader[FakeLLMCall]

func (*FakeLLM) Chat

func (f *FakeLLM) Chat(ctx context.Context, options llm.ChatOptions) (llm.LLMStream, error)

func (*FakeLLM) Close

func (f *FakeLLM) Close(ctx context.Context) error

func (*FakeLLM) DroppedObservations

func (f *FakeLLM) DroppedObservations() uint64

func (*FakeLLM) RemoveResponse

func (f *FakeLLM) RemoveResponse(input string) bool

type FakeLLMCall

type FakeLLMCall struct {
	Input       string
	ChatContext *llm.ChatContext
	ToolContext *llm.Context
	Options     llm.ChatOptions
}

type FakeLLMOptions

type FakeLLMOptions struct {
	Responses           []FakeLLMResponse
	Label               string
	Provider            string
	Model               string
	ChunkRunes          int
	StreamCapacity      int
	ObservationCapacity int
}

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 FakeToolCall struct {
	Name string
	Args map[string]any
}

type FunctionCallAssert

type FunctionCallAssert[T any] struct {
	*EventAssert[T]
	Call *llm.FunctionCall
}

type FunctionCallAssertOptions

type FunctionCallAssertOptions struct {
	Name string
	Args map[string]any
}

type FunctionCallOutputAssert

type FunctionCallOutputAssert[T any] struct {
	*EventAssert[T]
	Output *llm.FunctionCallOutput
}

type FunctionCallOutputAssertOptions

type FunctionCallOutputAssertOptions struct {
	Output  *string
	IsError *bool
}

type MessageAssert

type MessageAssert[T any] struct {
	*EventAssert[T]
	Message *llm.ChatMessage
}

func (*MessageAssert[T]) Judge

func (a *MessageAssert[T]) Judge(ctx context.Context, model llm.LLM, intent string) error

Judge asks an LLM to make a structured, tool-forced intent judgment.

type MessageAssertOptions

type MessageAssertOptions struct{ Role llm.ChatRole }

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]

func (*RunAssert[T]) SkipNext

func (a *RunAssert[T]) SkipNext(count int) *RunAssert[T]

type RunEvent

type RunEvent struct {
	Type     EventType
	Item     llm.ChatItem
	OldAgent any
	NewAgent any
}

func (RunEvent) CreatedAt

func (e RunEvent) CreatedAt() int64

type RunOutputOptions

type RunOutputOptions struct {
	MaxRetries        int
	RetryInstructions string
}

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 NewRunResult[T any](userInput string) *RunResult[T]

func (*RunResult[T]) Complete

func (r *RunResult[T]) Complete(output T, hasOutput bool, err error)

func (*RunResult[T]) Done

func (r *RunResult[T]) Done() bool

func (*RunResult[T]) Events

func (r *RunResult[T]) Events() []RunEvent

func (*RunResult[T]) Expect

func (r *RunResult[T]) Expect() *RunAssert[T]

func (*RunResult[T]) FinalOutput

func (r *RunResult[T]) FinalOutput() (T, error)

func (*RunResult[T]) Record

func (r *RunResult[T]) Record(item llm.ChatItem) bool

func (*RunResult[T]) RecordHandoff

func (r *RunResult[T]) RecordHandoff(item *llm.AgentHandoffItem, oldAgent, newAgent any) bool

func (*RunResult[T]) Reject

func (r *RunResult[T]) Reject(err error)

func (*RunResult[T]) Require

func (r *RunResult[T]) Require(t TestingT) *RunAssert[T]

func (*RunResult[T]) UserInput

func (r *RunResult[T]) UserInput() string

func (*RunResult[T]) Wait

func (r *RunResult[T]) Wait(ctx context.Context) (*RunResult[T], error)

type TestingT

type TestingT interface {
	Helper()
	Fatalf(format string, args ...any)
}

Jump to

Keyboard shortcuts

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