Documentation
¶
Overview ¶
Package llmtest provides helpers for testing code that consumes llm.Stream channels, following the convention of packages like net/http/httptest.
Index ¶
- func CompletedEvent(reason llm.StopReason) llm.Event
- func ErrorEvent(err *llm.ProviderError) llm.Event
- func ReasoningEvent(s string) llm.Event
- func SendEvents(evs ...llm.Event) <-chan llm.Envelope
- func TextEvent(s string) llm.Event
- func ToolEvent(id, name string, args map[string]any) llm.Event
- func UsageEvent(rec usage.Record) llm.Event
- func UsageTokenEvent(provider, model string, inputTokens, outputTokens int) llm.Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompletedEvent ¶ added in v0.26.0
func CompletedEvent(reason llm.StopReason) llm.Event
func ErrorEvent ¶
func ErrorEvent(err *llm.ProviderError) llm.Event
func ReasoningEvent ¶
func SendEvents ¶
SendEvents builds a buffered, pre-populated Envelope channel and closes it. Use it to construct a fake stream in tests:
ch := llmtest.SendEvents(
llmtest.TextEvent("hello"),
llmtest.CompletedEvent(llm.StopReasonEndTurn),
)
func UsageEvent ¶ added in v0.26.0
UsageEvent builds a UsageUpdatedEvent from a usage.Record. For simple tests that only need token counts, use UsageTokenEvent.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.