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 record
Represents an AI response, which can include a message and/or list of tool invocation requests.static interface
Represents an input message.static class
static final record
Represents a tool invocation request with a name and arguments.static final record
Represents a tool result.static final record
Represents a user message.static class
Base class for building reply configurations for specific input predicates.static final class
Specialized 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.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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
fixedResponse
(String response) Configures a fixed response for all input messages.void
reset()
Resets all previously added response configurations.whenMessage
(String message) Configures to respond when the content of anTestModelProvider.InputMessage
is 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.ToolResult
is 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.UserMessage
is 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
-
createChatModel
- Specified by:
createChatModel
in interfaceakka.javasdk.agent.ModelProvider.Custom
-
createStreamingChatModel
- Specified by:
createStreamingChatModel
in 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.UserMessage
orTestModelProvider.ToolResult
.Note that to finish the configuration, you must call one of the reply methods.
-
whenMessage
Configures to respond when the content of anTestModelProvider.InputMessage
is 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.UserMessage
instances only.Note that to finish the configuration, you must call one of the reply methods.
-
whenUserMessage
Configures to respond when anTestModelProvider.UserMessage
is 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.ToolResult
instances 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.ToolResult
is 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.
-