Uses of Class
dev.langchain4j.test.mock.MockChatModel
Packages that use MockChatModel
Package
Description
Model mocks for tests: they need no network, answer the way a test tells them to, and record the requests they
receive.
-
Uses of MockChatModel in dev.langchain4j.test.mock
Methods in dev.langchain4j.test.mock that return MockChatModelModifier and TypeMethodDescriptionstatic MockChatModelMockChatModel.thatCallsTool(String toolName, String jsonArguments) A model that answers the first request with a call of the given tool.static MockChatModelMockChatModel.thatCallsTool(String toolName, Map<String, ?> arguments) A model that answers the first request with a call of the given tool.static MockChatModelMockChatModel.thatFails(RuntimeException exception) A model whose first request fails with exactly the given exception.static MockChatModelMockChatModel.thatResponds(AiMessage... aiMessages) A model that answers with the given messages in order, one per request.static MockChatModelMockChatModel.thatResponds(ChatResponse chatResponse) A model that answers the first request with exactly the given response, including its metadata, for example its token usage, model name or finish reason.static MockChatModelMockChatModel.thatResponds(String text) A model that answers the first request with the given text.static MockChatModelMockChatModel.thatResponds(Function<ChatRequest, AiMessage> answers) A model that computes the answer to the first request from the request.static MockChatModelMockChatModel.thatResponds(List<AiMessage> aiMessages) A model that answers with the given messages in order, one per request.MockChatModel.thenCallsTool(String toolName, String jsonArguments) Adds a step: the next request is answered with a call of the given tool.MockChatModel.thenCallsTool(String toolName, Map<String, ?> arguments) Adds a step: the next request is answered with a call of the given tool.MockChatModel.thenFails(RuntimeException exception) Adds a step: the next request fails with exactly the given exception.MockChatModel.thenRepeats()Answers every further request with the last step of the script.MockChatModel.thenResponds(AiMessage aiMessage) Adds a step: the next request is answered with the given message.MockChatModel.thenResponds(ChatResponse chatResponse) Adds a step: the next request is answered with exactly the given response, including its metadata, for example its token usage or finish reason.MockChatModel.thenResponds(String text) Adds a step: the next request is answered with the given text.MockChatModel.withListeners(ChatModelListener... listeners) Notifies the given listeners of each call, like a real model does.MockChatModel.withListeners(List<ChatModelListener> listeners) Notifies the given listeners of each call, like a real model does.MockChatModel.withSupportedCapabilities(Capability... capabilities) Reports the given capabilities fromMockChatModel.supportedCapabilities(), like a model that supports them.MockChatModel.withSupportedCapabilities(Set<Capability> capabilities) Reports the given capabilities fromMockChatModel.supportedCapabilities(), seeMockChatModel.withSupportedCapabilities(Capability...).MockChatModel.withTokenUsage(@Nullable TokenUsage tokenUsage) Reports the given token usage in the response to every request, except for a step that gives the whole response: that one reports exactly its own token usage.