Class ToolCompensatedEvent.ToolCompensatedEventBuilder
java.lang.Object
dev.langchain4j.observability.api.event.AiServiceEvent.Builder<ToolCompensatedEvent>
dev.langchain4j.observability.api.event.ToolCompensatedEvent.ToolCompensatedEventBuilder
- Enclosing interface:
ToolCompensatedEvent
public static class ToolCompensatedEvent.ToolCompensatedEventBuilder
extends AiServiceEvent.Builder<ToolCompensatedEvent>
- Since:
- 1.20.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedCreates a builder initialized from an existingToolCompensatedEvent. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds aToolCompensatedEvent.@Nullable ThrowablecompensationError(@Nullable Throwable compensationError) Sets the error of the compensating action:nullwhen the tool was rolled back successfully, otherwise the exception the compensating action failed with.invocationContext(InvocationContext invocationContext) booleanReturns whethercompensationError(Throwable)was called, also when it was called withnull.reason()reason(CompensationReason reason) Sets the reason the tool was compensated.request()request(ToolExecutionRequest request) Sets the compensated tool's request.resultContents(List<Content> resultContents) Sets the compensated tool's result contents.resultText(String resultText) Sets the compensated tool's result text.Methods inherited from class AiServiceEvent.Builder
invocationContext
-
Constructor Details
-
ToolCompensatedEventBuilder
protected ToolCompensatedEventBuilder() -
ToolCompensatedEventBuilder
Creates a builder initialized from an existingToolCompensatedEvent. When the event does not reportToolCompensatedEvent.compensationError()(it throwsUnsupportedOperationException), the builder copies everything else, andbuild()fails untilcompensationError(Throwable)is called.
-
-
Method Details
-
request
Sets the compensated tool's request. -
resultText
Sets the compensated tool's result text. The text will be wrapped into a singleTextContent. Mutually exclusive withresultContents(List). -
resultContents
@Experimental public ToolCompensatedEvent.ToolCompensatedEventBuilder resultContents(List<Content> resultContents) Sets the compensated tool's result contents. Mutually exclusive withresultText(String).- Since:
- 1.20.0
-
reason
Sets the reason the tool was compensated. -
compensationError
@Experimental public ToolCompensatedEvent.ToolCompensatedEventBuilder compensationError(@Nullable Throwable compensationError) Sets the error of the compensating action:nullwhen the tool was rolled back successfully, otherwise the exception the compensating action failed with. Required:build()fails when it was not called, also when the tool was rolled back successfully.- Since:
- 1.25.0
-
request
-
resultText
-
resultContents
-
reason
-
compensationError
- Since:
- 1.25.0
-
isCompensationErrorSet
public boolean isCompensationErrorSet()Returns whethercompensationError(Throwable)was called, also when it was called withnull. Used byDefaultToolCompensatedEventto check that it was called.- Since:
- 1.25.0
-
invocationContext
public ToolCompensatedEvent.ToolCompensatedEventBuilder invocationContext(InvocationContext invocationContext) - Overrides:
invocationContextin classAiServiceEvent.Builder<ToolCompensatedEvent>
-
build
Builds aToolCompensatedEvent.- Specified by:
buildin classAiServiceEvent.Builder<ToolCompensatedEvent>- Throws:
IllegalArgumentException- if neither or both ofresultTextandresultContentsare set, or ifcompensationError(Throwable)was not called.
-