Documentation
¶
Overview ¶
Package llmtest provides a deterministic in-memory llm.Model for tests: a scripted backend that returns a fixed sequence of turns and records the requests it was given, so the conversation loop and the agent runtime can be driven end to end without a real provider or any network.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrScriptExhausted = fault.New(fault.Terminal, "llmtest_script_exhausted", "scripted model: no turn left for this call")
ErrScriptExhausted is returned (terminal) when Generate is called more times than the script has turns.
Functions ¶
Types ¶
type ScriptedModel ¶
type ScriptedModel struct {
// contains filtered or unexported fields
}
ScriptedModel is a deterministic llm.Model: each Generate call returns the next turn from a fixed script and records the request it was handed. It ignores the request when choosing what to return, so a test fixes the model's behaviour up front and then asserts, via Requests, that the loop fed the right history back. Running off the end of the script is a terminal error, surfacing a loop that took more turns than the test scripted.
func NewScripted ¶
func NewScripted(turns ...llm.Response) *ScriptedModel
NewScripted builds a ScriptedModel that returns the given turns in order.
func (*ScriptedModel) Calls ¶
func (m *ScriptedModel) Calls() int
Calls reports how many times Generate has been invoked.
func (*ScriptedModel) Requests ¶
func (m *ScriptedModel) Requests() []llm.Request
Requests returns a copy of the requests Generate has received, in order, so a test can assert the conversation the loop built (e.g. that tool results were appended before the next turn).