Package akka.javasdk.testkit
Class TestModelProvider
Object
akka.javasdk.testkit.TestModelProvider
- All Implemented Interfaces:
akka.javasdk.agent.ModelProvider,akka.javasdk.agent.ModelProvider.Custom
public final class TestModelProvider
extends Object
implements akka.javasdk.agent.ModelProvider.Custom
A
ModelProvider implementation for testing purposes that does not use a real AI model. It
allows defining mock responses based on input predicates.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents an AI response, which can include a message and/or list of tool invocation requests.static interfaceRepresents an input message.static classstatic final recordRepresents a tool invocation request with a name and arguments.static final recordRepresents a tool result.static final recordRepresents a user message.static classBase class for building reply configurations for specific input predicates.static final classSpecialized reply builder for handling tool result messages.Nested classes/interfaces inherited from interface akka.javasdk.agent.ModelProvider
akka.javasdk.agent.ModelProvider.Anthropic, akka.javasdk.agent.ModelProvider.Bedrock, akka.javasdk.agent.ModelProvider.Custom, akka.javasdk.agent.ModelProvider.FromConfig, akka.javasdk.agent.ModelProvider.GoogleAIGemini, akka.javasdk.agent.ModelProvider.HuggingFace, akka.javasdk.agent.ModelProvider.LocalAI, akka.javasdk.agent.ModelProvider.Ollama, akka.javasdk.agent.ModelProvider.OpenAi, akka.javasdk.agent.ModelProvider.VertexAi -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfixedResponse(String response) Configures a fixed response for all input messages.voidreset()Resets all previously added response configurations.whenMessage(String message) Configures to respond when the content of anTestModelProvider.InputMessageis an exact match of the passedmessage.whenMessage(Predicate<String> predicate) Configures to respond when the passed string predicate matches the content of anTestModelProvider.InputMessage.whenToolResult(TestModelProvider.ToolResult toolResult) Configures to respond when anTestModelProvider.ToolResultis an exact match oftoolResult.whenToolResult(Predicate<TestModelProvider.ToolResult> predicate) Configures to respond when the given predicate matches aTestModelProvider.ToolResult.whenUserMessage(TestModelProvider.UserMessage userMessage) Configures to respond when anTestModelProvider.UserMessageis an exact match ofuserMessage.whenUserMessage(Predicate<TestModelProvider.UserMessage> predicate) Configures to respond when the given predicate matches aTestModelProvider.UserMessage.
-
Constructor Details
-
TestModelProvider
public TestModelProvider()
-
-
Method Details
-
modelName
- Specified by:
modelNamein interfaceakka.javasdk.agent.ModelProvider.Custom
-
createChatModel
- Specified by:
createChatModelin interfaceakka.javasdk.agent.ModelProvider.Custom
-
createStreamingChatModel
- Specified by:
createStreamingChatModelin interfaceakka.javasdk.agent.ModelProvider.Custom
-
fixedResponse
Configures a fixed response for all input messages. -
whenMessage
Configures to respond when the passed string predicate matches the content of anTestModelProvider.InputMessage. The predicate is applied to content ofTestModelProvider.UserMessageorTestModelProvider.ToolResult.Note that to finish the configuration, you must call one of the reply methods.
-
whenMessage
Configures to respond when the content of anTestModelProvider.InputMessageis an exact match of the passedmessage.Note that to finish the configuration, you must call one of the reply methods.
-
whenUserMessage
public TestModelProvider.WhenClause whenUserMessage(Predicate<TestModelProvider.UserMessage> predicate) Configures to respond when the given predicate matches aTestModelProvider.UserMessage. The predicate is applied toTestModelProvider.UserMessageinstances only.Note that to finish the configuration, you must call one of the reply methods.
-
whenUserMessage
Configures to respond when anTestModelProvider.UserMessageis an exact match ofuserMessage.Note that to finish the configuration, you must call one of the reply methods.
-
whenToolResult
public TestModelProvider.WhenToolReplyClause whenToolResult(Predicate<TestModelProvider.ToolResult> predicate) Configures to respond when the given predicate matches aTestModelProvider.ToolResult. The predicate is applied toTestModelProvider.ToolResultinstances only.Note that to finish the configuration, you must call one of the reply methods.
-
whenToolResult
public TestModelProvider.WhenToolReplyClause whenToolResult(TestModelProvider.ToolResult toolResult) Configures to respond when anTestModelProvider.ToolResultis an exact match oftoolResult.Note that to finish the configuration, you must call one of the reply methods.
-
reset
public void reset()Resets all previously added response configurations.
-