llmtest

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package llmtest provides helpers for testing code that consumes llm.Stream channels, following the convention of packages like net/http/httptest.

Index

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 ReasoningEvent(s string) llm.Event

func SendEvents

func SendEvents(evs ...llm.Event) <-chan llm.Envelope

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 TextEvent

func TextEvent(s string) llm.Event

func ToolEvent

func ToolEvent(id, name string, args map[string]any) llm.Event

func UsageEvent added in v0.26.0

func UsageEvent(rec usage.Record) llm.Event

UsageEvent builds a UsageUpdatedEvent from a usage.Record. For simple tests that only need token counts, use UsageTokenEvent.

func UsageTokenEvent added in v0.40.0

func UsageTokenEvent(provider, model string, inputTokens, outputTokens int) llm.Event

UsageTokenEvent builds a minimal UsageUpdatedEvent with the given token counts. provider and model are optional; pass empty strings to omit them.

Types

This section is empty.

Jump to

Keyboard shortcuts

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