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. This class is part of the fluent API for configuring how the LLM should respond with tool calls when it receives specific inputs.
Receiver class for configuring tool call responses from the LLM.
Properties
Functions
Adds an exact pattern match for an LLM answer that triggers a set of tool calls.
Adds an exact pattern match for an LLM answer that triggers a set of tool calls with predefined responses.
Adds an exact pattern match for an LLM answer that triggers a tool call.
Adds a partial pattern match for an LLM answer that triggers a set of tool calls.
Adds a partial pattern match for an LLM answer that triggers a tool call.
Adds a partial pattern match for an LLM answer that triggers a set of tool calls with predefined responses.
Adds a specific moderation response for an exact pattern match.
Associates a given moderation response with a specific partial pattern.
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 a list of LLM tool calls.
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 moderation response to the provided result.
Sets the default response to be returned when no other response matches.
Sets the tool registry to be used for tool execution.