Class DefaultToolExecutedEvent
java.lang.Object
dev.langchain4j.observability.event.AbstractAiServiceEvent
dev.langchain4j.observability.event.DefaultToolExecutedEvent
- All Implemented Interfaces:
AiServiceEvent, ToolExecutedEvent
Default implementation of
ToolExecutedEvent.-
Nested Class Summary
Nested classes/interfaces inherited from interface AiServiceEvent
AiServiceEvent.Builder<T>Nested classes/interfaces inherited from interface ToolExecutedEvent
ToolExecutedEvent.ToolExecutedEventBuilder -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionbooleanisError()Returns whether the tool execution failed, for example because the tool threw an exception and the error was sent to the LLM.request()Gets theToolExecutionRequestthat initiated the tool execution.Returns the contents of the tool execution result.Returns the tool execution result as a plain text string.Methods inherited from class AbstractAiServiceEvent
invocationContextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AiServiceEvent
invocationContextMethods inherited from interface ToolExecutedEvent
eventClass, toBuilder
-
Constructor Details
-
DefaultToolExecutedEvent
-
-
Method Details
-
request
Description copied from interface:ToolExecutedEventGets theToolExecutionRequestthat initiated the tool execution.- Specified by:
requestin interfaceToolExecutedEvent
-
resultText
Description copied from interface:ToolExecutedEventReturns the tool execution result as a plain text string. This is a convenience method for when the result is known to be a singleTextContent.- Specified by:
resultTextin interfaceToolExecutedEvent- Returns:
- the text of the single
TextContentelement.
-
resultContents
Description copied from interface:ToolExecutedEventReturns the contents of the tool execution result.- Specified by:
resultContentsin interfaceToolExecutedEvent- Returns:
- the list of
Contentelements, nevernull.
-
isError
Description copied from interface:ToolExecutedEventReturns whether the tool execution failed, for example because the tool threw an exception and the error was sent to the LLM. It is alsotruewhen the tool error failed the AI Service invocation (for example withToolExecutionErrorHandler.failInvocation()): then the result is the error text, which was not sent to the LLM, and anAiServiceErrorEventfollows. AI Services created withAiServicesalways report it. Integrations that create their own events should report it too: code that reads events reflectively, for example a JSON serializer that serializes this event or anAiServiceInvocationSummaryEventcontaining it, fails withUnsupportedOperationExceptionwhen it is not reported.- Specified by:
isErrorin interfaceToolExecutedEvent- Returns:
trueif the tool execution failed,falseif it succeeded
-