MockLLMBuilder
Builder class for creating mock LLM executors for testing.
This class provides a fluent API for configuring mock responses for LLM requests and tool calls. It allows you to define how the LLM should respond to different inputs and how tools should behave when called during testing.
Example usage:
val mockLLMApi = getMockExecutor(toolRegistry) {
// Mock LLM text responses
mockLLMAnswer("Hello!") onRequestContains "Hello"
mockLLMAnswer("I don't know how to answer that.").asDefaultResponse
// Mock LLM tool calls
mockLLMToolCall(CreateTool, CreateTool.Args("solve")) onRequestEquals "Solve task"
// Mock tool behavior
mockTool(PositiveToneTool) alwaysReturns "The text has a positive tone."
mockTool(NegativeToneTool) alwaysTells {
println("Negative tone tool called")
"The text has a negative tone."
}
}
Types
Receiver class for configuring tool behavior during testing.
Receiver class for configuring tool call responses from the LLM.
Functions
Convenience extension function for configuring a text tool to always return the specified string.
Convenience extension function for configuring a text tool to always execute the specified action and return its string result.
Builds and returns a PromptExecutor configured with the mock responses and tool actions.
Convenience extension function for configuring a text tool to execute the specified action and return its string result when it receives matching arguments.
Creates a mock for an LLM tool call.
Mocks a tool call for the provided tool function and arguments.
Associates a tool function with the MockLLMBuilder to create a MockToolFromCallableReceiver instance.
Configures the LLM to respond with this string when the user request satisfies the specified condition.
Configures the LLM to respond with this string when the user request contains the specified pattern.
Configures the LLM to respond with this string when the user request exactly matches the specified pattern.
Sets the default response to be returned when no other response matches.
Sets the tool registry to be used for tool execution.