Uses of Class
dev.langchain4j.test.mock.MockDecisionModel
Packages that use MockDecisionModel
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 MockDecisionModel in dev.langchain4j.test.mock
Methods in dev.langchain4j.test.mock that return MockDecisionModelModifier and TypeMethodDescriptionstatic MockDecisionModelMockDecisionModel.thatAnswers(Function<? super DecisionRequest, ? extends Map<String, ? extends DecisionAnswer>> answers) A model that answers the first request with the answers computed from it, keyed by question name.static MockDecisionModelMockDecisionModel.thatAnswers(Map<String, ? extends DecisionAnswer> answers) A model that answers the first request with the given answers, keyed by question name.static MockDecisionModelMockDecisionModel.thatAnswersQuestions(Function<Question, ? extends DecisionAnswer> answer) A model that answers every question of the first request with the answer computed from the question.static MockDecisionModelMockDecisionModel.thatAnswersYesNoQuestions(ToDoubleFunction<YesNoQuestion> probability) A model that answers every yes/no question of the first request with the probability of "yes", from 0 to 1, computed from the question.static MockDecisionModelMockDecisionModel.thatFails(RuntimeException exception) A model whose first request fails with exactly the given exception.static MockDecisionModelMockDecisionModel.thatResponds(DecisionResponse response) A model that answers the first request with the answers and the metadata of the given response, for example its token usage or model name, to test code that reads them, such as a cost check.MockDecisionModel.thenAnswers(Function<? super DecisionRequest, ? extends Map<String, ? extends DecisionAnswer>> answers) Adds a step: the next request is answered with the answers computed from it, keyed by question name.MockDecisionModel.thenAnswers(Map<String, ? extends DecisionAnswer> answers) Adds a step: the next request is answered with the given answers, keyed by question name.MockDecisionModel.thenAnswersQuestions(Function<Question, ? extends DecisionAnswer> answer) Adds a step: every question of the next request is answered with the answer computed from the question.MockDecisionModel.thenAnswersYesNoQuestions(ToDoubleFunction<YesNoQuestion> probability) Adds a step: every yes/no question of the next request is answered with the probability of "yes", from 0 to 1, computed from the question, seeMockDecisionModel.thatAnswersYesNoQuestions(ToDoubleFunction).MockDecisionModel.thenFails(RuntimeException exception) Adds a step: the next request fails with exactly the given exception.MockDecisionModel.thenRepeats()Answers every further request with the last step of the script.MockDecisionModel.thenResponds(DecisionResponse response) Adds a step: the next request is answered with the answers and the metadata of the given response, for example its token usage or model name, seeMockDecisionModel.thatResponds(DecisionResponse).MockDecisionModel.withListeners(DecisionModelListener... listeners) Notifies the given listeners of each call, like a real model does.MockDecisionModel.withListeners(List<DecisionModelListener> listeners) Notifies the given listeners of each call, like a real model does.