Uses of Class
dev.langchain4j.test.service.AiServiceInvocationAssert
Packages that use AiServiceInvocationAssert
-
Uses of AiServiceInvocationAssert in dev.langchain4j.test
Methods in dev.langchain4j.test that return AiServiceInvocationAssertModifier and TypeMethodDescriptionstatic AiServiceInvocationAssertLangChain4jAssertions.assertThat(AiServiceCapture actual) Starts assertions on the only top-level AI Service invocation of the given capture, made withAiServiceCapture.static AiServiceInvocationAssertLangChain4jAssertions.assertThat(AiServiceInvocation actual) Starts assertions on the given AI Service invocation, captured withAiServiceCapture. -
Uses of AiServiceInvocationAssert in dev.langchain4j.test.service
Subclasses with type arguments of type AiServiceInvocationAssert in dev.langchain4j.test.serviceModifier and TypeClassDescriptionfinal classAssertions on what an AI Service did: which tools were executed, with which arguments and in which order, which sources were retrieved, how many times the chat model and the other models were called, why the response finished and whether the invocation succeeded.Methods in dev.langchain4j.test.service that return AiServiceInvocationAssertModifier and TypeMethodDescriptionAiServiceInvocationAssert.hasFailedWith(Class<? extends Throwable> type) Asserts that the invocation failed with an error of the given type, or with an error caused by one.AiServiceInvocationAssert.hasFailedWithMessageContaining(String text) Asserts that the invocation failed with an error whose message, or the message of one of its causes, contains the given text (case-sensitive).AiServiceInvocationAssert.hasFinishReason(FinishReason finishReason) Asserts that the final response of this invocation finished for the given reason.AiServiceInvocationAssert.hasModelCallCount(int expectedCount) Asserts that exactly the given number of model calls were made (seeAiServiceInvocation.modelCalls()): those of the AI Service to its own chat model and those of the components it runs, of every model type, also calls that failed.AiServiceInvocationAssert.hasModelCallCount(Class<? extends ModelCall> type, int expectedCount) Asserts that exactly the given number of calls were made to models of the given type (seeAiServiceInvocation.modelCalls()), also calls that failed.AiServiceInvocationAssert.hasNoFailedToolExecutions()Asserts that no tool execution failed (seeToolExecution.hasFailed()).AiServiceInvocationAssert.hasNoMoreToolExecutions()Asserts that every tool execution was checked by one of the tool assertions above, called before on the same invocation, like Mockito'sverifyNoMoreInteractions: the assertions add up across separateassertThat(...)statements on the sameAiServiceCapture.AiServiceInvocationAssert.hasNoRetrievedSources()Asserts that no sources were retrieved for retrieval-augmented generation (RAG), for example for a question that the retrieved knowledge should not answer.AiServiceInvocationAssert.hasNoToolExecutions()Asserts that no tool was executed, not even one that failed.AiServiceInvocationAssert.hasOwnChatModelCallCount(int expectedCount) Asserts that the AI Service called its own chat model exactly the given number of times (seeAiServiceInvocation.ownChatModelCalls()), also calls that failed.AiServiceInvocationAssert.hasOwnChatModelCallCountAtMost(int maxCount) Asserts that the AI Service called its own chat model at most the given number of times (seeAiServiceInvocation.ownChatModelCalls()), also calls that failed, for example to check that the AI Service does not call tools in a loop.AiServiceInvocationAssert.hasRetrievedSourceContaining(String text) Asserts that at least one retrieved source (seeAiServiceInvocation.sources()) contains the given text (case-sensitive).AiServiceInvocationAssert.hasSucceeded()Asserts that the invocation succeeded: it neither failed nor was cancelled.AiServiceInvocationAssert.hasToolExecuted(String toolName) Asserts that the tool with the given name was executed successfully at least once.AiServiceInvocationAssert.hasToolExecutedTimes(String toolName, int times) Asserts that the tool with the given name was executed successfully exactly the given number of times.AiServiceInvocationAssert.hasToolExecutedWith(String toolName, Consumer<Map<String, Object>> argumentsRequirements) Asserts that the tool with the given name was executed successfully at least once with arguments that pass the given requirements.AiServiceInvocationAssert.hasToolExecutedWith(String toolName, Map<String, ?> expectedArguments) Asserts that the tool with the given name was executed successfully at least once with arguments that contain all the given arguments.AiServiceInvocationAssert.hasToolExecutionFailed(String toolName) Asserts that the tool with the given name was executed at least once and that this execution failed: the tool threw an exception, or its arguments were invalid.AiServiceInvocationAssert.hasToolsExecutedExactlyInAnyOrder(String... toolNames) Asserts that exactly the given tools were executed successfully, in any order, and no other tools: a tool that is not given must not have been executed at all, not even in an execution that failed.AiServiceInvocationAssert.hasToolsExecutedInOrder(String... toolNames) Asserts that the given tools were executed successfully in the given order.AiServiceInvocationAssert.includingNested()Makes the assertions that follow check the whole tree of invocations: this invocation and all the invocations it started, directly or not (seeAiServiceInvocation.nestedInvocations()).AiServiceInvocationAssert.topLevelOnly()Makes the assertions that follow check only what this invocation did itself, not the invocations it started (seeAiServiceInvocation.nestedInvocations()).