Interface RetrievalAugmentor
- All Known Implementing Classes:
DefaultRetrievalAugmentor
public interface RetrievalAugmentor
Augments the provided
This serves as an entry point into the RAG flow in LangChain4j.
You are free to use the default implementation (
ChatMessage with retrieved Contents.
This serves as an entry point into the RAG flow in LangChain4j.
You are free to use the default implementation (
DefaultRetrievalAugmentor) or to implement a custom one.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaugment(AugmentationRequest augmentationRequest) default CompletableFuture<AugmentationResult> augmentAsync(AugmentationRequest augmentationRequest) Non-blocking counterpart ofaugment(AugmentationRequest), invoked by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service modes so the RAG flow never blocks the calling thread.
-
Method Details
-
augment
- Parameters:
augmentationRequest- TheAugmentationRequestcontaining theChatMessageto augment.- Returns:
- The
AugmentationResultcontaining the augmentedChatMessage.
-
augmentAsync
@Experimental default CompletableFuture<AugmentationResult> augmentAsync(AugmentationRequest augmentationRequest) Non-blocking counterpart ofaugment(AugmentationRequest), invoked by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service modes so the RAG flow never blocks the calling thread.The default returns a failed future carrying
AsyncNotSupportedException: an augmentor that is not genuinely asynchronous does not pretend to be.DefaultRetrievalAugmentoroverrides this to compose its steps into a real future. A custom augmentor that has not opted in is still usable from the non-blocking modes: the AI Service offloads its blockingaugment(AugmentationRequest)to a shared virtual-thread executor, rather than the augmentor being silently offloaded on every call.An implementation that honors cancellation should abort in-flight work when the returned future is cancelled (best-effort).
- Parameters:
augmentationRequest- TheAugmentationRequestcontaining theChatMessageto augment.- Returns:
- A
CompletableFutureof theAugmentationResultcontaining the augmentedChatMessage. - Since:
- 1.20.0
-