Class CurrentInvocation
java.lang.Object
dev.langchain4j.internal.CurrentInvocation
Holds the
InvocationContext.invocationId() of the AI Service invocation that is doing its own work on the
current thread (for example running a tool, a guardrail, retrieval or the chatRequestTransformer), so that an AI Service
invoked by that work can record it as its parent invocation.
It is set only around that work, not around code of the caller (the handlers of a TokenStream, the
subscriber of a returned publisher, the continuations of a returned future), so an AI Service invoked by the
caller's code normally has no parent invocation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TcallWith(InvocationContext invocationContext, Supplier<T> action) Calls the given action with the id of the given invocation context as the current one, then restores the previous one.static <T> TcallWithout(Supplier<T> action) Calls the given action with no current invocation, then restores the previous one.static UUID
-
Method Details
-
invocationId
-
callWith
Calls the given action with the id of the given invocation context as the current one, then restores the previous one. Does nothing special when the invocation context isnull. -
callWithout
Calls the given action with no current invocation, then restores the previous one. Used when an AI Service is invoked during the work of another invocation: its listeners and callbacks are not part of that work.
-