Class DefaultContentInjector
-
- All Implemented Interfaces:
-
dev.langchain4j.rag.content.injector.ContentInjector
public class DefaultContentInjector implements ContentInjector
Default implementation of ContentInjector intended to be suitable for the majority of use cases. It's important to note that while efforts will be made to avoid breaking changes, the default behavior of this class may be updated in the future if it's found that the current behavior does not adequately serve the majority of use cases. Such changes would be made to benefit both current and future users. This implementation appends all given Contents to the end of the given UserMessage in their order of iteration. Refer to DEFAULT_PROMPT_TEMPLATE and implementation for more details. Configurable parameters (optional): - promptTemplate: The prompt template that defines how the original
userMessageandcontentsare combined into the resulting UserMessage. The text of the template should contain the{{userMessage}}and{{contents}}variables. - metadataKeysToInclude: A list of Metadata keys that should be included with each textSegment.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classDefaultContentInjector.DefaultContentInjectorBuilder
-
Field Summary
Fields Modifier and Type Field Description public final static PromptTemplateDEFAULT_PROMPT_TEMPLATE
-
Constructor Summary
Constructors Constructor Description DefaultContentInjector()DefaultContentInjector(List<String> metadataKeysToInclude)DefaultContentInjector(PromptTemplate promptTemplate)DefaultContentInjector(PromptTemplate promptTemplate, List<String> metadataKeysToInclude)
-
Method Summary
Modifier and Type Method Description static DefaultContentInjector.DefaultContentInjectorBuilderbuilder()ChatMessageinject(List<Content> contents, ChatMessage chatMessage)Injects given Contents into a given ChatMessage. UserMessageinject(List<Content> contents, UserMessage userMessage)-
-
Constructor Detail
-
DefaultContentInjector
DefaultContentInjector()
-
DefaultContentInjector
DefaultContentInjector(PromptTemplate promptTemplate)
-
DefaultContentInjector
DefaultContentInjector(PromptTemplate promptTemplate, List<String> metadataKeysToInclude)
-
-
Method Detail
-
builder
static DefaultContentInjector.DefaultContentInjectorBuilder builder()
-
inject
ChatMessage inject(List<Content> contents, ChatMessage chatMessage)
Injects given Contents into a given ChatMessage. This method has a default implementation in order to temporarily support current custom implementations of
ContentInjector. The default implementation will be removed soon.- Parameters:
contents- The list of Content to be injected.chatMessage- The ChatMessage into which the Contents are to be injected.- Returns:
The UserMessage with the injected Contents.
-
inject
@Deprecated() UserMessage inject(List<Content> contents, UserMessage userMessage)
-
-
-
-